Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added extended attribute getter for notation-go #46

Merged
merged 2 commits into from
Aug 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions signature/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package signature

import (
"crypto/x509"
"errors"
"time"
)

Expand Down Expand Up @@ -119,3 +120,14 @@ type Payload struct {
// Content contains the raw bytes of the payload.
Content []byte
}

// ExtendedAttribute fetches the specified Attribute with provided key from
// signerInfo.SignedAttributes.ExtendedAttributes
func (signerInfo *SignerInfo) ExtendedAttribute(key string) (Attribute, error) {
for _, attr := range signerInfo.SignedAttributes.ExtendedAttributes {
if attr.Key == key {
return attr, nil
}
}
return Attribute{}, errors.New("key not in ExtendedAttributes")
}