Skip to content

Commit

Permalink
Merge pull request #5 from safing/fix/compatibility-and-checks
Browse files Browse the repository at this point in the history
Fix compatibility and checks
  • Loading branch information
dhaavi authored Aug 6, 2020
2 parents 3aee348 + 72dae4b commit abf8e0b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (s *Session) Close(data []byte) (*Letter, error) { //nolint:gocognit
letter := &Letter{}

if s.wire == nil || s.wire.msgNo == 0 {
letter.Version = 1
letter.Version = s.envelope.Version
letter.SuiteID = s.envelope.SuiteID
}

Expand Down
1 change: 1 addition & 0 deletions envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func (e *Envelope) prepSignets(signets []*Signet, recipients bool, storage Trust
// keys are _always_ signets
if signet.Scheme == SignetSchemeKey {
recipients = false
// TODO: spills to next loop
}

// signet is referrer
Expand Down
6 changes: 6 additions & 0 deletions letter-wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ func (letter *Letter) ToWire() (*container.Container, error) {
return c, nil
}

// LetterFromWireData is a relay to LetterFromWire to quickly fix import issues of godep.
// DEPRECATED
func LetterFromWireData(data []byte) (*Letter, error) {
return LetterFromWire(container.New(data))
}

// LetterFromWire parses a letter sent over a network connection.
func LetterFromWire(c *container.Container) (*Letter, error) {
letter := &Letter{}
Expand Down
4 changes: 4 additions & 0 deletions lhash/labeledhash.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func Load(labeledHash []byte) (*LabeledHash, error) {
return nil, errors.New("compatibility error: invalid or unsupported algorithm")
}

if alg.new().Size() != len(digest) {
return nil, errors.New("integrity error: invalid digest length")
}

return &LabeledHash{
alg: alg,
digest: digest,
Expand Down

0 comments on commit abf8e0b

Please sign in to comment.