Skip to content

Commit

Permalink
Save signature to file data for access outside helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Jul 11, 2022
1 parent c346404 commit 4556eda
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion filesig/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type FileData struct {
SignedAt time.Time
MetaData map[string]string

signature *jess.Letter
verificationError error
}

Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4556eda

Please sign in to comment.