Updated service_certificate_fuzzer
Implemented google c++ code style changes for service_certificate_fuzzer exec/s: 4511 Test: ./service_certificate_fuzzer Bug: 312374669 Change-Id: I5858fa10a84508d1cfdfce4d0933cbdb97a0ab75
This commit is contained in:
committed by
Aditya Wazir
parent
2b3de00a36
commit
98fd5501b3
@@ -15,14 +15,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <crypto_session.h>
|
||||
#include <log.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "service_certificate.h"
|
||||
#include "vendor_widevine_fuzz_helper.h"
|
||||
#include "wv_cdm_event_listener.h"
|
||||
#include "wv_cdm_types.h"
|
||||
#include <crypto_session.h>
|
||||
#include <log.h>
|
||||
#include <memory>
|
||||
#include <utils/Log.h>
|
||||
|
||||
using namespace wvcdm;
|
||||
using namespace video_widevine;
|
||||
@@ -34,60 +36,60 @@ static constexpr int32_t kMaxByte = 256;
|
||||
class ServiceCertificateFuzzer {
|
||||
public:
|
||||
ServiceCertificateFuzzer(const uint8_t *data, size_t size)
|
||||
: mFdp(data, size){};
|
||||
void process();
|
||||
: fdp_(data, size){};
|
||||
void Process();
|
||||
|
||||
private:
|
||||
FuzzedDataProvider mFdp;
|
||||
FuzzedDataProvider fdp_;
|
||||
};
|
||||
|
||||
void ServiceCertificateFuzzer::process() {
|
||||
EncryptedClientIdentification encryptedClientId;
|
||||
ClientIdentification clearClientId;
|
||||
ServiceCertificate serviceCertificate;
|
||||
while (mFdp.remaining_bytes()) {
|
||||
auto invokeServiceCertificateAPI =
|
||||
mFdp.PickValueInArray<const std::function<void()>>({
|
||||
void ServiceCertificateFuzzer::Process() {
|
||||
EncryptedClientIdentification encrypted_client_id;
|
||||
ClientIdentification clear_client_id;
|
||||
ServiceCertificate service_certificate;
|
||||
while (fdp_.remaining_bytes()) {
|
||||
auto invoke_service_certificate_API =
|
||||
fdp_.PickValueInArray<const std::function<void()>>({
|
||||
[&]() {
|
||||
FuzzCdmClientPropertySet propertySet(&mFdp);
|
||||
propertySet.enable_privacy_mode();
|
||||
propertySet.set_service_certificate(kTestSignedCertificate);
|
||||
FuzzCdmClientPropertySet property_set(&fdp_);
|
||||
property_set.enable_privacy_mode();
|
||||
property_set.set_service_certificate(kTestSignedCertificate);
|
||||
PropertiesTestPeer::ForceReinit();
|
||||
PropertiesTestPeer::AddSessionPropertySet(
|
||||
mFdp.ConsumeBool() ? kTestSessionId1
|
||||
: mFdp.ConsumeRandomLengthString(kMaxByte),
|
||||
&propertySet);
|
||||
std::string rawServiceCertificate;
|
||||
fdp_.ConsumeBool() ? kTestSessionId1
|
||||
: fdp_.ConsumeRandomLengthString(kMaxByte),
|
||||
&property_set);
|
||||
std::string raw_service_certificate;
|
||||
PropertiesTestPeer::GetServiceCertificate(
|
||||
mFdp.ConsumeBool() ? kTestSessionId1
|
||||
: mFdp.ConsumeRandomLengthString(kMaxByte),
|
||||
&rawServiceCertificate);
|
||||
if (mFdp.ConsumeBool()) {
|
||||
serviceCertificate.Init(mFdp.ConsumeBool()
|
||||
? rawServiceCertificate
|
||||
fdp_.ConsumeBool() ? kTestSessionId1
|
||||
: fdp_.ConsumeRandomLengthString(kMaxByte),
|
||||
&raw_service_certificate);
|
||||
if (fdp_.ConsumeBool()) {
|
||||
service_certificate.Init(fdp_.ConsumeBool()
|
||||
? raw_service_certificate
|
||||
: kTestSignedCertificate);
|
||||
} else {
|
||||
serviceCertificate.Init(
|
||||
mFdp.ConsumeRandomLengthString(kMaxByte));
|
||||
service_certificate.Init(
|
||||
fdp_.ConsumeRandomLengthString(kMaxByte));
|
||||
}
|
||||
},
|
||||
[&]() {
|
||||
serviceCertificate.VerifySignedMessage(
|
||||
mFdp.ConsumeRandomLengthString(kMaxByte) /*message*/,
|
||||
mFdp.ConsumeRandomLengthString(kMaxByte) /*signature*/);
|
||||
service_certificate.VerifySignedMessage(
|
||||
fdp_.ConsumeRandomLengthString(kMaxByte) /*message*/,
|
||||
fdp_.ConsumeRandomLengthString(kMaxByte) /*signature*/);
|
||||
},
|
||||
[&]() {
|
||||
CdmKeyMessage signedCertificate =
|
||||
mFdp.ConsumeRandomLengthString(kMaxByte);
|
||||
serviceCertificate.ParseResponse(
|
||||
mFdp.ConsumeRandomLengthString(kMaxByte) /*response*/,
|
||||
mFdp.ConsumeBool()
|
||||
CdmKeyMessage signed_certificate =
|
||||
fdp_.ConsumeRandomLengthString(kMaxByte);
|
||||
service_certificate.ParseResponse(
|
||||
fdp_.ConsumeRandomLengthString(kMaxByte) /*response*/,
|
||||
fdp_.ConsumeBool()
|
||||
? nullptr
|
||||
: &signedCertificate /*signed_certificate*/);
|
||||
: &signed_certificate /*signed_certificate*/);
|
||||
},
|
||||
[&]() {
|
||||
CdmKeyMessage request;
|
||||
serviceCertificate.GetRequest(mFdp.ConsumeBool() ? nullptr
|
||||
service_certificate.GetRequest(fdp_.ConsumeBool() ? nullptr
|
||||
: &request);
|
||||
},
|
||||
[&]() {
|
||||
@@ -95,39 +97,39 @@ void ServiceCertificateFuzzer::process() {
|
||||
* crypto_session object is not used in EncryptClientId.
|
||||
* Therefore keeping crypto_session as nullptr.
|
||||
*/
|
||||
ClientIdentification_ClientCapabilities *clientCapabilities =
|
||||
clearClientId.mutable_client_capabilities();
|
||||
ClientIdentification_ClientCapabilities *client_capabilities =
|
||||
clear_client_id.mutable_client_capabilities();
|
||||
/**
|
||||
* Default value of clientCapabilities is false.
|
||||
* Default value of client_capabilities is false.
|
||||
* So passing true to all set methods.
|
||||
*/
|
||||
int32_t clientCase =
|
||||
mFdp.ConsumeIntegralInRange<int32_t>(kMinNum, kMaxNum);
|
||||
switch (clientCase) {
|
||||
int32_t client_case =
|
||||
fdp_.ConsumeIntegralInRange<int32_t>(kMinNum, kMaxNum);
|
||||
switch (client_case) {
|
||||
case 0:
|
||||
clientCapabilities->set_client_token(true /*Value*/);
|
||||
client_capabilities->set_client_token(true /*Value*/);
|
||||
break;
|
||||
case 1:
|
||||
clientCapabilities->set_session_token(true /*Value*/);
|
||||
client_capabilities->set_session_token(true /*Value*/);
|
||||
break;
|
||||
case 2:
|
||||
clientCapabilities->set_video_resolution_constraints(
|
||||
client_capabilities->set_video_resolution_constraints(
|
||||
true /*Value*/);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
serviceCertificate.EncryptClientId(nullptr /*crypto_session*/,
|
||||
&clearClientId,
|
||||
&encryptedClientId);
|
||||
service_certificate.EncryptClientId(nullptr /*crypto_session*/,
|
||||
&clear_client_id,
|
||||
&encrypted_client_id);
|
||||
},
|
||||
});
|
||||
invokeServiceCertificateAPI();
|
||||
invoke_service_certificate_API();
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
ServiceCertificateFuzzer serviceCertificateFuzzer(data, size);
|
||||
serviceCertificateFuzzer.process();
|
||||
ServiceCertificateFuzzer service_certificate_fuzzer(data, size);
|
||||
service_certificate_fuzzer.Process();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user