Updated crypto_session_fuzzer
Implemented google c++ code style changes for crypto_session_fuzzer exec/s: 136 Test: ./crypto_session_fuzzer Bug: 312374669 Change-Id: Ie490914858a35dfe0f8bfdd4a40f9be65d41b6bd
This commit is contained in:
committed by
Aditya Wazir
parent
d866ba45aa
commit
982bec196b
@@ -15,12 +15,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <fuzzer/FuzzedDataProvider.h>
|
||||||
|
|
||||||
#include "crypto_session.h"
|
#include "crypto_session.h"
|
||||||
#include "entitlement_key_session.h"
|
#include "entitlement_key_session.h"
|
||||||
#include "properties.h"
|
#include "properties.h"
|
||||||
#include "string_conversions.h"
|
#include "string_conversions.h"
|
||||||
#include "wv_cdm_constants.h"
|
#include "wv_cdm_constants.h"
|
||||||
#include <fuzzer/FuzzedDataProvider.h>
|
|
||||||
|
|
||||||
using namespace wvcdm;
|
using namespace wvcdm;
|
||||||
|
|
||||||
@@ -34,469 +35,469 @@ constexpr int32_t kDefaultSampleSize = 0;
|
|||||||
|
|
||||||
class CryptoSessionFuzzer {
|
class CryptoSessionFuzzer {
|
||||||
public:
|
public:
|
||||||
CryptoSessionFuzzer(const uint8_t* data, size_t size) : mFdp(data, size) {};
|
CryptoSessionFuzzer(const uint8_t* data, size_t size) : fdp_(data, size){};
|
||||||
void process();
|
void Process();
|
||||||
void FillDecryptParams(CdmDecryptionParametersV16& params);
|
void FillDecryptParams(CdmDecryptionParametersV16& params);
|
||||||
void SetKeyParams(CryptoKey& inputKey);
|
void SetKeyParams(CryptoKey& input_key);
|
||||||
void setUp(CryptoSession* cryptoSession, const std::string& keyId,
|
void SetUp(CryptoSession* crypto_session, const std::string& key_id,
|
||||||
std::string& message, std::string& signature,
|
std::string& message, std::string& signature,
|
||||||
std::string& coreMessage);
|
std::string& core_message);
|
||||||
void initializeStripeBuffer(std::vector<uint8_t>* buffer, size_t size);
|
void InitializeStripeBuffer(std::vector<uint8_t>* buffer, size_t size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FuzzedDataProvider mFdp;
|
FuzzedDataProvider fdp_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void CryptoSessionFuzzer::initializeStripeBuffer(std::vector<uint8_t>* buffer,
|
void CryptoSessionFuzzer::InitializeStripeBuffer(std::vector<uint8_t>* buffer,
|
||||||
size_t size) {
|
size_t size) {
|
||||||
buffer->assign(size, 0);
|
buffer->assign(size, 0);
|
||||||
for (size_t i = 0; i < size; ++i) {
|
for (size_t i = 0; i < size; ++i) {
|
||||||
(*buffer)[i] = mFdp.ConsumeIntegral<uint8_t>();
|
(*buffer)[i] = fdp_.ConsumeIntegral<uint8_t>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryptoSessionFuzzer::SetKeyParams(CryptoKey& inputKey) {
|
void CryptoSessionFuzzer::SetKeyParams(CryptoKey& input_key) {
|
||||||
inputKey.set_key_data(mFdp.ConsumeRandomLengthString(kStringLength));
|
input_key.set_key_data(fdp_.ConsumeRandomLengthString(kStringLength));
|
||||||
inputKey.set_key_data_iv(mFdp.ConsumeRandomLengthString(kStringLength));
|
input_key.set_key_data_iv(fdp_.ConsumeRandomLengthString(kStringLength));
|
||||||
inputKey.set_key_control(mFdp.ConsumeRandomLengthString(kStringLength));
|
input_key.set_key_control(fdp_.ConsumeRandomLengthString(kStringLength));
|
||||||
inputKey.set_key_control_iv(mFdp.ConsumeRandomLengthString(kStringLength));
|
input_key.set_key_control_iv(fdp_.ConsumeRandomLengthString(kStringLength));
|
||||||
inputKey.set_cipher_mode(mFdp.ConsumeBool() ? kCipherModeCbc
|
input_key.set_cipher_mode(fdp_.ConsumeBool() ? kCipherModeCbc
|
||||||
: kCipherModeCtr);
|
: kCipherModeCtr);
|
||||||
inputKey.set_track_label(mFdp.ConsumeRandomLengthString(kStringLength));
|
input_key.set_track_label(fdp_.ConsumeRandomLengthString(kStringLength));
|
||||||
inputKey.set_entitlement_key_id(
|
input_key.set_entitlement_key_id(
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength));
|
fdp_.ConsumeRandomLengthString(kStringLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryptoSessionFuzzer::FillDecryptParams(
|
void CryptoSessionFuzzer::FillDecryptParams(
|
||||||
CdmDecryptionParametersV16& params) {
|
CdmDecryptionParametersV16& params) {
|
||||||
params.cipher_mode = mFdp.ConsumeBool() ? kCipherModeCbc : kCipherModeCtr;
|
params.cipher_mode = fdp_.ConsumeBool() ? kCipherModeCbc : kCipherModeCtr;
|
||||||
params.observe_legacy_fields = mFdp.ConsumeBool();
|
params.observe_legacy_fields = fdp_.ConsumeBool();
|
||||||
uint32_t noOfSamples =
|
uint32_t no_of_samples =
|
||||||
mFdp.ConsumeIntegralInRange<uint32_t>(kMinSamplesCount, kMaxSamplesCount);
|
fdp_.ConsumeIntegralInRange<uint32_t>(kMinSamplesCount, kMaxSamplesCount);
|
||||||
|
|
||||||
while (--noOfSamples) {
|
while (--no_of_samples) {
|
||||||
size_t sampleSize = 0;
|
size_t sample_size = 0;
|
||||||
uint32_t noOfSubSamples = mFdp.ConsumeIntegralInRange<uint32_t>(
|
uint32_t no_of_sub_samples = fdp_.ConsumeIntegralInRange<uint32_t>(
|
||||||
kMinSamplesCount, kMaxSamplesCount);
|
kMinSamplesCount, kMaxSamplesCount);
|
||||||
std::vector<CdmDecryptionSubsample> subSampleVector;
|
std::vector<CdmDecryptionSubsample> sub_sample_vector;
|
||||||
while (--noOfSubSamples) {
|
while (--no_of_sub_samples) {
|
||||||
size_t clearBytes =
|
size_t clear_bytes =
|
||||||
mFdp.ConsumeIntegralInRange<size_t>(kMinByte, kMaxByte);
|
fdp_.ConsumeIntegralInRange<size_t>(kMinByte, kMaxByte);
|
||||||
size_t protectedBytes =
|
size_t protected_bytes =
|
||||||
mFdp.ConsumeIntegralInRange<size_t>(kMinByte, kMaxByte);
|
fdp_.ConsumeIntegralInRange<size_t>(kMinByte, kMaxByte);
|
||||||
CdmDecryptionSubsample subsample(clearBytes, protectedBytes);
|
CdmDecryptionSubsample sub_sample(clear_bytes, protected_bytes);
|
||||||
sampleSize += clearBytes + protectedBytes;
|
sample_size += clear_bytes + protected_bytes;
|
||||||
subSampleVector.push_back(subsample);
|
sub_sample_vector.push_back(sub_sample);
|
||||||
}
|
}
|
||||||
std::vector<uint8_t> iv;
|
std::vector<uint8_t> iv;
|
||||||
iv = mFdp.ConsumeBytes<uint8_t>(kIvSize);
|
iv = fdp_.ConsumeBytes<uint8_t>(kIvSize);
|
||||||
if (iv.size() != kIvSize) {
|
if (iv.size() != kIvSize) {
|
||||||
iv.resize(kIvSize, 0);
|
iv.resize(kIvSize, 0);
|
||||||
}
|
}
|
||||||
void* decryptBuffer;
|
void* decrypt_buffer;
|
||||||
std::vector<uint8_t> eBuffer;
|
std::vector<uint8_t> e_buffer;
|
||||||
for (int i = 0; i < sampleSize; ++i) {
|
for (int i = 0; i < sample_size; ++i) {
|
||||||
eBuffer.push_back(
|
e_buffer.push_back(
|
||||||
mFdp.ConsumeIntegralInRange<uint8_t>(kMinByte, kMaxByte));
|
fdp_.ConsumeIntegralInRange<uint8_t>(kMinByte, kMaxByte));
|
||||||
}
|
}
|
||||||
size_t decryptBufferOffset =
|
size_t decrypt_buffer_offset =
|
||||||
mFdp.ConsumeIntegralInRange<uint8_t>(kMinByte, kMaxByte);
|
fdp_.ConsumeIntegralInRange<uint8_t>(kMinByte, kMaxByte);
|
||||||
CdmDecryptionSample sample(eBuffer.data(), decryptBuffer,
|
CdmDecryptionSample sample(e_buffer.data(), decrypt_buffer,
|
||||||
decryptBufferOffset, sampleSize, iv);
|
decrypt_buffer_offset, sample_size, iv);
|
||||||
sample.subsamples = subSampleVector;
|
sample.subsamples = sub_sample_vector;
|
||||||
params.samples.push_back(sample);
|
params.samples.push_back(sample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryptoSessionFuzzer::setUp(CryptoSession* cryptoSession,
|
void CryptoSessionFuzzer::SetUp(CryptoSession* crypto_session,
|
||||||
const std::string& keyId, std::string& message,
|
const std::string& key_id, std::string& message,
|
||||||
std::string& signature,
|
std::string& signature,
|
||||||
std::string& coreMessage) {
|
std::string& core_message) {
|
||||||
bool shouldSpecifyAlgorithm;
|
bool should_specify_algorithm;
|
||||||
OEMCrypto_SignatureHashAlgorithm algorithm;
|
OEMCrypto_SignatureHashAlgorithm algorithm;
|
||||||
CdmLicenseKeyType keyType1 = kLicenseKeyTypeEntitlement;
|
CdmLicenseKeyType key_type_1 = kLicenseKeyTypeEntitlement;
|
||||||
cryptoSession->PrepareAndSignProvisioningRequest(
|
crypto_session->PrepareAndSignProvisioningRequest(
|
||||||
message, &coreMessage, &signature, shouldSpecifyAlgorithm, algorithm);
|
message, &core_message, &signature, should_specify_algorithm, algorithm);
|
||||||
cryptoSession->PrepareAndSignLicenseRequest(
|
crypto_session->PrepareAndSignLicenseRequest(
|
||||||
message, &coreMessage, &signature, shouldSpecifyAlgorithm, algorithm);
|
message, &core_message, &signature, should_specify_algorithm, algorithm);
|
||||||
cryptoSession->LoadLicense(message, coreMessage, signature, keyType1);
|
crypto_session->LoadLicense(message, core_message, signature, key_type_1);
|
||||||
|
|
||||||
CryptoKey inputKey;
|
CryptoKey input_key;
|
||||||
inputKey.set_key_id(keyId);
|
input_key.set_key_id(key_id);
|
||||||
CryptoSessionFuzzer::SetKeyParams(inputKey);
|
CryptoSessionFuzzer::SetKeyParams(input_key);
|
||||||
std::vector<CryptoKey> keys = { inputKey };
|
std::vector<CryptoKey> keys = {input_key};
|
||||||
cryptoSession->LoadEntitledContentKeys(keys);
|
crypto_session->LoadEntitledContentKeys(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryptoSessionFuzzer::process() {
|
void CryptoSessionFuzzer::Process() {
|
||||||
metrics::CryptoMetrics cryptoMetrics;
|
metrics::CryptoMetrics crypto_metrics;
|
||||||
std::unique_ptr<CryptoSession> cryptoSession(
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
CryptoSession::MakeCryptoSession(&cryptoMetrics));
|
CryptoSession::MakeCryptoSession(&crypto_metrics));
|
||||||
|
|
||||||
CdmLicenseKeyType keyType;
|
CdmLicenseKeyType key_type;
|
||||||
OEMCrypto_SignatureHashAlgorithm algorithm;
|
OEMCrypto_SignatureHashAlgorithm algorithm;
|
||||||
Properties::Init();
|
Properties::Init();
|
||||||
|
|
||||||
RequestedSecurityLevel requestedSecurityLevel =
|
RequestedSecurityLevel requested_security_level =
|
||||||
mFdp.ConsumeBool() ? kLevelDefault : kLevel3;
|
fdp_.ConsumeBool() ? kLevelDefault : kLevel3;
|
||||||
cryptoSession->Open(requestedSecurityLevel);
|
crypto_session->Open(requested_security_level);
|
||||||
|
|
||||||
while (mFdp.remaining_bytes()) {
|
while (fdp_.remaining_bytes()) {
|
||||||
auto invokeCryptoSessionAPI = mFdp.PickValueInArray<
|
auto invoke_crypto_session_API = fdp_.PickValueInArray<
|
||||||
const std::function<void()>>({
|
const std::function<void()>>({
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string token = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string token = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string additionalToken =
|
std::string additional_token =
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength);
|
fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
cryptoSession->GetProvisioningToken(
|
crypto_session->GetProvisioningToken(
|
||||||
mFdp.ConsumeBool() ? &token : nullptr,
|
fdp_.ConsumeBool() ? &token : nullptr,
|
||||||
mFdp.ConsumeBool() ? &additionalToken : nullptr);
|
fdp_.ConsumeBool() ? &additional_token : nullptr);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
cryptoSession->SetSystemId(
|
crypto_session->SetSystemId(
|
||||||
mFdp.ConsumeIntegral<uint32_t>() /*system_id*/);
|
fdp_.ConsumeIntegral<uint32_t>() /*system_id*/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string provisioningId;
|
std::string provisioning_id;
|
||||||
cryptoSession->GetProvisioningId(&provisioningId);
|
crypto_session->GetProvisioningId(&provisioning_id);
|
||||||
cryptoSession->GetExternalDeviceUniqueId(&provisioningId);
|
crypto_session->GetExternalDeviceUniqueId(&provisioning_id);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
cryptoSession->LoadLicense(
|
crypto_session->LoadLicense(
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*signed_message*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*signed_message*/,
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*coreMessage*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*core_message*/,
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*signature*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*signature*/,
|
||||||
keyType);
|
key_type);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string coreMessage =
|
std::string core_message =
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength);
|
fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string signature = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string signature = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
cryptoSession->PrepareAndSignRenewalRequest(
|
crypto_session->PrepareAndSignRenewalRequest(
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*message*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*message*/,
|
||||||
mFdp.ConsumeBool() ? &coreMessage : nullptr,
|
fdp_.ConsumeBool() ? &core_message : nullptr,
|
||||||
mFdp.ConsumeBool() ? &signature : nullptr);
|
fdp_.ConsumeBool() ? &signature : nullptr);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
cryptoSession->LoadRenewal(
|
crypto_session->LoadRenewal(
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*signed_message*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*signed_message*/,
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*coreMessage*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*core_message*/,
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*signature*/);
|
fdp_.ConsumeRandomLengthString(kStringLength) /*signature*/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
const std::string& message =
|
const std::string& message =
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength);
|
fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string coreMessage =
|
std::string core_message =
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength);
|
fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string signature = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string signature = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
OEMCrypto_SignatureHashAlgorithm algorithm;
|
OEMCrypto_SignatureHashAlgorithm algorithm;
|
||||||
bool shouldSpecifyAlgorithm = mFdp.ConsumeBool();
|
bool should_specify_algorithm = fdp_.ConsumeBool();
|
||||||
cryptoSession->PrepareAndSignProvisioningRequest(
|
crypto_session->PrepareAndSignProvisioningRequest(
|
||||||
message, mFdp.ConsumeBool() ? &coreMessage : nullptr,
|
message, fdp_.ConsumeBool() ? &core_message : nullptr,
|
||||||
mFdp.ConsumeBool() ? &signature : nullptr, shouldSpecifyAlgorithm,
|
fdp_.ConsumeBool() ? &signature : nullptr, should_specify_algorithm,
|
||||||
algorithm);
|
algorithm);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
const CryptoWrappedKey privateKey;
|
const CryptoWrappedKey private_key;
|
||||||
cryptoSession->LoadCertificatePrivateKey(privateKey);
|
crypto_session->LoadCertificatePrivateKey(private_key);
|
||||||
} else {
|
} else {
|
||||||
CryptoWrappedKey::Type type =
|
CryptoWrappedKey::Type type =
|
||||||
(CryptoWrappedKey::Type)mFdp.ConsumeIntegral<int32_t>();
|
(CryptoWrappedKey::Type)fdp_.ConsumeIntegral<int32_t>();
|
||||||
std::string key = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string key = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
const CryptoWrappedKey privateKey(type, key);
|
const CryptoWrappedKey private_key(type, key);
|
||||||
cryptoSession->LoadCertificatePrivateKey(privateKey);
|
crypto_session->LoadCertificatePrivateKey(private_key);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string publicKey;
|
std::string public_key;
|
||||||
std::string publicKeySignature;
|
std::string public_key_signature;
|
||||||
std::string wrappedPrivateKey;
|
std::string wrapped_private_key;
|
||||||
CryptoWrappedKey::Type keyType;
|
CryptoWrappedKey::Type key_type;
|
||||||
cryptoSession->GenerateCertificateKeyPair(
|
crypto_session->GenerateCertificateKeyPair(
|
||||||
&publicKey, &publicKeySignature, &wrappedPrivateKey, &keyType);
|
&public_key, &public_key_signature, &wrapped_private_key, &key_type);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
const CryptoWrappedKey privateKey;
|
const CryptoWrappedKey private_key;
|
||||||
cryptoSession->LoadOemCertificatePrivateKey(privateKey);
|
crypto_session->LoadOemCertificatePrivateKey(private_key);
|
||||||
} else {
|
} else {
|
||||||
CryptoWrappedKey::Type type =
|
CryptoWrappedKey::Type type =
|
||||||
(CryptoWrappedKey::Type)mFdp.ConsumeIntegral<int32_t>();
|
(CryptoWrappedKey::Type)fdp_.ConsumeIntegral<int32_t>();
|
||||||
std::string key = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string key = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
const CryptoWrappedKey privateKey(type, key);
|
const CryptoWrappedKey private_key(type, key);
|
||||||
cryptoSession->LoadOemCertificatePrivateKey(privateKey);
|
crypto_session->LoadOemCertificatePrivateKey(private_key);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
size_t out;
|
size_t out;
|
||||||
RequestedSecurityLevel security_level =
|
RequestedSecurityLevel security_level =
|
||||||
(RequestedSecurityLevel)mFdp.ConsumeIntegral<int32_t>();
|
(RequestedSecurityLevel)fdp_.ConsumeIntegral<int32_t>();
|
||||||
cryptoSession->GetNumberOfOpenSessions(security_level, &out);
|
crypto_session->GetNumberOfOpenSessions(security_level, &out);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string info = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string info = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
cryptoSession->GetBuildInformation(&info);
|
crypto_session->GetBuildInformation(&info);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
CdmWatermarkingSupport support =
|
CdmWatermarkingSupport support =
|
||||||
(CdmWatermarkingSupport)mFdp.ConsumeIntegral<int32_t>();
|
(CdmWatermarkingSupport)fdp_.ConsumeIntegral<int32_t>();
|
||||||
cryptoSession->GetWatermarkingSupport(&support);
|
crypto_session->GetWatermarkingSupport(&support);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
CdmProductionReadiness readiness =
|
CdmProductionReadiness readiness =
|
||||||
(CdmProductionReadiness)mFdp.ConsumeIntegral<int32_t>();
|
(CdmProductionReadiness)fdp_.ConsumeIntegral<int32_t>();
|
||||||
cryptoSession->GetProductionReadiness(&readiness);
|
crypto_session->GetProductionReadiness(&readiness);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
RequestedSecurityLevel security_level =
|
RequestedSecurityLevel security_level =
|
||||||
(RequestedSecurityLevel)mFdp.ConsumeIntegral<int32_t>();
|
(RequestedSecurityLevel)fdp_.ConsumeIntegral<int32_t>();
|
||||||
size_t number_of_entries = mFdp.ConsumeIntegral<size_t>();
|
size_t number_of_entries = fdp_.ConsumeIntegral<size_t>();
|
||||||
cryptoSession->GetMaximumUsageTableEntries(security_level,
|
crypto_session->GetMaximumUsageTableEntries(security_level,
|
||||||
&number_of_entries);
|
&number_of_entries);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
RequestedSecurityLevel security_level =
|
RequestedSecurityLevel security_level =
|
||||||
(RequestedSecurityLevel)mFdp.ConsumeIntegral<int32_t>();
|
(RequestedSecurityLevel)fdp_.ConsumeIntegral<int32_t>();
|
||||||
uint32_t decrypt_hash_support = mFdp.ConsumeIntegral<uint32_t>();
|
uint32_t decrypt_hash_support = fdp_.ConsumeIntegral<uint32_t>();
|
||||||
cryptoSession->GetDecryptHashSupport(security_level,
|
crypto_session->GetDecryptHashSupport(security_level,
|
||||||
&decrypt_hash_support);
|
&decrypt_hash_support);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
bool hasSupport = mFdp.ConsumeBool();
|
bool has_support = fdp_.ConsumeBool();
|
||||||
cryptoSession->HasUsageTableSupport(&hasSupport);
|
crypto_session->HasUsageTableSupport(&has_support);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
cryptoSession->DeactivateUsageInformation(
|
crypto_session->DeactivateUsageInformation(
|
||||||
mFdp.ConsumeRandomLengthString(
|
fdp_.ConsumeRandomLengthString(
|
||||||
kStringLength) /*provider_session_token*/);
|
kStringLength) /*provider_session_token*/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string usageReport =
|
std::string usage_report =
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength);
|
fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
CryptoSession::UsageDurationStatus usageDurationStatus;
|
CryptoSession::UsageDurationStatus usage_duration_status;
|
||||||
int64_t secondsSinceStarted = mFdp.ConsumeIntegral<int64_t>();
|
int64_t seconds_since_started = fdp_.ConsumeIntegral<int64_t>();
|
||||||
int64_t secondsSinceLastPlayed = mFdp.ConsumeIntegral<int64_t>();
|
int64_t seconds_since_last_played = fdp_.ConsumeIntegral<int64_t>();
|
||||||
cryptoSession->GenerateUsageReport(
|
crypto_session->GenerateUsageReport(
|
||||||
mFdp.ConsumeRandomLengthString(
|
fdp_.ConsumeRandomLengthString(
|
||||||
kStringLength) /*provider_session_token*/,
|
kStringLength) /*provider_session_token*/,
|
||||||
&usageReport, &usageDurationStatus, &secondsSinceStarted,
|
&usage_report, &usage_duration_status, &seconds_since_started,
|
||||||
&secondsSinceLastPlayed);
|
&seconds_since_last_played);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
uint32_t nonce = mFdp.ConsumeIntegral<uint32_t>();
|
uint32_t nonce = fdp_.ConsumeIntegral<uint32_t>();
|
||||||
cryptoSession->GenerateNonce(&nonce);
|
crypto_session->GenerateNonce(&nonce);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string signedMessage, coreMessage, signature;
|
std::string signed_message, core_message, signature;
|
||||||
std::string wrappedPrivateKey;
|
std::string wrapped_private_key;
|
||||||
cryptoSession->LoadProvisioning(
|
crypto_session->LoadProvisioning(
|
||||||
signedMessage, coreMessage, signature,
|
signed_message, core_message, signature,
|
||||||
mFdp.ConsumeBool() ? &wrappedPrivateKey : nullptr);
|
fdp_.ConsumeBool() ? &wrapped_private_key : nullptr);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
cryptoSession->SetDecryptHash(
|
crypto_session->SetDecryptHash(
|
||||||
mFdp.ConsumeIntegral<int16_t>() /*frame_number*/,
|
fdp_.ConsumeIntegral<int16_t>() /*frame_number*/,
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*hash*/);
|
fdp_.ConsumeRandomLengthString(kStringLength) /*hash*/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
CdmEncryptionAlgorithm algorithm;
|
CdmEncryptionAlgorithm algorithm;
|
||||||
std::string outBuffer;
|
std::string out_buffer;
|
||||||
cryptoSession->GenericDecrypt(
|
crypto_session->GenericDecrypt(
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*in_buffer*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*in_buffer*/,
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*key_id*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*key_id*/,
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*iv*/, algorithm,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*iv*/, algorithm,
|
||||||
&outBuffer);
|
&out_buffer);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
CdmSigningAlgorithm algorithm = mFdp.ConsumeBool()
|
CdmSigningAlgorithm algorithm = fdp_.ConsumeBool()
|
||||||
? kSigningAlgorithmHmacSha256
|
? kSigningAlgorithmHmacSha256
|
||||||
: kSigningAlgorithmUnknown;
|
: kSigningAlgorithmUnknown;
|
||||||
std::string signature;
|
std::string signature;
|
||||||
cryptoSession->GenericSign(
|
crypto_session->GenericSign(
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*message*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*message*/,
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*key_id*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*key_id*/,
|
||||||
algorithm, &signature);
|
algorithm, &signature);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
CdmSigningAlgorithm algorithm = kSigningAlgorithmHmacSha256;
|
CdmSigningAlgorithm algorithm = kSigningAlgorithmHmacSha256;
|
||||||
const std::string signature;
|
const std::string signature;
|
||||||
cryptoSession->GenericVerify(
|
crypto_session->GenericVerify(
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*message*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*message*/,
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*key_id*/,
|
fdp_.ConsumeRandomLengthString(kStringLength) /*key_id*/,
|
||||||
algorithm, signature);
|
algorithm, signature);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
UsageTableHeader usageTableHeader;
|
UsageTableHeader usage_table_header;
|
||||||
cryptoSession->CreateUsageTableHeader(requestedSecurityLevel,
|
crypto_session->CreateUsageTableHeader(requested_security_level,
|
||||||
&usageTableHeader);
|
&usage_table_header);
|
||||||
|
|
||||||
cryptoSession->LoadUsageTableHeader(requestedSecurityLevel,
|
crypto_session->LoadUsageTableHeader(requested_security_level,
|
||||||
usageTableHeader);
|
usage_table_header);
|
||||||
uint32_t newEntryCount;
|
uint32_t new_entry_count;
|
||||||
cryptoSession->ShrinkUsageTableHeader(
|
crypto_session->ShrinkUsageTableHeader(
|
||||||
requestedSecurityLevel, newEntryCount, &usageTableHeader);
|
requested_security_level, new_entry_count, &usage_table_header);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
const UsageTableHeader usageTableHeader;
|
const UsageTableHeader usage_table_header;
|
||||||
cryptoSession->LoadUsageTableHeader(requestedSecurityLevel,
|
crypto_session->LoadUsageTableHeader(requested_security_level,
|
||||||
usageTableHeader);
|
usage_table_header);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
uint32_t entryNumber;
|
uint32_t entry_number;
|
||||||
cryptoSession->CreateUsageEntry(&entryNumber);
|
crypto_session->CreateUsageEntry(&entry_number);
|
||||||
cryptoSession->MoveUsageEntry(entryNumber);
|
crypto_session->MoveUsageEntry(entry_number);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
const UsageEntry usageEntry;
|
const UsageEntry usage_entry;
|
||||||
cryptoSession->LoadUsageEntry(
|
crypto_session->LoadUsageEntry(
|
||||||
mFdp.ConsumeIntegral<uint32_t>() /*entry_number*/, usageEntry);
|
fdp_.ConsumeIntegral<uint32_t>() /*entry_number*/, usage_entry);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
UsageTableHeader usageTableHeader;
|
UsageTableHeader usage_table_header;
|
||||||
UsageEntry usageEntry;
|
UsageEntry usage_entry;
|
||||||
cryptoSession->UpdateUsageEntry(&usageTableHeader, &usageEntry);
|
crypto_session->UpdateUsageEntry(&usage_table_header, &usage_entry);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
bool canSupportOutput = mFdp.ConsumeBool();
|
bool can_support_output = fdp_.ConsumeBool();
|
||||||
bool canDisableOutput = mFdp.ConsumeBool();
|
bool can_disable_output = fdp_.ConsumeBool();
|
||||||
bool canSupportCgmsA = mFdp.ConsumeBool();
|
bool can_support_cgmsa = fdp_.ConsumeBool();
|
||||||
cryptoSession->GetAnalogOutputCapabilities(
|
crypto_session->GetAnalogOutputCapabilities(
|
||||||
&canSupportOutput, &canDisableOutput, &canSupportCgmsA);
|
&can_support_output, &can_disable_output, &can_support_cgmsa);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
cryptoSession->SetDebugIgnoreKeyboxCount(
|
crypto_session->SetDebugIgnoreKeyboxCount(
|
||||||
mFdp.ConsumeIntegral<uint32_t>() /*count*/);
|
fdp_.ConsumeIntegral<uint32_t>() /*count*/);
|
||||||
},
|
},
|
||||||
[&]() { cryptoSession->GetOkpFallbackPolicy(); },
|
[&]() { crypto_session->GetOkpFallbackPolicy(); },
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string request = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string request = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
cryptoSession->PrepareOtaProvisioningRequest(
|
crypto_session->PrepareOtaProvisioningRequest(
|
||||||
mFdp.ConsumeBool() /*use_test_key*/, &request);
|
fdp_.ConsumeBool() /*use_test_key*/, &request);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
cryptoSession->LoadOtaProvisioning(
|
crypto_session->LoadOtaProvisioning(
|
||||||
mFdp.ConsumeBool() /*use_test_key*/,
|
fdp_.ConsumeBool() /*use_test_key*/,
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*response*/);
|
fdp_.ConsumeRandomLengthString(kStringLength) /*response*/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
uint32_t tier = mFdp.ConsumeIntegral<uint32_t>();
|
uint32_t tier = fdp_.ConsumeIntegral<uint32_t>();
|
||||||
cryptoSession->GetResourceRatingTier(&tier);
|
crypto_session->GetResourceRatingTier(&tier);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
size_t max;
|
size_t max;
|
||||||
cryptoSession->GetMaxNumberOfSessions(requestedSecurityLevel, &max);
|
crypto_session->GetMaxNumberOfSessions(requested_security_level, &max);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string keyData = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string key_data = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
cryptoSession->GetTokenFromKeybox(requestedSecurityLevel, &keyData);
|
crypto_session->GetTokenFromKeybox(requested_security_level, &key_data);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string bcc = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string bcc = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string additionalSignature =
|
std::string additional_signature =
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength);
|
fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
cryptoSession->GetBootCertificateChain(&bcc, &additionalSignature);
|
crypto_session->GetBootCertificateChain(&bcc, &additional_signature);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
cryptoSession->GenerateDerivedKeys(
|
crypto_session->GenerateDerivedKeys(
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength) /*message*/);
|
fdp_.ConsumeRandomLengthString(kStringLength) /*message*/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
CdmDecryptionParametersV16 params2;
|
CdmDecryptionParametersV16 params_2;
|
||||||
cryptoSession->Decrypt(params2);
|
crypto_session->Decrypt(params_2);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
const std::string& message =
|
const std::string& message =
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength);
|
fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string coreMessage, signature;
|
std::string core_message, signature;
|
||||||
bool shouldSpecifyAlgorithm;
|
bool should_specify_algorithm;
|
||||||
OEMCrypto_SignatureHashAlgorithm algorithm;
|
OEMCrypto_SignatureHashAlgorithm algorithm;
|
||||||
|
|
||||||
cryptoSession->PrepareAndSignProvisioningRequest(
|
crypto_session->PrepareAndSignProvisioningRequest(
|
||||||
message, &coreMessage, &signature, shouldSpecifyAlgorithm,
|
message, &core_message, &signature, should_specify_algorithm,
|
||||||
algorithm);
|
algorithm);
|
||||||
cryptoSession->PrepareAndSignLicenseRequest(
|
crypto_session->PrepareAndSignLicenseRequest(
|
||||||
message, &coreMessage, &signature, shouldSpecifyAlgorithm,
|
message, &core_message, &signature, should_specify_algorithm,
|
||||||
algorithm);
|
algorithm);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string keyId = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string key_id = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string message = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string message = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string signature, coreMessage;
|
std::string signature, core_message;
|
||||||
setUp(cryptoSession.get(), keyId, message, signature, coreMessage);
|
SetUp(crypto_session.get(), key_id, message, signature, core_message);
|
||||||
|
|
||||||
std::vector<uint8_t> inVector;
|
std::vector<uint8_t> in_vector;
|
||||||
std::vector<uint8_t> ivVector;
|
std::vector<uint8_t> iv_vector;
|
||||||
std::string inBuffer;
|
std::string in_buffer;
|
||||||
std::string iv;
|
std::string iv;
|
||||||
CdmEncryptionAlgorithm algorithmEncrypt =
|
CdmEncryptionAlgorithm algorithm_encrypt =
|
||||||
kEncryptionAlgorithmAesCbc128;
|
kEncryptionAlgorithmAesCbc128;
|
||||||
std::string outBuffer;
|
std::string out_buffer;
|
||||||
initializeStripeBuffer(&inVector, CONTENT_KEY_SIZE * 15);
|
InitializeStripeBuffer(&in_vector, CONTENT_KEY_SIZE * 15);
|
||||||
inBuffer = std::string(inVector.begin(), inVector.end());
|
in_buffer = std::string(in_vector.begin(), in_vector.end());
|
||||||
initializeStripeBuffer(&ivVector, KEY_IV_SIZE);
|
InitializeStripeBuffer(&iv_vector, KEY_IV_SIZE);
|
||||||
iv = std::string(ivVector.begin(), ivVector.end());
|
iv = std::string(iv_vector.begin(), iv_vector.end());
|
||||||
|
|
||||||
cryptoSession->GenericEncrypt(inBuffer, keyId, iv, algorithmEncrypt,
|
crypto_session->GenericEncrypt(in_buffer, key_id, iv, algorithm_encrypt,
|
||||||
&outBuffer);
|
&out_buffer);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string keyId = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string key_id = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string message = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string message = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string signature, coreMessage;
|
std::string signature, core_message;
|
||||||
setUp(cryptoSession.get(), keyId, message, signature, coreMessage);
|
SetUp(crypto_session.get(), key_id, message, signature, core_message);
|
||||||
|
|
||||||
std::vector<uint8_t> inVector;
|
std::vector<uint8_t> in_vector;
|
||||||
std::vector<uint8_t> ivVector;
|
std::vector<uint8_t> iv_vector;
|
||||||
std::string inBuffer;
|
std::string in_buffer;
|
||||||
std::string iv;
|
std::string iv;
|
||||||
CdmEncryptionAlgorithm algorithmEncrypt =
|
CdmEncryptionAlgorithm algorithm_encrypt =
|
||||||
kEncryptionAlgorithmAesCbc128;
|
kEncryptionAlgorithmAesCbc128;
|
||||||
std::string outBuffer;
|
std::string out_buffer;
|
||||||
initializeStripeBuffer(&inVector, CONTENT_KEY_SIZE * 15);
|
InitializeStripeBuffer(&in_vector, CONTENT_KEY_SIZE * 15);
|
||||||
inBuffer = std::string(inVector.begin(), inVector.end());
|
in_buffer = std::string(in_vector.begin(), in_vector.end());
|
||||||
initializeStripeBuffer(&ivVector, KEY_IV_SIZE);
|
InitializeStripeBuffer(&iv_vector, KEY_IV_SIZE);
|
||||||
iv = std::string(ivVector.begin(), ivVector.end());
|
iv = std::string(iv_vector.begin(), iv_vector.end());
|
||||||
|
|
||||||
cryptoSession->GenericDecrypt(inBuffer, keyId, iv, algorithmEncrypt,
|
crypto_session->GenericDecrypt(in_buffer, key_id, iv, algorithm_encrypt,
|
||||||
&outBuffer);
|
&out_buffer);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string keyId = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string key_id = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string message = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string message = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string signature, coreMessage;
|
std::string signature, core_message;
|
||||||
setUp(cryptoSession.get(), keyId, message, signature, coreMessage);
|
SetUp(crypto_session.get(), key_id, message, signature, core_message);
|
||||||
|
|
||||||
CdmSigningAlgorithm algorithm2 = kSigningAlgorithmHmacSha256;
|
CdmSigningAlgorithm algorithm_2 = kSigningAlgorithmHmacSha256;
|
||||||
cryptoSession->GenericSign(message, keyId, algorithm2, &signature);
|
crypto_session->GenericSign(message, key_id, algorithm_2, &signature);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
std::string keyId = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string key_id = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string message = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string message = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string signature, coreMessage;
|
std::string signature, core_message;
|
||||||
setUp(cryptoSession.get(), keyId, message, signature, coreMessage);
|
SetUp(crypto_session.get(), key_id, message, signature, core_message);
|
||||||
|
|
||||||
CdmSigningAlgorithm algorithm2 = kSigningAlgorithmHmacSha256;
|
CdmSigningAlgorithm algorithm_2 = kSigningAlgorithmHmacSha256;
|
||||||
cryptoSession->GenericVerify(message, keyId, algorithm2, signature);
|
crypto_session->GenericVerify(message, key_id, algorithm_2, signature);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
const std::string keyId =
|
const std::string key_id =
|
||||||
mFdp.ConsumeRandomLengthString(kStringLength);
|
fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string message = mFdp.ConsumeRandomLengthString(kStringLength);
|
std::string message = fdp_.ConsumeRandomLengthString(kStringLength);
|
||||||
std::string signature, coreMessage;
|
std::string signature, core_message;
|
||||||
setUp(cryptoSession.get(), keyId, message, signature, coreMessage);
|
SetUp(crypto_session.get(), key_id, message, signature, core_message);
|
||||||
CdmDecryptionParametersV16 params(keyId);
|
CdmDecryptionParametersV16 params(key_id);
|
||||||
CryptoSessionFuzzer::FillDecryptParams(params);
|
CryptoSessionFuzzer::FillDecryptParams(params);
|
||||||
cryptoSession->Decrypt(params);
|
crypto_session->Decrypt(params);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
invokeCryptoSessionAPI();
|
invoke_crypto_session_API();
|
||||||
}
|
}
|
||||||
cryptoSession->Close();
|
crypto_session->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
CryptoSessionFuzzer cryptoSessionFuzzer(data, size);
|
CryptoSessionFuzzer crypto_session_fuzzer(data, size);
|
||||||
cryptoSessionFuzzer.process();
|
crypto_session_fuzzer.Process();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user