Add clang-tidy support for the OPK Linux port
Bug: 256230932 Change-Id: I4f46e285376101ff129c1fca5c80a259c70cc0c7
This commit is contained in:
@@ -60,17 +60,12 @@ void DeviceFeatures::Initialize() {
|
||||
printf("--- ERROR: Could not open session: %d ----\n", result);
|
||||
}
|
||||
// If the device uses a keybox, check to see if loading a certificate is
|
||||
// installed.
|
||||
if (provisioning_method == OEMCrypto_Keybox ||
|
||||
provisioning_method == OEMCrypto_OEMCertificate ||
|
||||
provisioning_method == OEMCrypto_BootCertificateChain) {
|
||||
// Devices with a keybox or OEM Certificate are required to support loading
|
||||
// a DRM certificate.
|
||||
loads_certificate = true;
|
||||
} else {
|
||||
// Other devices are either broken, or they have a baked in certificate.
|
||||
loads_certificate = false;
|
||||
}
|
||||
// installed. Devices with a keybox or OEM Certificate are required to support
|
||||
// loading a DRM certificate. Other devices are either broken, or they have a
|
||||
// baked in certificate.
|
||||
loads_certificate = provisioning_method == OEMCrypto_Keybox ||
|
||||
provisioning_method == OEMCrypto_OEMCertificate ||
|
||||
provisioning_method == OEMCrypto_BootCertificateChain;
|
||||
printf("loads_certificate = %s.\n", loads_certificate ? "true" : "false");
|
||||
generic_crypto =
|
||||
(OEMCrypto_ERROR_NOT_IMPLEMENTED !=
|
||||
|
||||
@@ -685,11 +685,9 @@ void LicenseRoundTrip::CreateDefaultResponse() {
|
||||
// Fill in the default core_response_ fields, except the substrings, which are
|
||||
// filled in the next function.
|
||||
core_response_.nonce_required =
|
||||
((wvoec::kControlNonceEnabled | wvoec::kControlNonceOrEntry |
|
||||
wvoec::kControlNonceRequired) &
|
||||
control_)
|
||||
? 1
|
||||
: 0;
|
||||
(wvoec::kControlNonceEnabled | wvoec::kControlNonceOrEntry |
|
||||
wvoec::kControlNonceRequired) &
|
||||
control_;
|
||||
core_response_.license_type = license_type_;
|
||||
FillCoreResponseSubstrings();
|
||||
}
|
||||
@@ -1866,10 +1864,7 @@ bool Session::GenerateRsaSessionKey(vector<uint8_t>* session_key,
|
||||
}
|
||||
*session_key = wvutil::a2b_hex("6fa479c731d2770b6a61a5d1420bb9d1");
|
||||
*enc_session_key = public_rsa_->EncryptSessionKey(*session_key);
|
||||
if (enc_session_key->empty()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !enc_session_key->empty();
|
||||
}
|
||||
|
||||
bool Session::GenerateEccSessionKey(vector<uint8_t>* session_key,
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#include "oemcrypto_types.h"
|
||||
#include "pst_report.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// GTest requires PrintTo to be in the same namespace as the thing it prints,
|
||||
// which is std::vector in this case.
|
||||
namespace std {
|
||||
@@ -38,13 +36,15 @@ void PrintTo(const vector<uint8_t>& value, ostream* os);
|
||||
} // namespace std
|
||||
|
||||
namespace wvoec {
|
||||
|
||||
using namespace std;
|
||||
|
||||
// OEMCrypto Fuzzing: Set max signture length to 1mb.
|
||||
const size_t MB = 1024 * 1024;
|
||||
|
||||
// Make sure this is larger than kMaxKeysPerSession.
|
||||
constexpr size_t kMaxNumKeys = 30;
|
||||
|
||||
namespace {
|
||||
#if defined(TEST_SPEED_MULTIPLIER) // Can slow test time limits when
|
||||
// debugging is slowing everything.
|
||||
constexpr int kSpeedMultiplier = TEST_SPEED_MULTIPLIER;
|
||||
@@ -57,7 +57,6 @@ constexpr uint32_t kDuration = 2 * kSpeedMultiplier;
|
||||
constexpr uint32_t kLongDuration = 5 * kSpeedMultiplier;
|
||||
constexpr int32_t kTimeTolerance = 3 * kSpeedMultiplier;
|
||||
constexpr int64_t kUsageTableTimeTolerance = 10 * kSpeedMultiplier;
|
||||
} // namespace
|
||||
|
||||
// Note: The API does not specify a maximum key id length. We specify a
|
||||
// maximum just for these tests, so that we have a fixed message size.
|
||||
@@ -158,7 +157,7 @@ class RoundTrip {
|
||||
required_request_signature_size_(0),
|
||||
encrypted_response_length_(0),
|
||||
response_signature_length_(0) {}
|
||||
virtual ~RoundTrip() {}
|
||||
virtual ~RoundTrip() = default;
|
||||
|
||||
// Have OEMCrypto sign a request message and then verify the signature and the
|
||||
// core message.
|
||||
@@ -380,7 +379,7 @@ class LicenseRoundTrip
|
||||
: RoundTrip(session),
|
||||
control_(wvoec::kControlNonceEnabled),
|
||||
num_keys_(4),
|
||||
pst_(""),
|
||||
pst_(),
|
||||
minimum_srm_version_(0),
|
||||
update_mac_keys_(true),
|
||||
api_version_(kCurrentAPI),
|
||||
@@ -519,7 +518,7 @@ class RenewalRoundTrip
|
||||
void EncryptAndSignResponse() override;
|
||||
void InjectFuzzedResponseData(OEMCrypto_Renewal_Response_Fuzz& fuzzed_data,
|
||||
const uint8_t* renewal_response,
|
||||
const size_t renewal_response_size);
|
||||
size_t renewal_response_size);
|
||||
OEMCryptoResult LoadResponse() override { return LoadResponse(session_); }
|
||||
OEMCryptoResult LoadResponse(Session* session) override;
|
||||
uint64_t renewal_duration_seconds() const {
|
||||
@@ -852,6 +851,7 @@ OEMCryptoResult GetKeyHandleIntoVector(OEMCrypto_SESSION session,
|
||||
size_t key_id_length,
|
||||
OEMCryptoCipherMode cipher_mode,
|
||||
vector<uint8_t>& key_handle);
|
||||
|
||||
} // namespace wvoec
|
||||
|
||||
#endif // CDM_OEC_SESSION_UTIL_H_
|
||||
|
||||
@@ -189,7 +189,6 @@ TEST_F(OEMCryptoClientTest, VersionNumber) {
|
||||
if (sts != OEMCrypto_SUCCESS) {
|
||||
LOGW("Device is not production ready, returns %d", sts);
|
||||
}
|
||||
sts = OEMCrypto_SUCCESS;
|
||||
std::string build_info;
|
||||
size_t buf_length = 0;
|
||||
sts = OEMCrypto_BuildInformation(&build_info[0], &buf_length);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace wvoec {
|
||||
const uint8_t kFuzzDataSeparator[] = {'-', '_', '^', '_'};
|
||||
|
||||
void AppendToFile(const std::string& file_name, const char* message,
|
||||
const size_t message_size);
|
||||
size_t message_size);
|
||||
|
||||
// Function to append separator "-_^_" between contents of corpus file.
|
||||
void AppendSeparator(const std::string& file_name);
|
||||
|
||||
@@ -960,7 +960,6 @@ TEST_P(OEMCryptoRefreshTest, RenewLicenseLoadOutsideRentalDuration) {
|
||||
// failure.
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
session_.TestDecryptCTR(false, OEMCrypto_ERROR_UNKNOWN_FAILURE));
|
||||
return;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(TestAll, OEMCryptoRefreshTest,
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
#include "oemcrypto_resource_test.h"
|
||||
#include "wvcrc32.h"
|
||||
|
||||
using ::testing::WithParamInterface;
|
||||
|
||||
namespace wvoec {
|
||||
|
||||
using ::testing::WithParamInterface;
|
||||
|
||||
// Used for testing oemcrypto APIs with huge buffers.
|
||||
typedef const std::function<OEMCryptoResult(size_t)> oemcrypto_function;
|
||||
void TestHugeLengthDoesNotCrashAPI(oemcrypto_function f,
|
||||
|
||||
@@ -87,11 +87,8 @@
|
||||
#include "test_sleep.h"
|
||||
#include "wvcrc32.h"
|
||||
|
||||
using ::testing::Bool;
|
||||
using ::testing::Combine;
|
||||
using ::testing::Range;
|
||||
using ::testing::tuple;
|
||||
using ::testing::Values;
|
||||
using ::testing::WithParamInterface;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -207,7 +207,9 @@ OEMCryptoResult OemCertificate::GetPublicCertificate(
|
||||
return OEMCrypto_ERROR_SHORT_BUFFER;
|
||||
}
|
||||
*public_cert_length = cert_data.size();
|
||||
memcpy(public_cert, cert_data.data(), cert_data.size());
|
||||
if (public_cert != nullptr) {
|
||||
memcpy(public_cert, cert_data.data(), cert_data.size());
|
||||
}
|
||||
return OEMCrypto_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ bool ParseRsaPrivateKeyInfo(const uint8_t* buffer, size_t length,
|
||||
}
|
||||
ScopedBio bio;
|
||||
// Check allowed scheme type.
|
||||
if (!memcmp("SIGN", buffer, 4)) {
|
||||
if (memcmp("SIGN", buffer, 4) == 0) {
|
||||
uint32_t allowed_schemes_bno;
|
||||
memcpy(&allowed_schemes_bno, reinterpret_cast<const uint8_t*>(&buffer[4]),
|
||||
4);
|
||||
@@ -811,7 +811,9 @@ OEMCryptoResult RsaPublicKey::EncryptOaep(const uint8_t* message,
|
||||
return OEMCrypto_ERROR_SHORT_BUFFER;
|
||||
}
|
||||
*enc_message_length = enc_size;
|
||||
memcpy(enc_message, encrypt_buffer.data(), enc_size);
|
||||
if (enc_message != nullptr) {
|
||||
memcpy(enc_message, encrypt_buffer.data(), enc_size);
|
||||
}
|
||||
return OEMCrypto_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user