resolved conflicts for merge of 3db90f54 to master

Change-Id: Ie9e46292e003fefce9ca44a31cb338a0ecf51930
This commit is contained in:
Jeff Tinker
2014-04-01 16:32:36 -07:00
26 changed files with 874 additions and 49 deletions

View File

@@ -320,12 +320,23 @@ status_t WVDrmPlugin::queryKeyStatus(
return mapCdmResponseType(res);
}
status_t WVDrmPlugin::getProvisionRequest(Vector<uint8_t>& request,
status_t WVDrmPlugin::getProvisionRequest(const String8& cert_type,
const String8& cert_authority,
Vector<uint8_t>& request,
String8& defaultUrl) {
CdmProvisioningRequest cdmProvisionRequest;
string cdmDefaultUrl;
CdmResponseType res = mCDM->GetProvisioningRequest(&cdmProvisionRequest,
CdmCertificateType cdmCertType = kCertificateWidevine;
if (cert_type == "X.509") {
cdmCertType = kCertificateX509;
}
string cdmCertAuthority = cert_authority.string();
CdmResponseType res = mCDM->GetProvisioningRequest(cdmCertType,
cdmCertAuthority,
&cdmProvisionRequest,
&cdmDefaultUrl);
if (isCdmResponseTypeSuccess(res)) {
@@ -342,9 +353,27 @@ status_t WVDrmPlugin::getProvisionRequest(Vector<uint8_t>& request,
}
status_t WVDrmPlugin::provideProvisionResponse(
const Vector<uint8_t>& response) {
const Vector<uint8_t>& response,
Vector<uint8_t>& certificate,
Vector<uint8_t>& wrapped_key) {
CdmProvisioningResponse cdmResponse(response.begin(), response.end());
CdmResponseType res = mCDM->HandleProvisioningResponse(cdmResponse);
string cdmCertificate;
string cdmWrappedKey;
CdmResponseType res = mCDM->HandleProvisioningResponse(cdmResponse,
&cdmCertificate,
&cdmWrappedKey);
if (isCdmResponseTypeSuccess(res)) {
certificate.clear();
certificate.appendArray(
reinterpret_cast<const uint8_t*>(cdmCertificate.data()),
cdmCertificate.size());
wrapped_key.clear();
wrapped_key.appendArray(
reinterpret_cast<const uint8_t*>(cdmWrappedKey.data()),
cdmWrappedKey.size());
}
return mapCdmResponseType(res);
}
@@ -706,7 +735,7 @@ status_t WVDrmPlugin::sign(const Vector<uint8_t>& sessionId,
res = mCrypto->sign(cryptoSession.oecSessionId(), message.array(),
message.size(), cryptoSession.macAlgorithm(),
signature.editArray(), &signatureSize);
NULL, &signatureSize);
if (res != OEMCrypto_ERROR_SHORT_BUFFER) {
ALOGE("OEMCrypto_Generic_Sign failed with %u when requesting signature "
@@ -773,6 +802,68 @@ status_t WVDrmPlugin::verify(const Vector<uint8_t>& sessionId,
}
}
status_t WVDrmPlugin::signRSA(const Vector<uint8_t>& sessionId,
const String8& algorithm,
const Vector<uint8_t>& message,
const Vector<uint8_t>& wrappedKey,
Vector<uint8_t>& signature) {
CdmSessionId cdmSessionId(sessionId.begin(), sessionId.end());
if (!mCryptoSessions.count(cdmSessionId)) {
return android::ERROR_DRM_SESSION_NOT_OPENED;
}
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
RSA_Padding_Scheme padding_scheme;
if (algorithm == "RSASSA-PSS-SHA1") {
padding_scheme = kSign_RSASSA_PSS;
} else if (algorithm == "PKCS1-BlockType1") {
padding_scheme = kSign_PKCS1_Block1;
} else {
ALOGE("Unknown RSA Algorithm %s", algorithm.string());
return android::ERROR_DRM_CANNOT_HANDLE;
}
OEMCryptoResult res = mCrypto->loadDeviceRSAKey(cryptoSession.oecSessionId(),
wrappedKey.array(),
wrappedKey.size());
if (res != OEMCrypto_SUCCESS) {
ALOGE("OEMCrypto_LoadDeviceRSAKey failed with %u", res);
return mapOEMCryptoResult(res);
}
size_t signatureSize = 0;
res = mCrypto->generateRSASignature(cryptoSession.oecSessionId(),
message.array(), message.size(),
NULL, &signatureSize, padding_scheme);
if (res != OEMCrypto_ERROR_SHORT_BUFFER) {
ALOGE("OEMCrypto_GenerateRSASignature failed with %u when requesting "
"signature size", res);
if (res != OEMCrypto_SUCCESS) {
return mapOEMCryptoResult(res);
} else {
return android::ERROR_DRM_UNKNOWN;
}
}
signature.resize(signatureSize);
res = mCrypto->generateRSASignature(cryptoSession.oecSessionId(),
message.array(), message.size(),
signature.editArray(), &signatureSize,
padding_scheme);
if (res != OEMCrypto_SUCCESS) {
ALOGE("OEMCrypto_GenerateRSASignature failed with %u", res);
return mapOEMCryptoResult(res);
}
return android::OK;
}
void WVDrmPlugin::OnEvent(const CdmSessionId& cdmSessionId,
CdmEventType cdmEventType) {
Vector<uint8_t> sessionId;
@@ -809,8 +900,13 @@ status_t WVDrmPlugin::mapAndNotifyOfCdmResponseType(
status_t WVDrmPlugin::mapAndNotifyOfOEMCryptoResult(
const Vector<uint8_t>& sessionId,
OEMCryptoResult res) {
// Note that we only cover those errors that OEMCryptoCENC.h states may be
// returned by the generic crypto methods.
if (res == OEMCrypto_ERROR_NO_DEVICE_KEY) {
sendEvent(kDrmPluginEventProvisionRequired, 0, &sessionId, NULL);
}
return mapOEMCryptoResult(res);
}
status_t WVDrmPlugin::mapOEMCryptoResult(OEMCryptoResult res) {
switch (res) {
case OEMCrypto_SUCCESS:
return android::OK;
@@ -819,11 +915,19 @@ status_t WVDrmPlugin::mapAndNotifyOfOEMCryptoResult(
case OEMCrypto_ERROR_SHORT_BUFFER:
return kErrorIncorrectBufferSize;
case OEMCrypto_ERROR_NO_DEVICE_KEY:
sendEvent(kDrmPluginEventProvisionRequired, 0, &sessionId, NULL);
return android::ERROR_DRM_NOT_PROVISIONED;
case OEMCrypto_ERROR_INVALID_SESSION:
return android::ERROR_DRM_SESSION_NOT_OPENED;
case OEMCrypto_ERROR_TOO_MANY_SESSIONS:
return kErrorTooManySessions;
case OEMCrypto_ERROR_INVALID_RSA_KEY:
return kErrorInvalidKey;
case OEMCrypto_ERROR_INSUFFICIENT_RESOURCES:
return android::ERROR_DRM_RESOURCE_BUSY;
case OEMCrypto_ERROR_NOT_IMPLEMENTED:
return android::ERROR_DRM_CANNOT_HANDLE;
case OEMCrypto_ERROR_UNKNOWN_FAILURE:
case OEMCrypto_ERROR_OPEN_SESSION_FAILED:
return android::ERROR_DRM_UNKNOWN;
default:
return android::UNKNOWN_ERROR;