Save signature to file data for access outside helper functions
This commit is contained in:
parent
c346404d62
commit
4556eda901
1 changed files with 9 additions and 1 deletions
|
@ -21,6 +21,7 @@ type FileData struct {
|
|||
SignedAt time.Time
|
||||
MetaData map[string]string
|
||||
|
||||
signature *jess.Letter
|
||||
verificationError error
|
||||
}
|
||||
|
||||
|
@ -29,6 +30,11 @@ func (fd *FileData) FileHash() *lhash.LabeledHash {
|
|||
return fd.fileHash
|
||||
}
|
||||
|
||||
// Signature returns the signature, if present.
|
||||
func (fd *FileData) Signature() *jess.Letter {
|
||||
return fd.signature
|
||||
}
|
||||
|
||||
// VerificationError returns the error encountered during verification.
|
||||
func (fd *FileData) VerificationError() error {
|
||||
return fd.verificationError
|
||||
|
@ -75,7 +81,9 @@ func SignFileData(fileHash *lhash.LabeledHash, metaData map[string]string, envel
|
|||
// Any returned file data struct must be checked for an verification error.
|
||||
func VerifyFileData(letter *jess.Letter, requiredMetaData map[string]string, trustStore jess.TrustStore) (fd *FileData, err error) {
|
||||
// Parse data.
|
||||
fd = &FileData{}
|
||||
fd = &FileData{
|
||||
signature: letter,
|
||||
}
|
||||
_, err = dsd.Load(letter.Data, fd)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse file signature data: %w", err)
|
||||
|
|
Loading…
Add table
Reference in a new issue