Revise cdm signing api and test

[ Merge of http://go/wvgerrit/178131 ]

Bug: 279671867
Bug: 279672538
Test: com.google.android.wvts
Change-Id: If2e2c6d250c0379c217b3f9b21efb197c9ae4fd6
(cherry picked from commit 1e05d16ddeaeff5de994e30aa713cd74bed21400)
This commit is contained in:
Kyle Zhang
2023-05-12 21:28:55 +00:00
parent bd389027a1
commit b0c3e69962
5 changed files with 28 additions and 22 deletions

View File

@@ -2341,7 +2341,7 @@ void CdmEngine::SetFastOtaKeyboxFallbackDurationRules() {
system_fallback_policy->SetFastBackoffDurationRules();
}
CdmResponseType CdmEngine::SignRSA(const std::string& wrapped_key,
CdmResponseType CdmEngine::SignRsa(const std::string& wrapped_key,
const std::string& message,
std::string* signature,
RSA_Padding_Scheme padding_scheme) {
@@ -2355,9 +2355,13 @@ CdmResponseType CdmEngine::SignRSA(const std::string& wrapped_key,
// Retrieve the cdm session
std::shared_ptr<CdmSession> session;
if (!session_map_.FindSession(session_id, &session)) {
LOGE("Session not found: session_id = %s", IdToString(session_id));
return CdmResponseType(SESSION_NOT_FOUND_24);
{
std::unique_lock<std::recursive_mutex> lock(session_map_lock_);
if (!session_map_.FindSession(session_id, &session)) {
LOGE("Session not found: session_id = %s", IdToString(session_id));
CloseSession(session_id);
return CdmResponseType(SESSION_NOT_FOUND_24);
}
}
// Load cast private key for signing
@@ -2365,13 +2369,15 @@ CdmResponseType CdmEngine::SignRSA(const std::string& wrapped_key,
sts = session->LoadCastPrivateKey(key);
if (sts != NO_ERROR) {
LOGE("LoadCastPrivateKey failed, status: %d", static_cast<int>(sts));
CloseSession(session_id);
return sts;
}
// Generate Rsa signature for cast message
sts = session->GenerateRSASignature(message, signature, padding_scheme);
sts = session->GenerateRsaSignature(message, signature, padding_scheme);
if (sts != NO_ERROR) {
LOGE("GenerateRSASignature failed, status: %d", static_cast<int>(sts));
LOGE("GenerateRsaSignature failed, status: %d", static_cast<int>(sts));
CloseSession(session_id);
return sts;
}