Files
android/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generate_signature.cc
Ian Benz 53fe55cb72 Clean up fuzz helper classes
- Remove OEMCrypto state changes hidden in constructors and destructors.
- Use composition instead of inheritance to structure classes.
- Avoid calling non-trivial destructors for objects with static
  lifetime.

Merged from https://widevine-internal-review.googlesource.com/168497
Merged from https://widevine-internal-review.googlesource.com/171170
Merged from https://widevine-internal-review.googlesource.com/171171
Merged from https://widevine-internal-review.googlesource.com/171870

Change-Id: I20476a7b1132d11f011b8650ec01e3c2dc3fc0e8
2024-01-26 13:40:22 -08:00

37 lines
996 B
C++

#include "oemcrypto_fuzz_helper.h"
#include "oemcrypto_session_tests_helper.h"
#include "properties.h"
static bool is_init = false;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
wvoec::SessionUtil session_helper;
if (!is_init) {
wvoec::RedirectStdoutToFile();
wvoec::global_features.Initialize();
wvoec::global_features.RestrictFilter("*");
wvutil::Properties::Init();
is_init = true;
}
OEMCrypto_Initialize();
OEMCrypto_EnterTestMode();
session_helper.EnsureTestROT();
wvoec::Session s;
s.open();
s.GenerateDerivedKeysFromKeybox(session_helper.keybox_);
static const uint32_t SignatureBufferMaxLength = size;
vector<uint8_t> signature(SignatureBufferMaxLength);
size_t signature_length = signature.size();
OEMCryptoResult sts;
sts = OEMCrypto_GenerateSignature(s.session_id(), data, size,
&signature[0], &signature_length);
s.close();
OEMCrypto_Terminate();
return 0;
}