Implement GetDeviceId for prov4

[ Merge of http://go/wvgerrit/150349 ]

The device id for prov4 is hash of the encoded device public key
(COSE_key).

Also replaced a few bug numbers if it is prov3 specific (not related to prov4).

Bug: 225216277
Bug: 236317198
Test: oemcrypto_test
Change-Id: Ica1c8579c0a3ef83c70f331283c9cce629c6bb3f
This commit is contained in:
Alex Dale
2022-06-21 16:16:14 -07:00
parent d874fffaec
commit 073f478239
2 changed files with 26 additions and 4 deletions

View File

@@ -1522,6 +1522,27 @@ TEST_F(OEMCryptoProv40Test, InstallOemPrivateKeyCanBeUsed) {
public_key_signature2.size(), kSign_RSASSA_PSS));
}
TEST_F(OEMCryptoProv40Test, GetDeviceId) {
OEMCryptoResult sts;
std::vector<uint8_t> dev_id;
size_t dev_id_len = dev_id.size();
sts = OEMCrypto_GetDeviceID(dev_id.data(), &dev_id_len);
if (sts == OEMCrypto_ERROR_SHORT_BUFFER) {
ASSERT_GT(dev_id_len, 0u);
dev_id.resize(dev_id_len);
sts = OEMCrypto_GetDeviceID(dev_id.data(), &dev_id_len);
}
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
dev_id.resize(dev_id_len);
cout << " NormalGetDeviceId: dev_id = " << MaybeHex(dev_id)
<< " len = " << dev_id_len << endl;
// Device id should be stable. Query again.
std::vector<uint8_t> dev_id2(dev_id_len);
sts = OEMCrypto_GetDeviceID(dev_id2.data(), &dev_id_len);
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
ASSERT_EQ(dev_id2, dev_id);
}
//
// AddKey Tests
//