Skip to content

Commit

Permalink
Merge pull request #281 from chrisccoulson/add-keydata-platform-accessor
Browse files Browse the repository at this point in the history
keydata: add PlatformName accessor
  • Loading branch information
chrisccoulson authored Feb 1, 2024
2 parents 10c645d + 61da803 commit 3f5e143
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions keydata.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,11 @@ func (d *KeyData) openWithPassphrase(passphrase string, kdf KDF) (payload []byte
return payload, key, nil
}

// PlatformName returns the name of the platform that handles this key data.
func (d *KeyData) PlatformName() string {
return d.data.PlatformName
}

// ReadableName returns a human-readable name for this key data, useful for
// including in errors.
func (d *KeyData) ReadableName() string {
Expand Down
8 changes: 8 additions & 0 deletions keydata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,14 @@ func (s *keyDataSuite) TestNewKeyData(c *C) {
c.Check(err, IsNil)
}

func (s *keyDataSuite) TestKeyDataPlatformName(c *C) {
key, auxKey := s.newKeyDataKeys(c, 32, 32)
protected := s.mockProtectKeys(c, key, auxKey, crypto.SHA256)
keyData, err := NewKeyData(protected)
c.Assert(err, IsNil)
c.Check(keyData.PlatformName(), Equals, mockPlatformName)
}

func (s *keyDataSuite) TestUnmarshalPlatformHandle(c *C) {
key, auxKey := s.newKeyDataKeys(c, 32, 32)
protected := s.mockProtectKeys(c, key, auxKey, crypto.SHA256)
Expand Down

0 comments on commit 3f5e143

Please sign in to comment.