OEMCrypto_GetDeviceID should return Not Implemented for Prov 3.0
Merge from Widevine repo of http://go/wvgerrit/22402 This CL updates the oemcrypto reference implementation (mock) to return OEMCrypto_ERROR_NOT_IMPLEMENTED from OEMCrypto_GetDeviceID when the device is configured to use provisioning 3.0. This CL also moves unit test for OEMCrypto_GetDeviceID to the section that is run only for keybox using devices. b/33178932 Change-Id: Ie4f9346132ce305bdbd47474dc4c0f6268f3d444
This commit is contained in:
@@ -796,6 +796,9 @@ OEMCryptoResult OEMCrypto_GetDeviceID(uint8_t* deviceID,
|
||||
LOGE("OEMCrypto_GetDeviceID: OEMCrypto Not Initialized.");
|
||||
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
|
||||
}
|
||||
if (!crypto_engine->supports_keybox()) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
// Devices that do not support a keybox should use some other method to
|
||||
// store the device id.
|
||||
std::vector<uint8_t> dev_id_string = crypto_engine->keybox().device_id();
|
||||
|
||||
@@ -142,37 +142,6 @@ TEST_F(OEMCryptoClientTest, CheckMaxNumberOfSessionsAPI10) {
|
||||
printf(" Max Number of Sessions: %zu.\n", maximum);
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoClientTest, NormalGetDeviceId) {
|
||||
OEMCryptoResult sts;
|
||||
uint8_t dev_id[128] = {0};
|
||||
size_t dev_id_len = 128;
|
||||
sts = OEMCrypto_GetDeviceID(dev_id, &dev_id_len);
|
||||
cout << " NormalGetDeviceId: dev_id = " << dev_id
|
||||
<< " len = " << dev_id_len << endl;
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoClientTest, GetDeviceIdShortBuffer) {
|
||||
OEMCryptoResult sts;
|
||||
uint8_t dev_id[128];
|
||||
uint32_t req_len = 0;
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
dev_id[i] = 0x55;
|
||||
}
|
||||
dev_id[127] = '\0';
|
||||
size_t dev_id_len = req_len;
|
||||
sts = OEMCrypto_GetDeviceID(dev_id, &dev_id_len);
|
||||
ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, sts);
|
||||
// On short buffer error, function should return minimum buffer length
|
||||
ASSERT_TRUE(dev_id_len > req_len);
|
||||
// Should also return short buffer if passed a zero length and a null buffer.
|
||||
dev_id_len = req_len;
|
||||
sts = OEMCrypto_GetDeviceID(NULL, &dev_id_len);
|
||||
ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, sts);
|
||||
// On short buffer error, function should return minimum buffer length
|
||||
ASSERT_TRUE(dev_id_len > req_len);
|
||||
}
|
||||
|
||||
//
|
||||
// initialization tests
|
||||
//
|
||||
@@ -435,6 +404,37 @@ TEST_F(OEMCryptoClientTest, CanLoadTestKeys) {
|
||||
|
||||
class OEMCryptoKeyboxTest : public OEMCryptoClientTest {};
|
||||
|
||||
TEST_F(OEMCryptoKeyboxTest, NormalGetDeviceId) {
|
||||
OEMCryptoResult sts;
|
||||
uint8_t dev_id[128] = {0};
|
||||
size_t dev_id_len = 128;
|
||||
sts = OEMCrypto_GetDeviceID(dev_id, &dev_id_len);
|
||||
cout << " NormalGetDeviceId: dev_id = " << dev_id
|
||||
<< " len = " << dev_id_len << endl;
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoKeyboxTest, GetDeviceIdShortBuffer) {
|
||||
OEMCryptoResult sts;
|
||||
uint8_t dev_id[128];
|
||||
uint32_t req_len = 0;
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
dev_id[i] = 0x55;
|
||||
}
|
||||
dev_id[127] = '\0';
|
||||
size_t dev_id_len = req_len;
|
||||
sts = OEMCrypto_GetDeviceID(dev_id, &dev_id_len);
|
||||
ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, sts);
|
||||
// On short buffer error, function should return minimum buffer length
|
||||
ASSERT_TRUE(dev_id_len > req_len);
|
||||
// Should also return short buffer if passed a zero length and a null buffer.
|
||||
dev_id_len = req_len;
|
||||
sts = OEMCrypto_GetDeviceID(NULL, &dev_id_len);
|
||||
ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, sts);
|
||||
// On short buffer error, function should return minimum buffer length
|
||||
ASSERT_TRUE(dev_id_len > req_len);
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoKeyboxTest, NormalGetKeyData) {
|
||||
OEMCryptoResult sts;
|
||||
uint8_t key_data[256];
|
||||
|
||||
Reference in New Issue
Block a user