Merge "Piped CdmEngine's generic crypto operations to Android CDM." into udc-dev am: c77b0a6bf2
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/22824317 Change-Id: If0e060c39e67234c8041c1b705bac047198eee6c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -459,6 +459,7 @@ enum CdmResponseEnum : int32_t {
|
||||
UNSUPPORTED_SIGNATURE_HASH_ALGORITHM_4 = 393,
|
||||
STORE_ATSC_LICENSE_DEVICE_FILES_INIT_ERROR = 394,
|
||||
STORE_ATSC_LICENSE_ERROR = 395,
|
||||
SESSION_NOT_FOUND_GENERIC_CRYPTO = 396,
|
||||
// Don't forget to add new values to
|
||||
// * core/src/wv_cdm_types.cpp
|
||||
// * android/include/mapErrors-inl.h
|
||||
|
||||
@@ -865,6 +865,8 @@ const char* CdmResponseEnumToString(CdmResponseEnum cdm_response_enum) {
|
||||
return "STORE_ATSC_LICENSE_DEVICE_FILES_INIT_ERROR";
|
||||
case STORE_ATSC_LICENSE_ERROR:
|
||||
return "STORE_ATSC_LICENSE_ERROR";
|
||||
case SESSION_NOT_FOUND_GENERIC_CRYPTO:
|
||||
return "SESSION_NOT_FOUND_GENERIC_CRYPTO";
|
||||
}
|
||||
return UnknownValueRep(cdm_response_enum);
|
||||
}
|
||||
|
||||
@@ -270,6 +270,33 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
|
||||
virtual bool SetDefaultOtaKeyboxFallbackDurationRules();
|
||||
virtual bool SetFastOtaKeyboxFallbackDurationRules();
|
||||
|
||||
// Generic crypto API.
|
||||
virtual CdmResponseType GenericEncrypt(const CdmSessionId& session_id,
|
||||
const KeyId& key_id,
|
||||
const std::string& input,
|
||||
const std::string& iv,
|
||||
CdmEncryptionAlgorithm algorithm,
|
||||
std::string* output);
|
||||
|
||||
virtual CdmResponseType GenericDecrypt(const CdmSessionId& session_id,
|
||||
const KeyId& key_id,
|
||||
const std::string& input,
|
||||
const std::string& iv,
|
||||
CdmEncryptionAlgorithm algorithm,
|
||||
std::string* output);
|
||||
|
||||
virtual CdmResponseType GenericSign(const CdmSessionId& session_id,
|
||||
const KeyId& key_id,
|
||||
const std::string& input,
|
||||
CdmSigningAlgorithm algorithm,
|
||||
std::string* signature);
|
||||
|
||||
virtual CdmResponseType GenericVerify(const CdmSessionId& session_id,
|
||||
const KeyId& key_id,
|
||||
const std::string& input,
|
||||
CdmSigningAlgorithm algorithm,
|
||||
const std::string& signature);
|
||||
|
||||
private:
|
||||
struct CdmInfo {
|
||||
CdmInfo();
|
||||
|
||||
@@ -832,4 +832,68 @@ bool WvContentDecryptionModule::SetFastOtaKeyboxFallbackDurationRules() {
|
||||
return true;
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GenericEncrypt(
|
||||
const CdmSessionId& session_id, const KeyId& key_id,
|
||||
const std::string& input, const std::string& iv,
|
||||
CdmEncryptionAlgorithm algorithm, std::string* output) {
|
||||
if (output == nullptr) {
|
||||
LOGE("Output parameter |output| is null");
|
||||
return CdmResponseType(PARAMETER_NULL);
|
||||
}
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (cdm_engine == nullptr) {
|
||||
LOGW("Could not find session: sid = %s", wvcdm::IdToString(session_id));
|
||||
return CdmResponseType(SESSION_NOT_FOUND_GENERIC_CRYPTO);
|
||||
}
|
||||
return cdm_engine->GenericEncrypt(session_id, input, key_id, iv, algorithm,
|
||||
output);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GenericDecrypt(
|
||||
const CdmSessionId& session_id, const KeyId& key_id,
|
||||
const std::string& input, const std::string& iv,
|
||||
CdmEncryptionAlgorithm algorithm, std::string* output) {
|
||||
if (output == nullptr) {
|
||||
LOGE("Output parameter |output| is null");
|
||||
return CdmResponseType(PARAMETER_NULL);
|
||||
}
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (cdm_engine == nullptr) {
|
||||
LOGW("Could not find session: sid = %s", wvcdm::IdToString(session_id));
|
||||
return CdmResponseType(SESSION_NOT_FOUND_GENERIC_CRYPTO);
|
||||
}
|
||||
return cdm_engine->GenericDecrypt(session_id, input, key_id, iv, algorithm,
|
||||
output);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GenericSign(
|
||||
const CdmSessionId& session_id, const KeyId& key_id,
|
||||
const std::string& input, CdmSigningAlgorithm algorithm,
|
||||
std::string* signature) {
|
||||
if (signature == nullptr) {
|
||||
LOGE("Output parameter |signature| is null");
|
||||
return CdmResponseType(PARAMETER_NULL);
|
||||
}
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (cdm_engine == nullptr) {
|
||||
LOGW("Could not find session: sid = %s", wvcdm::IdToString(session_id));
|
||||
return CdmResponseType(SESSION_NOT_FOUND_GENERIC_CRYPTO);
|
||||
}
|
||||
return cdm_engine->GenericSign(session_id, input, key_id, algorithm,
|
||||
signature);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GenericVerify(
|
||||
const CdmSessionId& session_id, const KeyId& key_id,
|
||||
const std::string& input, CdmSigningAlgorithm algorithm,
|
||||
const std::string& signature) {
|
||||
CdmEngine* cdm_engine = GetCdmForSessionId(session_id);
|
||||
if (cdm_engine == nullptr) {
|
||||
LOGW("Could not find session: sid = %s", wvcdm::IdToString(session_id));
|
||||
return CdmResponseType(SESSION_NOT_FOUND_GENERIC_CRYPTO);
|
||||
}
|
||||
return cdm_engine->GenericVerify(session_id, input, key_id, algorithm,
|
||||
signature);
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -75,6 +75,7 @@ static inline WvStatus mapCdmResponseType(wvcdm::CdmResponseType res) {
|
||||
case wvcdm::SESSION_NOT_FOUND_21:
|
||||
case wvcdm::SESSION_NOT_FOUND_22:
|
||||
case wvcdm::SESSION_NOT_FOUND_23:
|
||||
case wvcdm::SESSION_NOT_FOUND_GENERIC_CRYPTO:
|
||||
err = Status::ERROR_DRM_SESSION_NOT_OPENED;
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user