OEMCrypto_GetRandom should only be called after init

Merge from master branch of Widevine repo of http://go/wvgerrit/66079
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/65662

This CL forces OEMCrypto_Initialize to be called before OEMCrypto_GetRandom is
called in the reference code.

Bug: 34847139
Test: tested as part of http://go/ag/5501993
Change-Id: Ibb94e2fdc11cdb43c2c7bd2a3379f87b0155479a
This commit is contained in:
Fred Gylys-Colwell
2018-11-12 14:20:55 -08:00
parent 4fa255ea51
commit 4ffacfdcc7

View File

@@ -731,6 +731,10 @@ extern "C" OEMCryptoResult OEMCrypto_GetKeyData(uint8_t* keyData,
extern "C" OEMCryptoResult OEMCrypto_GetRandom(uint8_t* randomData,
size_t dataLength) {
if (!crypto_engine) {
LOGE("OEMCrypto_GetRandom: OEMCrypto Not Initialized.");
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
}
if (!randomData) {
return OEMCrypto_ERROR_UNKNOWN_FAILURE;
}