OEMCrypto v16.2
Merge from Widevine repo of http://go/wvgerrit/93404 This is the unit tests, reference code, and documentation for OEMCrypto v16.2. Backwards compatibility should work for a v15 OEMCrypto. Some review comments will be addressed in future CLs. Bug: 141247171 Test: Unit tests Test: Media GTS tests on bonito Change-Id: I9d427c07580e180c0a4cfdc4a68f538d351c0ddd
This commit is contained in:
@@ -541,6 +541,8 @@ bool CryptoSession::GetApiMinorVersion(SecurityLevel security_level,
|
||||
WithOecReadLock("GetApiMinorVersion", [&] {
|
||||
*minor_version = OEMCrypto_MinorAPIVersion(security_level);
|
||||
});
|
||||
// Record the minor version into the metrics.
|
||||
metrics_->oemcrypto_minor_api_version_.Record(*minor_version);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -811,10 +813,12 @@ CdmResponseType CryptoSession::PrepareAndSignLicenseRequest(
|
||||
// First call is intended to determine the required size of the
|
||||
// output buffers.
|
||||
WithOecSessionLock("PrepareAndSignLicenseRequest", [&] {
|
||||
M_TIME(sts = OEMCrypto_PrepAndSignLicenseRequest(
|
||||
oec_session_id_, nullptr, message.size(), &core_message_length,
|
||||
nullptr, &signature_length),
|
||||
metrics_, oemcrypto_prep_and_sign_license_request_, sts);
|
||||
M_TIME(
|
||||
sts = OEMCrypto_PrepAndSignLicenseRequest(
|
||||
oec_session_id_,
|
||||
reinterpret_cast<uint8_t*>(const_cast<char*>(message.data())),
|
||||
message.size(), &core_message_length, nullptr, &signature_length),
|
||||
metrics_, oemcrypto_prep_and_sign_license_request_, sts);
|
||||
});
|
||||
|
||||
if (OEMCrypto_ERROR_SHORT_BUFFER != sts) {
|
||||
@@ -939,10 +943,12 @@ CdmResponseType CryptoSession::PrepareAndSignRenewalRequest(
|
||||
// First call is intended to determine the required size of the
|
||||
// output buffers.
|
||||
WithOecSessionLock("PrepareAndSignRenewalRequest", [&] {
|
||||
M_TIME(sts = OEMCrypto_PrepAndSignRenewalRequest(
|
||||
oec_session_id_, nullptr, message.size(), &core_message_length,
|
||||
nullptr, &signature_length),
|
||||
metrics_, oemcrypto_prep_and_sign_renewal_request_, sts);
|
||||
M_TIME(
|
||||
sts = OEMCrypto_PrepAndSignRenewalRequest(
|
||||
oec_session_id_,
|
||||
reinterpret_cast<uint8_t*>(const_cast<char*>(message.data())),
|
||||
message.size(), &core_message_length, nullptr, &signature_length),
|
||||
metrics_, oemcrypto_prep_and_sign_renewal_request_, sts);
|
||||
});
|
||||
|
||||
if (OEMCrypto_ERROR_SHORT_BUFFER != sts) {
|
||||
@@ -1056,10 +1062,12 @@ CdmResponseType CryptoSession::PrepareAndSignProvisioningRequest(
|
||||
// First call is intended to determine the required size of the
|
||||
// output buffers.
|
||||
WithOecSessionLock("PrepareAndSignProvisioningRequest", [&] {
|
||||
M_TIME(sts = OEMCrypto_PrepAndSignProvisioningRequest(
|
||||
oec_session_id_, nullptr, message.size(), &core_message_length,
|
||||
nullptr, &signature_length),
|
||||
metrics_, oemcrypto_prep_and_sign_provisioning_request_, sts);
|
||||
M_TIME(
|
||||
sts = OEMCrypto_PrepAndSignProvisioningRequest(
|
||||
oec_session_id_,
|
||||
reinterpret_cast<uint8_t*>(const_cast<char*>(message.data())),
|
||||
message.size(), &core_message_length, nullptr, &signature_length),
|
||||
metrics_, oemcrypto_prep_and_sign_provisioning_request_, sts);
|
||||
});
|
||||
|
||||
if (OEMCrypto_ERROR_SHORT_BUFFER != sts) {
|
||||
@@ -1318,8 +1326,8 @@ CdmResponseType CryptoSession::Decrypt(const CdmDecryptionParameters& params) {
|
||||
}
|
||||
|
||||
WithOecSessionLock("Decrypt() calling key_session_->Decrypt()", [&] {
|
||||
sts =
|
||||
key_session_->Decrypt(params, buffer_descriptor, pattern_descriptor);
|
||||
sts = key_session_->Decrypt(params, buffer_descriptor, 0,
|
||||
pattern_descriptor);
|
||||
});
|
||||
|
||||
if (sts == OEMCrypto_ERROR_BUFFER_TOO_LARGE) {
|
||||
@@ -1817,6 +1825,9 @@ bool CryptoSession::GetMaximumUsageTableEntries(SecurityLevel security_level,
|
||||
WithOecReadLock("GetMaxUsageTableEntries", [&] {
|
||||
*number_of_entries = OEMCrypto_MaximumUsageTableHeaderSize(security_level);
|
||||
});
|
||||
// Record the number of entries into the metrics.
|
||||
metrics_->oemcrypto_maximum_usage_table_header_size_.Record(
|
||||
*number_of_entries);
|
||||
|
||||
return *number_of_entries >= kMinimumUsageTableEntriesSupported;
|
||||
}
|
||||
@@ -2562,18 +2573,12 @@ OEMCryptoResult CryptoSession::DecryptInChunks(
|
||||
// of AES blocks long.
|
||||
OEMCryptoResult sts;
|
||||
sts = OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
#if 0 // TODO(b/135285640): fix this.
|
||||
WithOecSessionLock("DecryptInChunks", [&] {
|
||||
M_TIME(
|
||||
sts = OEMCrypto_DecryptCENC(
|
||||
oec_session_id_, params.encrypt_buffer + additional_offset,
|
||||
chunk_size, params.is_encrypted, &iv.front(), params.block_offset,
|
||||
&buffer_descriptor, &pattern_descriptor, subsample_flags),
|
||||
metrics_, oemcrypto_decrypt_cenc_, sts,
|
||||
metrics::Pow2Bucket(chunk_size));
|
||||
M_TIME(sts = key_session_->Decrypt(params, buffer_descriptor,
|
||||
additional_offset, pattern_descriptor),
|
||||
metrics_, oemcrypto_decrypt_cenc_, sts,
|
||||
metrics::Pow2Bucket(chunk_size));
|
||||
});
|
||||
#endif
|
||||
|
||||
if (sts != OEMCrypto_SUCCESS) {
|
||||
return sts;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user