From 4556eda901844ff4ef3e9b130e01f241210a3eb2 Mon Sep 17 00:00:00 2001 From: Daniel <dhaavi@users.noreply.github.com> Date: Mon, 11 Jul 2022 17:03:12 +0200 Subject: [PATCH] Save signature to file data for access outside helper functions --- filesig/main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/filesig/main.go b/filesig/main.go index 708b007..b4f54ba 100644 --- a/filesig/main.go +++ b/filesig/main.go @@ -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)