Exposing the Cast Signing Algorithm
[ Merge of http://go/wvgerrit/178076 ] 1. Exposing the Cast Signing Algorithm in cdm core. 2. Update core Cast tests to use new core CDM Cast signing API. Bug: 279671867 Bug: 279672538 Test: com.google.android.wvts Change-Id: Ia73c4b5e6dd61edf790bca97a321881d310e7a99 (cherry picked from commit 8996b624d73adf14db45e54653e7ddc513f3895c)
This commit is contained in:
@@ -2340,4 +2340,48 @@ void CdmEngine::SetFastOtaKeyboxFallbackDurationRules() {
|
||||
}
|
||||
system_fallback_policy->SetFastBackoffDurationRules();
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::SignRSA(const std::string& wrapped_key,
|
||||
const std::string& message,
|
||||
std::string* signature,
|
||||
RSA_Padding_Scheme padding_scheme) {
|
||||
// Try to open cdm session.
|
||||
CdmSessionId session_id;
|
||||
auto sts = OpenSession("com.widevine", nullptr, nullptr, &session_id);
|
||||
if (sts != NO_ERROR) {
|
||||
LOGE("OpenSession failed, status: %d", static_cast<int>(sts));
|
||||
return sts;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Load cast private key for signing
|
||||
CryptoWrappedKey key(CryptoWrappedKey::kRsa, wrapped_key);
|
||||
sts = session->LoadCastPrivateKey(key);
|
||||
if (sts != NO_ERROR) {
|
||||
LOGE("LoadCastPrivateKey failed, status: %d", static_cast<int>(sts));
|
||||
return sts;
|
||||
}
|
||||
|
||||
// Generate Rsa signature for cast message
|
||||
sts = session->GenerateRSASignature(message, signature, padding_scheme);
|
||||
if (sts != NO_ERROR) {
|
||||
LOGE("GenerateRSASignature failed, status: %d", static_cast<int>(sts));
|
||||
return sts;
|
||||
}
|
||||
|
||||
// Try to close cdm session.
|
||||
sts = CloseSession(session_id);
|
||||
if (sts != NO_ERROR) {
|
||||
LOGE("CloseSession failed, status: %d", static_cast<int>(sts));
|
||||
return sts;
|
||||
}
|
||||
|
||||
return sts;
|
||||
}
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user