Files
android/libwvdrmengine/mediadrm/src_hidl/WVGenericCryptoInterface.cpp
Tom Cherry 6b2787121c remove extraneous using namespace android and deprecate utils/Log.h
This namespace is not used by this file and its declaration is removed
in a separate CL from utils/Log.h, which is the only place it is
defined, so we must remove this extraneous line.

Also, since that separate CL is deprecating utils/Log.h in favor of
log/log.h, we make the switch to the new header.

Test: Build

Change-Id: Iac4bc8faffbd2d68dc4ccccaf569db0c5a13a7bc
2017-07-12 17:13:01 -07:00

49 lines
1.7 KiB
C++

//
// Copyright 2013 Google Inc. All Rights Reserved.
//
//#define LOG_NDEBUG 0
#define LOG_TAG "WVCdm"
#include <log/log.h>
#include "WVGenericCryptoInterface.h"
#include "wv_cdm_constants.h"
namespace wvdrm {
using namespace std;
using namespace wvcdm;
OEMCryptoResult WVGenericCryptoInterface::signRSA(const uint8_t* wrapped_rsa_key,
size_t wrapped_rsa_key_length,
const uint8_t* message,
size_t message_length,
std::vector<uint8_t>& signature,
RSA_Padding_Scheme padding_scheme) {
OEMCrypto_SESSION session;
OEMCryptoResult sts = OEMCrypto_OpenSession(&session);
if (sts != OEMCrypto_SUCCESS) return sts;
sts = OEMCrypto_LoadDeviceRSAKey(session, wrapped_rsa_key,
wrapped_rsa_key_length);
if (sts == OEMCrypto_SUCCESS) {
size_t signatureSize = 0;
sts = OEMCrypto_GenerateRSASignature(session, message, message_length,
NULL, &signatureSize,
padding_scheme);
if (sts == OEMCrypto_SUCCESS) {
// Should be short buffer.
sts = OEMCrypto_ERROR_UNKNOWN_FAILURE;
} else if (sts == OEMCrypto_ERROR_SHORT_BUFFER) {
signature.resize(signatureSize);
sts = OEMCrypto_GenerateRSASignature(session, message, message_length,
signature.data(), &signatureSize,
padding_scheme);
}
}
OEMCrypto_CloseSession(session);
return sts;
}
} // namespace wvdrm