|
|
|
|
@@ -12,6 +12,7 @@
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "mapErrors-inl.h"
|
|
|
|
|
#include "media/stagefright/MediaErrors.h"
|
|
|
|
|
#include "utils/Errors.h"
|
|
|
|
|
#include "wv_cdm_constants.h"
|
|
|
|
|
@@ -45,8 +46,8 @@ status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
|
|
|
|
|
CdmSessionId cdmSessionId;
|
|
|
|
|
CdmResponseType res = mCDM->OpenSession("com.widevine", &cdmSessionId);
|
|
|
|
|
|
|
|
|
|
if (res != wvcdm::NO_ERROR) {
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
if (!isCdmResponseTypeSuccess(res)) {
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool success = false;
|
|
|
|
|
@@ -58,15 +59,18 @@ status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
|
|
|
|
|
// Construct a CryptoSession
|
|
|
|
|
CdmQueryMap info;
|
|
|
|
|
|
|
|
|
|
CdmResponseType res = mCDM->QueryKeyControlInfo(cdmSessionId, &info);
|
|
|
|
|
res = mCDM->QueryKeyControlInfo(cdmSessionId, &info);
|
|
|
|
|
|
|
|
|
|
if (res == wvcdm::NO_ERROR && info.count(QUERY_KEY_OEMCRYPTO_SESSION_ID)) {
|
|
|
|
|
if (isCdmResponseTypeSuccess(res) &&
|
|
|
|
|
info.count(QUERY_KEY_OEMCRYPTO_SESSION_ID)) {
|
|
|
|
|
OEMCrypto_SESSION oecSessionId;
|
|
|
|
|
istringstream(info[QUERY_KEY_OEMCRYPTO_SESSION_ID]) >> oecSessionId;
|
|
|
|
|
|
|
|
|
|
mCryptoSessions[cdmSessionId] = CryptoSession(oecSessionId);
|
|
|
|
|
|
|
|
|
|
success = true;
|
|
|
|
|
} else {
|
|
|
|
|
ALOGE("Unable to query key control info.");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ALOGE("Received failure when trying to attach WVDrmPlugin as an event"
|
|
|
|
|
@@ -87,7 +91,14 @@ status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
|
|
|
|
|
|
|
|
|
|
mCDM->CloseSession(cdmSessionId);
|
|
|
|
|
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
if (!isCdmResponseTypeSuccess(res)) {
|
|
|
|
|
// We got an error code we can return.
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
} else {
|
|
|
|
|
// We got a failure that did not give us an error code, such as a failure
|
|
|
|
|
// of AttachEventListener() or the key being missing from the map.
|
|
|
|
|
return kErrorCDMGeneric;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -95,12 +106,11 @@ status_t WVDrmPlugin::closeSession(const Vector<uint8_t>& sessionId) {
|
|
|
|
|
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
|
|
|
|
CdmResponseType res = mCDM->CloseSession(cdmSessionId);
|
|
|
|
|
|
|
|
|
|
if (res == wvcdm::NO_ERROR) {
|
|
|
|
|
if (isCdmResponseTypeSuccess(res)) {
|
|
|
|
|
mCryptoSessions.erase(cdmSessionId);
|
|
|
|
|
return android::OK;
|
|
|
|
|
} else {
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::getKeyRequest(
|
|
|
|
|
@@ -117,7 +127,7 @@ status_t WVDrmPlugin::getKeyRequest(
|
|
|
|
|
} else if (keyType == kKeyType_Streaming) {
|
|
|
|
|
cdmLicenseType = kLicenseTypeStreaming;
|
|
|
|
|
} else {
|
|
|
|
|
return BAD_TYPE;
|
|
|
|
|
return android::ERROR_DRM_CANNOT_HANDLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
|
|
|
|
@@ -140,17 +150,15 @@ status_t WVDrmPlugin::getKeyRequest(
|
|
|
|
|
cdmLicenseType,
|
|
|
|
|
cdmParameters, &keyRequest);
|
|
|
|
|
|
|
|
|
|
if (res != wvcdm::KEY_MESSAGE) {
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
if (isCdmResponseTypeSuccess(res)) {
|
|
|
|
|
defaultUrl.clear();
|
|
|
|
|
|
|
|
|
|
request.clear();
|
|
|
|
|
request.appendArray(reinterpret_cast<const uint8_t*>(keyRequest.data()),
|
|
|
|
|
keyRequest.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defaultUrl.clear();
|
|
|
|
|
|
|
|
|
|
request.clear();
|
|
|
|
|
request.appendArray(reinterpret_cast<const uint8_t*>(keyRequest.data()),
|
|
|
|
|
keyRequest.size());
|
|
|
|
|
|
|
|
|
|
return android::OK;
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::provideKeyResponse(
|
|
|
|
|
@@ -163,11 +171,7 @@ status_t WVDrmPlugin::provideKeyResponse(
|
|
|
|
|
|
|
|
|
|
CdmResponseType res = mCDM->AddKey(cdmSessionId, cdmResponse);
|
|
|
|
|
|
|
|
|
|
if (res == wvcdm::KEY_ADDED || res == wvcdm::NO_ERROR) {
|
|
|
|
|
return android::OK;
|
|
|
|
|
} else {
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::removeKeys(const Vector<uint8_t>& keySetId) {
|
|
|
|
|
@@ -189,24 +193,22 @@ status_t WVDrmPlugin::queryKeyStatus(
|
|
|
|
|
|
|
|
|
|
CdmResponseType res = mCDM->QueryKeyStatus(cdmSessionId, &cdmLicenseInfo);
|
|
|
|
|
|
|
|
|
|
if (res != wvcdm::NO_ERROR) {
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
if (isCdmResponseTypeSuccess(res)) {
|
|
|
|
|
infoMap.clear();
|
|
|
|
|
for (CdmQueryMap::const_iterator iter = cdmLicenseInfo.begin();
|
|
|
|
|
iter != cdmLicenseInfo.end();
|
|
|
|
|
++iter) {
|
|
|
|
|
const string& cdmKey = iter->first;
|
|
|
|
|
const string& cdmValue = iter->second;
|
|
|
|
|
|
|
|
|
|
String8 key(cdmKey.data(), cdmKey.size());
|
|
|
|
|
String8 value(cdmValue.data(), cdmValue.size());
|
|
|
|
|
|
|
|
|
|
infoMap.add(key, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
infoMap.clear();
|
|
|
|
|
for (CdmQueryMap::const_iterator iter = cdmLicenseInfo.begin();
|
|
|
|
|
iter != cdmLicenseInfo.end();
|
|
|
|
|
++iter) {
|
|
|
|
|
const string& cdmKey = iter->first;
|
|
|
|
|
const string& cdmValue = iter->second;
|
|
|
|
|
|
|
|
|
|
String8 key(cdmKey.data(), cdmKey.size());
|
|
|
|
|
String8 value(cdmValue.data(), cdmValue.size());
|
|
|
|
|
|
|
|
|
|
infoMap.add(key, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return android::OK;
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::getProvisionRequest(Vector<uint8_t>& request,
|
|
|
|
|
@@ -217,19 +219,17 @@ status_t WVDrmPlugin::getProvisionRequest(Vector<uint8_t>& request,
|
|
|
|
|
CdmResponseType res = mCDM->GetProvisioningRequest(&cdmProvisionRequest,
|
|
|
|
|
&cdmDefaultUrl);
|
|
|
|
|
|
|
|
|
|
if (res != wvcdm::NO_ERROR) {
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
if (isCdmResponseTypeSuccess(res)) {
|
|
|
|
|
request.clear();
|
|
|
|
|
request.appendArray(reinterpret_cast<const uint8_t*>(
|
|
|
|
|
cdmProvisionRequest.data()),
|
|
|
|
|
cdmProvisionRequest.size());
|
|
|
|
|
|
|
|
|
|
defaultUrl.clear();
|
|
|
|
|
defaultUrl.setTo(cdmDefaultUrl.data(), cdmDefaultUrl.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
request.clear();
|
|
|
|
|
request.appendArray(reinterpret_cast<const uint8_t*>(
|
|
|
|
|
cdmProvisionRequest.data()),
|
|
|
|
|
cdmProvisionRequest.size());
|
|
|
|
|
|
|
|
|
|
defaultUrl.clear();
|
|
|
|
|
defaultUrl.setTo(cdmDefaultUrl.data(), cdmDefaultUrl.size());
|
|
|
|
|
|
|
|
|
|
return android::OK;
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::provideProvisionResponse(
|
|
|
|
|
@@ -239,11 +239,7 @@ status_t WVDrmPlugin::provideProvisionResponse(
|
|
|
|
|
|
|
|
|
|
CdmResponseType res = mCDM->HandleProvisioningResponse(cdmResponse);
|
|
|
|
|
|
|
|
|
|
if (res == wvcdm::NO_ERROR) {
|
|
|
|
|
return android::OK;
|
|
|
|
|
} else {
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::getSecureStops(List<Vector<uint8_t> >& secureStops) {
|
|
|
|
|
@@ -251,24 +247,22 @@ status_t WVDrmPlugin::getSecureStops(List<Vector<uint8_t> >& secureStops) {
|
|
|
|
|
|
|
|
|
|
CdmResponseType res = mCDM->GetSecureStops(&cdmSecureStops);
|
|
|
|
|
|
|
|
|
|
if (res != wvcdm::NO_ERROR) {
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
if (isCdmResponseTypeSuccess(res)) {
|
|
|
|
|
secureStops.clear();
|
|
|
|
|
for (CdmSecureStops::const_iterator iter = cdmSecureStops.begin();
|
|
|
|
|
iter != cdmSecureStops.end();
|
|
|
|
|
++iter) {
|
|
|
|
|
const string& cdmStop = *iter;
|
|
|
|
|
|
|
|
|
|
Vector<uint8_t> stop;
|
|
|
|
|
stop.appendArray(reinterpret_cast<const uint8_t*>(cdmStop.data()),
|
|
|
|
|
cdmStop.size());
|
|
|
|
|
|
|
|
|
|
secureStops.push_back(stop);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
secureStops.clear();
|
|
|
|
|
for (CdmSecureStops::const_iterator iter = cdmSecureStops.begin();
|
|
|
|
|
iter != cdmSecureStops.end();
|
|
|
|
|
++iter) {
|
|
|
|
|
const string& cdmStop = *iter;
|
|
|
|
|
|
|
|
|
|
Vector<uint8_t> stop;
|
|
|
|
|
stop.appendArray(reinterpret_cast<const uint8_t*>(cdmStop.data()),
|
|
|
|
|
cdmStop.size());
|
|
|
|
|
|
|
|
|
|
secureStops.push_back(stop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return android::OK;
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::releaseSecureStops(const Vector<uint8_t>& ssRelease) {
|
|
|
|
|
@@ -276,11 +270,7 @@ status_t WVDrmPlugin::releaseSecureStops(const Vector<uint8_t>& ssRelease) {
|
|
|
|
|
|
|
|
|
|
CdmResponseType res = mCDM->ReleaseSecureStops(cdmMessage);
|
|
|
|
|
|
|
|
|
|
if (res == wvcdm::NO_ERROR) {
|
|
|
|
|
return android::OK;
|
|
|
|
|
} else {
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::getPropertyString(const String8& name,
|
|
|
|
|
@@ -298,12 +288,12 @@ status_t WVDrmPlugin::getPropertyString(const String8& name,
|
|
|
|
|
|
|
|
|
|
CdmResponseType res = mCDM->QueryStatus(&status);
|
|
|
|
|
|
|
|
|
|
if (res != wvcdm::NO_ERROR) {
|
|
|
|
|
if (!isCdmResponseTypeSuccess(res)) {
|
|
|
|
|
ALOGE("Error querying CDM status: %u", res);
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
} else if (!status.count(QUERY_KEY_SECURITY_LEVEL)) {
|
|
|
|
|
ALOGE("CDM did not report a security level");
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return kErrorCDMGeneric;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const string& securityLevel = status[QUERY_KEY_SECURITY_LEVEL];
|
|
|
|
|
@@ -312,7 +302,7 @@ status_t WVDrmPlugin::getPropertyString(const String8& name,
|
|
|
|
|
value.append(securityLevel.data(), securityLevel.size());
|
|
|
|
|
} else {
|
|
|
|
|
ALOGE("App requested unknown property %s", name.string());
|
|
|
|
|
return android::ERROR_UNSUPPORTED;
|
|
|
|
|
return android::ERROR_DRM_CANNOT_HANDLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return android::OK;
|
|
|
|
|
@@ -325,12 +315,12 @@ status_t WVDrmPlugin::getPropertyByteArray(const String8& name,
|
|
|
|
|
|
|
|
|
|
CdmResponseType res = mCDM->QueryStatus(&status);
|
|
|
|
|
|
|
|
|
|
if (res != wvcdm::NO_ERROR) {
|
|
|
|
|
if (!isCdmResponseTypeSuccess(res)) {
|
|
|
|
|
ALOGE("Error querying CDM status: %u", res);
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return mapCdmResponseType(res);
|
|
|
|
|
} else if (!status.count(QUERY_KEY_DEVICE_ID)) {
|
|
|
|
|
ALOGE("CDM did not report a unique ID");
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return kErrorCDMGeneric;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const string& uniqueId = status[QUERY_KEY_DEVICE_ID];
|
|
|
|
|
@@ -340,7 +330,7 @@ status_t WVDrmPlugin::getPropertyByteArray(const String8& name,
|
|
|
|
|
uniqueId.size());
|
|
|
|
|
} else {
|
|
|
|
|
ALOGE("App requested unknown property %s", name.string());
|
|
|
|
|
return android::ERROR_UNSUPPORTED;
|
|
|
|
|
return android::ERROR_DRM_CANNOT_HANDLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return android::OK;
|
|
|
|
|
@@ -348,12 +338,12 @@ status_t WVDrmPlugin::getPropertyByteArray(const String8& name,
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::setPropertyString(const String8& name,
|
|
|
|
|
const String8& value) {
|
|
|
|
|
return android::ERROR_UNSUPPORTED;
|
|
|
|
|
return android::ERROR_DRM_CANNOT_HANDLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::setPropertyByteArray(const String8& name,
|
|
|
|
|
const Vector<uint8_t>& value) {
|
|
|
|
|
return android::ERROR_UNSUPPORTED;
|
|
|
|
|
return android::ERROR_DRM_CANNOT_HANDLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::setCipherAlgorithm(const Vector<uint8_t>& sessionId,
|
|
|
|
|
@@ -361,7 +351,7 @@ status_t WVDrmPlugin::setCipherAlgorithm(const Vector<uint8_t>& sessionId,
|
|
|
|
|
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
|
|
|
|
|
|
|
|
|
if (!mCryptoSessions.count(cdmSessionId)) {
|
|
|
|
|
return android::NO_INIT;
|
|
|
|
|
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
|
|
|
|
@@ -369,7 +359,7 @@ status_t WVDrmPlugin::setCipherAlgorithm(const Vector<uint8_t>& sessionId,
|
|
|
|
|
if (algorithm == "AES/CBC/NoPadding") {
|
|
|
|
|
cryptoSession.setCipherAlgorithm(OEMCrypto_AES_CBC_128_NO_PADDING);
|
|
|
|
|
} else {
|
|
|
|
|
return android::BAD_VALUE;
|
|
|
|
|
return android::ERROR_DRM_CANNOT_HANDLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return android::OK;
|
|
|
|
|
@@ -380,7 +370,7 @@ status_t WVDrmPlugin::setMacAlgorithm(const Vector<uint8_t>& sessionId,
|
|
|
|
|
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
|
|
|
|
|
|
|
|
|
if (!mCryptoSessions.count(cdmSessionId)) {
|
|
|
|
|
return android::NO_INIT;
|
|
|
|
|
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
|
|
|
|
@@ -388,7 +378,7 @@ status_t WVDrmPlugin::setMacAlgorithm(const Vector<uint8_t>& sessionId,
|
|
|
|
|
if (algorithm == "HmacSHA256") {
|
|
|
|
|
cryptoSession.setMacAlgorithm(OEMCrypto_HMAC_SHA256);
|
|
|
|
|
} else {
|
|
|
|
|
return android::BAD_VALUE;
|
|
|
|
|
return android::ERROR_DRM_CANNOT_HANDLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return android::OK;
|
|
|
|
|
@@ -402,7 +392,7 @@ status_t WVDrmPlugin::encrypt(const Vector<uint8_t>& sessionId,
|
|
|
|
|
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
|
|
|
|
|
|
|
|
|
if (!mCryptoSessions.count(cdmSessionId)) {
|
|
|
|
|
return android::NO_INIT;
|
|
|
|
|
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
|
|
|
|
@@ -416,7 +406,7 @@ status_t WVDrmPlugin::encrypt(const Vector<uint8_t>& sessionId,
|
|
|
|
|
|
|
|
|
|
if (res != OEMCrypto_SUCCESS) {
|
|
|
|
|
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return mapOEMCryptoResult(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
output.resize(input.size());
|
|
|
|
|
@@ -429,7 +419,7 @@ status_t WVDrmPlugin::encrypt(const Vector<uint8_t>& sessionId,
|
|
|
|
|
return android::OK;
|
|
|
|
|
} else {
|
|
|
|
|
ALOGE("OEMCrypto_Generic_Encrypt failed with %u", res);
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return mapOEMCryptoResult(res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -441,7 +431,7 @@ status_t WVDrmPlugin::decrypt(const Vector<uint8_t>& sessionId,
|
|
|
|
|
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
|
|
|
|
|
|
|
|
|
if (!mCryptoSessions.count(cdmSessionId)) {
|
|
|
|
|
return android::NO_INIT;
|
|
|
|
|
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
|
|
|
|
@@ -455,7 +445,7 @@ status_t WVDrmPlugin::decrypt(const Vector<uint8_t>& sessionId,
|
|
|
|
|
|
|
|
|
|
if (res != OEMCrypto_SUCCESS) {
|
|
|
|
|
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return mapOEMCryptoResult(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
output.resize(input.size());
|
|
|
|
|
@@ -468,7 +458,7 @@ status_t WVDrmPlugin::decrypt(const Vector<uint8_t>& sessionId,
|
|
|
|
|
return android::OK;
|
|
|
|
|
} else {
|
|
|
|
|
ALOGE("OEMCrypto_Generic_Decrypt failed with %u", res);
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return mapOEMCryptoResult(res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -479,7 +469,7 @@ status_t WVDrmPlugin::sign(const Vector<uint8_t>& sessionId,
|
|
|
|
|
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
|
|
|
|
|
|
|
|
|
if (!mCryptoSessions.count(cdmSessionId)) {
|
|
|
|
|
return android::NO_INIT;
|
|
|
|
|
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
|
|
|
|
@@ -493,7 +483,7 @@ status_t WVDrmPlugin::sign(const Vector<uint8_t>& sessionId,
|
|
|
|
|
|
|
|
|
|
if (res != OEMCrypto_SUCCESS) {
|
|
|
|
|
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return mapOEMCryptoResult(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t signatureSize = 0;
|
|
|
|
|
@@ -505,7 +495,11 @@ status_t WVDrmPlugin::sign(const Vector<uint8_t>& sessionId,
|
|
|
|
|
if (res != OEMCrypto_ERROR_SHORT_BUFFER) {
|
|
|
|
|
ALOGE("OEMCrypto_Generic_Sign failed with %u when requesting signature "
|
|
|
|
|
"size", res);
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
if (res != OEMCrypto_SUCCESS) {
|
|
|
|
|
return mapOEMCryptoResult(res);
|
|
|
|
|
} else {
|
|
|
|
|
return android::ERROR_DRM_UNKNOWN;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
signature.resize(signatureSize);
|
|
|
|
|
@@ -518,7 +512,7 @@ status_t WVDrmPlugin::sign(const Vector<uint8_t>& sessionId,
|
|
|
|
|
return android::OK;
|
|
|
|
|
} else {
|
|
|
|
|
ALOGE("OEMCrypto_Generic_Sign failed with %u", res);
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return mapOEMCryptoResult(res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -530,7 +524,7 @@ status_t WVDrmPlugin::verify(const Vector<uint8_t>& sessionId,
|
|
|
|
|
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
|
|
|
|
|
|
|
|
|
|
if (!mCryptoSessions.count(cdmSessionId)) {
|
|
|
|
|
return android::NO_INIT;
|
|
|
|
|
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
|
|
|
|
@@ -544,7 +538,7 @@ status_t WVDrmPlugin::verify(const Vector<uint8_t>& sessionId,
|
|
|
|
|
|
|
|
|
|
if (res != OEMCrypto_SUCCESS) {
|
|
|
|
|
ALOGE("OEMCrypto_SelectKey failed with %u", res);
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return mapOEMCryptoResult(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res = mCrypto->verify(cryptoSession.oecSessionId(), message.array(),
|
|
|
|
|
@@ -559,7 +553,7 @@ status_t WVDrmPlugin::verify(const Vector<uint8_t>& sessionId,
|
|
|
|
|
return android::OK;
|
|
|
|
|
} else {
|
|
|
|
|
ALOGE("OEMCrypto_Generic_Verify failed with %u", res);
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
return mapOEMCryptoResult(res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -587,4 +581,25 @@ void WVDrmPlugin::onEvent(const CdmSessionId& cdmSessionId,
|
|
|
|
|
sendEvent(eventType, 0, &sessionId, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status_t WVDrmPlugin::mapOEMCryptoResult(OEMCryptoResult res) {
|
|
|
|
|
// Note that we only cover those errors that OEMCryptoCENC.h states may be
|
|
|
|
|
// returned by the generic crypto methods.
|
|
|
|
|
switch (res) {
|
|
|
|
|
case OEMCrypto_SUCCESS:
|
|
|
|
|
return android::OK;
|
|
|
|
|
case OEMCrypto_ERROR_SIGNATURE_FAILURE:
|
|
|
|
|
return android::ERROR_DRM_TAMPER_DETECTED;
|
|
|
|
|
case OEMCrypto_ERROR_SHORT_BUFFER:
|
|
|
|
|
return kErrorIncorrectBufferSize;
|
|
|
|
|
case OEMCrypto_ERROR_NO_DEVICE_KEY:
|
|
|
|
|
return kErrorNeedProvisioning;
|
|
|
|
|
case OEMCrypto_ERROR_INVALID_SESSION:
|
|
|
|
|
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
|
|
|
|
case OEMCrypto_ERROR_UNKNOWN_FAILURE:
|
|
|
|
|
return android::ERROR_DRM_UNKNOWN;
|
|
|
|
|
default:
|
|
|
|
|
return android::UNKNOWN_ERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace wvdrm
|
|
|
|
|
|