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:
@@ -3094,10 +3094,11 @@ OEMCryptoResult OEMCrypto_IsKeyboxOrOEMCertValid(void);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a device unique id. For devices with a keybox, retrieve the
|
* Return a device unique id. For devices with a keybox, retrieve the
|
||||||
* DeviceID from the Keybox. For devices that have an OEM Certificate instead
|
* DeviceID from the Keybox. For devices that have an OEM Certificate, or if
|
||||||
* of a keybox, it should set the device ID to a device-unique string, such
|
* provisioning 4 is used, it should set the device ID to a device-unique
|
||||||
* as the device serial number. The ID should be device-unique and it should
|
* string, such as the device serial number or a hash of the device public key
|
||||||
* be stable -- i.e. it should not change across a device reboot or a system
|
* in boot certificate chain. The ID should be device-unique and it should be
|
||||||
|
* stable -- i.e. it should not change across a device reboot or a system
|
||||||
* upgrade. This shall match the device id found in the core provisioning
|
* upgrade. This shall match the device id found in the core provisioning
|
||||||
* request message. The maximum length of the device id is 64 bytes. The
|
* request message. The maximum length of the device id is 64 bytes. The
|
||||||
* device ID field in a keybox is 32 bytes.
|
* device ID field in a keybox is 32 bytes.
|
||||||
|
|||||||
@@ -1522,6 +1522,27 @@ TEST_F(OEMCryptoProv40Test, InstallOemPrivateKeyCanBeUsed) {
|
|||||||
public_key_signature2.size(), kSign_RSASSA_PSS));
|
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
|
// AddKey Tests
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user