Add OEMCrypto_GenerateCertificateKeyPair second stage fuzzer
Merged from https://widevine-internal-review.googlesource.com/176771 Change-Id: I8afee6636a44f46a573be5a94f6c12161b57eace
This commit is contained in:
@@ -19,6 +19,38 @@ wvoec::OEMCryptoProvisioningAPIFuzz& provisioning_api_fuzz =
|
||||
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
|
||||
wvoec::RedirectStdoutToFile();
|
||||
provisioning_api_fuzz.Initialize();
|
||||
|
||||
#ifdef SECOND_STAGE
|
||||
|
||||
const uint32_t session_id = provisioning_api_fuzz.session().session_id();
|
||||
|
||||
size_t public_key_length = 0;
|
||||
size_t public_key_signature_length = 0;
|
||||
size_t wrapped_private_key_length = 0;
|
||||
OEMCrypto_PrivateKeyType key_type = OEMCrypto_RSA_Private_Key;
|
||||
OEMCryptoResult result = OEMCrypto_GenerateCertificateKeyPair(
|
||||
session_id, nullptr, &public_key_length, nullptr,
|
||||
&public_key_signature_length, nullptr, &wrapped_private_key_length,
|
||||
&key_type);
|
||||
wvoec::CheckStatusAndExitFuzzerOnFailure(result,
|
||||
OEMCrypto_ERROR_SHORT_BUFFER);
|
||||
|
||||
std::vector<uint8_t> public_key(public_key_length);
|
||||
std::vector<uint8_t> public_key_signature(public_key_signature_length);
|
||||
std::vector<uint8_t> wrapped_private_key(wrapped_private_key_length);
|
||||
result = OEMCrypto_GenerateCertificateKeyPair(
|
||||
session_id, public_key.data(), &public_key_length,
|
||||
public_key_signature.data(), &public_key_signature_length,
|
||||
wrapped_private_key.data(), &wrapped_private_key_length, &key_type);
|
||||
wvoec::CheckStatusAndExitFuzzerOnFailure(result, OEMCrypto_SUCCESS);
|
||||
|
||||
result = OEMCrypto_InstallOemPrivateKey(session_id, key_type,
|
||||
wrapped_private_key.data(),
|
||||
wrapped_private_key_length);
|
||||
wvoec::CheckStatusAndExitFuzzerOnFailure(result, OEMCrypto_SUCCESS);
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user