diff --git a/keydata.go b/keydata.go index 41858faf..7ba339de 100644 --- a/keydata.go +++ b/keydata.go @@ -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 { diff --git a/keydata_test.go b/keydata_test.go index 466cf846..735f2ac4 100644 --- a/keydata_test.go +++ b/keydata_test.go @@ -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)