Skip to content

Commit

Permalink
asserts: add accessor for serial-proof nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasb committed Aug 18, 2016
1 parent 531eabe commit b2be8d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions asserts/device_asserts.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ type SerialProof struct {
assertionBase
}

// Nonce returns the nonce obtained from store and to be presented when requesting a device session.
func (sproof *SerialProof) Nonce() string {
return sproof.HeaderString("nonce")
}

func assembleSerialProof(assert assertionBase) (Assertion, error) {
_, err := checkNotEmptyString(assert.headers, "nonce")
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions asserts/device_asserts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,14 @@ func (ss *serialSuite) TestSerialProofHappy(c *C) {
err = asserts.SignatureCheck(sproof2, ss.deviceKey.PublicKey())
c.Check(err, IsNil)

c.Check(sproof2.HeaderString("nonce"), Equals, "NONCE")
c.Check(sproof2.Nonce(), Equals, "NONCE")
}

func (ss *serialSuite) TestSerialProofDecodeInvalid(c *C) {
encoded := "type: serial-proof\n" +
"nonce: NONCE\n" +
"body-length: 2\n" +
"body-length: 0\n" +
"sign-key-sha3-384: " + ss.deviceKey.PublicKey().ID() + "\n\n" +
"HW" +
"\n\n" +
"AXNpZw=="

invalidTests := []struct{ original, invalid, expectedErr string }{
Expand Down

0 comments on commit b2be8d4

Please sign in to comment.