diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generate_certificate_key_pair_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generate_certificate_key_pair_fuzz.cc index cff4bd23..f66353a7 100644 --- a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generate_certificate_key_pair_fuzz.cc +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generate_certificate_key_pair_fuzz.cc @@ -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 public_key(public_key_length); + std::vector public_key_signature(public_key_signature_length); + std::vector 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; }