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 "service_certificate.h"
|
||||||
#include "vendor_widevine_fuzz_helper.h"
|
#include "vendor_widevine_fuzz_helper.h"
|
||||||
#include "wv_cdm_event_listener.h"
|
#include "wv_cdm_event_listener.h"
|
||||||
#include "wv_cdm_types.h"
|
#include "wv_cdm_types.h"
|
||||||
#include <crypto_session.h>
|
|
||||||
#include <log.h>
|
|
||||||
#include <memory>
|
|
||||||
#include <utils/Log.h>
|
|
||||||
|
|
||||||
using namespace wvcdm;
|
using namespace wvcdm;
|
||||||
using namespace video_widevine;
|
using namespace video_widevine;
|
||||||
@@ -34,60 +36,60 @@ static constexpr int32_t kMaxByte = 256;
|
|||||||
class ServiceCertificateFuzzer {
|
class ServiceCertificateFuzzer {
|
||||||
public:
|
public:
|
||||||
ServiceCertificateFuzzer(const uint8_t *data, size_t size)
|
ServiceCertificateFuzzer(const uint8_t *data, size_t size)
|
||||||
: mFdp(data, size){};
|
: fdp_(data, size){};
|
||||||
void process();
|
void Process();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FuzzedDataProvider mFdp;
|
FuzzedDataProvider fdp_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ServiceCertificateFuzzer::process() {
|
void ServiceCertificateFuzzer::Process() {
|
||||||
EncryptedClientIdentification encryptedClientId;
|
EncryptedClientIdentification encrypted_client_id;
|
||||||
ClientIdentification clearClientId;
|
ClientIdentification clear_client_id;
|
||||||
ServiceCertificate serviceCertificate;
|
ServiceCertificate service_certificate;
|
||||||
while (mFdp.remaining_bytes()) {
|
while (fdp_.remaining_bytes()) {
|
||||||
auto invokeServiceCertificateAPI =
|
auto invoke_service_certificate_API =
|
||||||
mFdp.PickValueInArray<const std::function<void()>>({
|
fdp_.PickValueInArray<const std::function<void()>>({
|
||||||
[&]() {
|
[&]() {
|
||||||
FuzzCdmClientPropertySet propertySet(&mFdp);
|
FuzzCdmClientPropertySet property_set(&fdp_);
|
||||||
propertySet.enable_privacy_mode();
|
property_set.enable_privacy_mode();
|
||||||
propertySet.set_service_certificate(kTestSignedCertificate);
|
property_set.set_service_certificate(kTestSignedCertificate);
|
||||||
PropertiesTestPeer::ForceReinit();
|
PropertiesTestPeer::ForceReinit();
|
||||||
PropertiesTestPeer::AddSessionPropertySet(
|
PropertiesTestPeer::AddSessionPropertySet(
|
||||||
mFdp.ConsumeBool() ? kTestSessionId1
|
fdp_.ConsumeBool() ? kTestSessionId1
|
||||||
: mFdp.ConsumeRandomLengthString(kMaxByte),
|
: fdp_.ConsumeRandomLengthString(kMaxByte),
|
||||||
&propertySet);
|
&property_set);
|
||||||
std::string rawServiceCertificate;
|
std::string raw_service_certificate;
|
||||||
PropertiesTestPeer::GetServiceCertificate(
|
PropertiesTestPeer::GetServiceCertificate(
|
||||||
mFdp.ConsumeBool() ? kTestSessionId1
|
fdp_.ConsumeBool() ? kTestSessionId1
|
||||||
: mFdp.ConsumeRandomLengthString(kMaxByte),
|
: fdp_.ConsumeRandomLengthString(kMaxByte),
|
||||||
&rawServiceCertificate);
|
&raw_service_certificate);
|
||||||
if (mFdp.ConsumeBool()) {
|
if (fdp_.ConsumeBool()) {
|
||||||
serviceCertificate.Init(mFdp.ConsumeBool()
|
service_certificate.Init(fdp_.ConsumeBool()
|
||||||
? rawServiceCertificate
|
? raw_service_certificate
|
||||||
: kTestSignedCertificate);
|
: kTestSignedCertificate);
|
||||||
} else {
|
} else {
|
||||||
serviceCertificate.Init(
|
service_certificate.Init(
|
||||||
mFdp.ConsumeRandomLengthString(kMaxByte));
|
fdp_.ConsumeRandomLengthString(kMaxByte));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
serviceCertificate.VerifySignedMessage(
|
service_certificate.VerifySignedMessage(
|
||||||
mFdp.ConsumeRandomLengthString(kMaxByte) /*message*/,
|
fdp_.ConsumeRandomLengthString(kMaxByte) /*message*/,
|
||||||
mFdp.ConsumeRandomLengthString(kMaxByte) /*signature*/);
|
fdp_.ConsumeRandomLengthString(kMaxByte) /*signature*/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
CdmKeyMessage signedCertificate =
|
CdmKeyMessage signed_certificate =
|
||||||
mFdp.ConsumeRandomLengthString(kMaxByte);
|
fdp_.ConsumeRandomLengthString(kMaxByte);
|
||||||
serviceCertificate.ParseResponse(
|
service_certificate.ParseResponse(
|
||||||
mFdp.ConsumeRandomLengthString(kMaxByte) /*response*/,
|
fdp_.ConsumeRandomLengthString(kMaxByte) /*response*/,
|
||||||
mFdp.ConsumeBool()
|
fdp_.ConsumeBool()
|
||||||
? nullptr
|
? nullptr
|
||||||
: &signedCertificate /*signed_certificate*/);
|
: &signed_certificate /*signed_certificate*/);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
CdmKeyMessage request;
|
CdmKeyMessage request;
|
||||||
serviceCertificate.GetRequest(mFdp.ConsumeBool() ? nullptr
|
service_certificate.GetRequest(fdp_.ConsumeBool() ? nullptr
|
||||||
: &request);
|
: &request);
|
||||||
},
|
},
|
||||||
[&]() {
|
[&]() {
|
||||||
@@ -95,39 +97,39 @@ void ServiceCertificateFuzzer::process() {
|
|||||||
* crypto_session object is not used in EncryptClientId.
|
* crypto_session object is not used in EncryptClientId.
|
||||||
* Therefore keeping crypto_session as nullptr.
|
* Therefore keeping crypto_session as nullptr.
|
||||||
*/
|
*/
|
||||||
ClientIdentification_ClientCapabilities *clientCapabilities =
|
ClientIdentification_ClientCapabilities *client_capabilities =
|
||||||
clearClientId.mutable_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.
|
* So passing true to all set methods.
|
||||||
*/
|
*/
|
||||||
int32_t clientCase =
|
int32_t client_case =
|
||||||
mFdp.ConsumeIntegralInRange<int32_t>(kMinNum, kMaxNum);
|
fdp_.ConsumeIntegralInRange<int32_t>(kMinNum, kMaxNum);
|
||||||
switch (clientCase) {
|
switch (client_case) {
|
||||||
case 0:
|
case 0:
|
||||||
clientCapabilities->set_client_token(true /*Value*/);
|
client_capabilities->set_client_token(true /*Value*/);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
clientCapabilities->set_session_token(true /*Value*/);
|
client_capabilities->set_session_token(true /*Value*/);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
clientCapabilities->set_video_resolution_constraints(
|
client_capabilities->set_video_resolution_constraints(
|
||||||
true /*Value*/);
|
true /*Value*/);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
serviceCertificate.EncryptClientId(nullptr /*crypto_session*/,
|
service_certificate.EncryptClientId(nullptr /*crypto_session*/,
|
||||||
&clearClientId,
|
&clear_client_id,
|
||||||
&encryptedClientId);
|
&encrypted_client_id);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
invokeServiceCertificateAPI();
|
invoke_service_certificate_API();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
ServiceCertificateFuzzer serviceCertificateFuzzer(data, size);
|
ServiceCertificateFuzzer service_certificate_fuzzer(data, size);
|
||||||
serviceCertificateFuzzer.process();
|
service_certificate_fuzzer.Process();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user