diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2017-09-14 07:42:50 +0200 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2017-09-26 21:35:41 +0200 |
commit | b2742dc28d1ff9001cd784455bbdf9cf29539c30 (patch) | |
tree | 2cac9dff572edbfc05588c33cce76a3dbb406d15 /objects/object_snapshot.go | |
parent | 9ddda1c317dbeaab1380e46ebf48eba9566a90e2 (diff) | |
download | petrific-b2742dc28d1ff9001cd784455bbdf9cf29539c30.tar.gz petrific-b2742dc28d1ff9001cd784455bbdf9cf29539c30.tar.bz2 petrific-b2742dc28d1ff9001cd784455bbdf9cf29539c30.zip |
Implement remaining subcommands
Diffstat (limited to 'objects/object_snapshot.go')
-rw-r--r-- | objects/object_snapshot.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/objects/object_snapshot.go b/objects/object_snapshot.go index 7edbc2a..e86484d 100644 --- a/objects/object_snapshot.go +++ b/objects/object_snapshot.go @@ -23,6 +23,7 @@ type Snapshot struct { Archive string Comment string Signed bool + raw []byte } func (s Snapshot) Type() ObjectType { @@ -62,6 +63,20 @@ func (s Snapshot) Payload() (out []byte) { return out } +type Verifyer interface { + Verify([]byte) error +} + +// Verify verifies that the snapshot has a valid signature. +// Only works with unserialized snapshots, i.e. a freshly created snapshot can not be verified. +func (s Snapshot) Verify(v Verifyer) error { + if !s.Signed { + return nil + } + + return v.Verify(s.raw) +} + type Signer interface { Sign([]byte) ([]byte, error) } @@ -73,6 +88,8 @@ func (s Snapshot) SignedPayload(signer Signer) ([]byte, error) { func (s *Snapshot) FromPayload(payload []byte) error { r := bytes.NewBuffer(payload) + s.raw = payload + seenArchive := false seenDate := false seenTree := false |