Add level 3 libs and address build warnings
* Fix strict aliasing error in gcc [ Merge of http://go/wvgerrit/15856 ] This also ensures the alignment of 64-bit memory access in a portable way, without using compiler-specific mechanisms like attributes or platform-specific mechanisms like memalign. (The aliasing error does not show up in clang.) * Return kNotSupported for non-Widevine init data [ Merge of http://go/wvgerrit/15853 ] This also improves logging for the init data parser by including a verbose message for non-Widevine PSSHs and by using a new IsEOF() method to avoid misleading "Unable to read atom size" logs. * Cast RSA_size() to int [ Merge of http://go/wvgerrit/15880 ] It has been suggested that this may be unsigned on some versions of OpenSSL or BoringSSL. * Be strict about warnings for CE CDM [ Merge of http://go/wvgerrit/15831 ] * Enable all warnings and treat warnings as errors in the CE build. * Fix all existing warnings (mostly unused variables, consts, and functions, and one signed/unsigned comparison). * Exclude protobuf warnings rather than maintain a divergent copy. * Fix release build errors [ Merge of http://go/wvgerrit/15855 ] * Level 3 Build With Android Emulator [ Merge of http://go/wvgerrit/15778 ] This CL rebuilds the level 3 libraries with the android emulator sdk_phone_*. This seems to avoid problems with the x86 build using incorrect compiler flags. These libraries work for arm, x86, mips, arm64, and x86_64. The level 3 library is disabled for mips64. Versions: level3/mips/libwvlevel3.a Level3 Library Sep 30 2015 18:29:50 level3/arm/libwvlevel3.a Level3 Library Sep 28 2015 13:18:25 level3/x86/libwvlevel3.a Level3 Library Sep 28 2015 13:08:28 Change-Id: I1e50aa78bdc84ecb905f2e55297d4f48b140341c
This commit is contained in:
@@ -26,7 +26,8 @@ class BufferReader {
|
||||
BufferReader(const uint8_t* buf, size_t size)
|
||||
: buf_(buf), size_(buf != NULL ? size : 0), pos_(0) {}
|
||||
|
||||
bool HasBytes(size_t count) { return (pos() + count <= size()); }
|
||||
bool HasBytes(size_t count) const { return pos_ + count <= size_; }
|
||||
bool IsEOF() const { return pos_ >= size_; }
|
||||
|
||||
// Read a value from the stream, performing endian correction,
|
||||
// and advance the stream pointer.
|
||||
|
||||
@@ -48,6 +48,7 @@ CdmSession::CdmSession(CdmClientPropertySet* cdm_client_property_set,
|
||||
key_set_id_ = *forced_session_id;
|
||||
} else {
|
||||
bool ok = GenerateKeySetId(&key_set_id_);
|
||||
(void)ok; // ok is now used when assertions are turned off.
|
||||
assert(ok);
|
||||
}
|
||||
session_id_ = key_set_id_;
|
||||
|
||||
@@ -55,7 +55,7 @@ bool InitializationData::ExtractWidevinePssh(const CdmInitData& init_data,
|
||||
// (optional, if version == 1) K * 16 byte key ID.
|
||||
// 4 byte size of PSSH data, exclusive. (N)
|
||||
// N byte PSSH data.
|
||||
while (1) {
|
||||
while (!reader.IsEOF()) {
|
||||
size_t start_pos = reader.pos();
|
||||
|
||||
// atom size, used for skipping.
|
||||
@@ -128,6 +128,7 @@ bool InitializationData::ExtractWidevinePssh(const CdmInitData& init_data,
|
||||
"the atom.");
|
||||
return false;
|
||||
}
|
||||
LOGV("CdmEngine::ExtractWidevinePssh: Skipping non-Widevine PSSH.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,6 @@ TEST_F(CdmSessionTest, ReInitFail) {
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, InitFailCryptoError) {
|
||||
CdmSecurityLevel level = kSecurityLevelL1;
|
||||
EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault)))
|
||||
.WillOnce(Return(UNKNOWN_ERROR));
|
||||
|
||||
|
||||
@@ -1469,7 +1469,6 @@ class DeviceFilesTest : public ::testing::Test {
|
||||
CdmAppParameterMap app_parameters;
|
||||
size_t start_pos = 0;
|
||||
size_t len = str.length();
|
||||
bool more = true;
|
||||
while (start_pos < len) {
|
||||
size_t name_end_pos = str.find(' ', start_pos);
|
||||
if (name_end_pos == std::string::npos) return app_parameters;
|
||||
@@ -1841,7 +1840,6 @@ TEST_F(DeviceFilesTest, RetrieveLicenses) {
|
||||
DeviceFiles device_files;
|
||||
EXPECT_TRUE(device_files.Init(kSecurityLevelL1));
|
||||
device_files.SetTestFile(&file);
|
||||
DeviceFiles::LicenseState license_state;
|
||||
CdmInitData pssh_data;
|
||||
CdmKeyMessage key_request;
|
||||
CdmKeyResponse key_response;
|
||||
|
||||
@@ -47,6 +47,7 @@ SSL_CTX* InitSslContext() {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// unused, may be useful for debugging SSL-related issues.
|
||||
void ShowServerCertificate(const SSL* ssl) {
|
||||
// gets the server certificate
|
||||
@@ -64,6 +65,7 @@ void ShowServerCertificate(const SSL* ssl) {
|
||||
LOGE("Failed to get server certificate");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Wait for a socket to be ready for reading or writing.
|
||||
// Establishing a connection counts as "ready for write".
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace wvcdm {
|
||||
|
||||
namespace {
|
||||
|
||||
const uint32_t kAesBlockSize = 16;
|
||||
const std::string kAesKey = a2bs_hex("000102030405060708090a0b0c0d0e0f");
|
||||
const std::string kAesIv = a2bs_hex("000102030405060708090a0b0c0d0e0f");
|
||||
const std::string kCencInitDataHdr = a2bs_hex(
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
ifeq "$(TARGET_ARCH)" "mips64" # stub out mips64 because it doesn't link correctly.
|
||||
$(warning Widevine Level 3 library disabled for mips 64 devices.)
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libwvlevel3
|
||||
LOCAL_C_INCLUDES := vendor/widevine/libwvdrmengine/oemcrypto/include
|
||||
LOCAL_SRC_FILES := level3_stubs.cpp
|
||||
LOCAL_PROPRIETARY_MODULE := true
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_OWNER := widevine
|
||||
LOCAL_MODULE_TARGET_ARCH := mips
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
else # for 32 bit mips.
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libwvlevel3
|
||||
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
|
||||
@@ -9,3 +23,4 @@ LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_OWNER := widevine
|
||||
LOCAL_MODULE_TARGET_ARCH := mips
|
||||
include $(BUILD_PREBUILT)
|
||||
endif
|
||||
|
||||
292
libwvdrmengine/level3/mips/level3_stubs.cpp
Normal file
292
libwvdrmengine/level3/mips/level3_stubs.cpp
Normal file
@@ -0,0 +1,292 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Stubs for OEMCrypto Level 3 Fallback APIs. (use when level 3 doesn't compile)
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "level3.h"
|
||||
|
||||
namespace wvoec3 {
|
||||
OEMCryptoResult Level3_Initialize(void) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_Terminate(void) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_OpenSession(OEMCrypto_SESSION* /*session*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_CloseSession(OEMCrypto_SESSION /*session*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GenerateDerivedKeys(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*mac_key_context*/,
|
||||
uint32_t /*mac_key_context_length*/,
|
||||
const uint8_t* /*enc_key_context*/,
|
||||
uint32_t /*enc_key_context_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GenerateNonce(OEMCrypto_SESSION /*session*/,
|
||||
uint32_t* /*nonce*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GenerateSignature(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*message*/,
|
||||
size_t /*message_length*/,
|
||||
uint8_t* /*signature*/,
|
||||
size_t* /*signature_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_LoadKeys(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*message*/,
|
||||
size_t /*message_length*/,
|
||||
const uint8_t* /*signature*/,
|
||||
size_t /*signature_length*/,
|
||||
const uint8_t* /*enc_mac_key_iv*/,
|
||||
const uint8_t* /*enc_mac_key*/,
|
||||
size_t /*num_keys*/,
|
||||
const OEMCrypto_KeyObject* /*key_array*/,
|
||||
const uint8_t* /*pst*/,
|
||||
size_t /*pst_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_RefreshKeys(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*message*/,
|
||||
size_t /*message_length*/,
|
||||
const uint8_t* /*signature*/,
|
||||
size_t /*signature_length*/,
|
||||
size_t /*num_keys*/,
|
||||
const OEMCrypto_KeyRefreshObject* /*key_array*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_QueryKeyControl(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*key_id*/,
|
||||
size_t /*key_id_length*/,
|
||||
uint8_t* /*key_control_block*/,
|
||||
size_t* /*key_control_block_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_SelectKey(const OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*key_id*/,
|
||||
size_t /*key_id_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_DecryptCTR(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*data_addr*/, size_t /*data_length*/,
|
||||
bool /*is_encrypted*/, const uint8_t* /*iv*/,
|
||||
size_t /*block_offset*/,
|
||||
const OEMCrypto_DestBufferDesc* /*out_buffer*/,
|
||||
uint8_t /*subsample_flags*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_CopyBuffer(const uint8_t */*data_addr*/,
|
||||
size_t /*data_length*/,
|
||||
OEMCrypto_DestBufferDesc* /*out_buffer*/,
|
||||
uint8_t /*subsample_flags*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_WrapKeybox(const uint8_t* /*keybox*/,
|
||||
size_t /*keyBoxLength*/,
|
||||
uint8_t* /*wrappedKeybox*/,
|
||||
size_t* /*wrappedKeyBoxLength*/,
|
||||
const uint8_t* /*transportKey*/,
|
||||
size_t /*transportKeyLength*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_InstallKeybox(const uint8_t* /*keybox*/,
|
||||
size_t /*keyBoxLength*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_LoadTestKeybox() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_IsKeyboxValid(void) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetDeviceID(uint8_t* /*deviceID*/, size_t* /*idLength*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetKeyData(uint8_t* /*keyData*/,
|
||||
size_t* /*keyDataLength*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetRandom(uint8_t* /*randomData*/, size_t /*dataLength*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_RewrapDeviceRSAKey(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*message*/,
|
||||
size_t /*message_length*/,
|
||||
const uint8_t* /*signature*/,
|
||||
size_t /*signature_length*/,
|
||||
const uint32_t* /*nonce*/,
|
||||
const uint8_t* /*enc_rsa_key*/,
|
||||
size_t /*enc_rsa_key_length*/,
|
||||
const uint8_t* /*enc_rsa_key_iv*/,
|
||||
uint8_t* /*wrapped_rsa_key*/,
|
||||
size_t* /*wrapped_rsa_key_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_LoadDeviceRSAKey(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*wrapped_rsa_key*/,
|
||||
size_t /*wrapped_rsa_key_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_LoadTestRSAKey() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GenerateRSASignature(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*message*/,
|
||||
size_t /*message_length*/,
|
||||
uint8_t* /*signature*/,
|
||||
size_t* /*signature_length*/,
|
||||
RSA_Padding_Scheme /*padding_scheme*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_DeriveKeysFromSessionKey(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*enc_session_key*/,
|
||||
size_t /*enc_session_key_length*/,
|
||||
const uint8_t* /*mac_key_context*/,
|
||||
size_t /*mac_key_context_length*/,
|
||||
const uint8_t* /*enc_key_context*/,
|
||||
size_t /*enc_key_context_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
uint32_t Level3_APIVersion() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
const char* Level3_SecurityLevel() {
|
||||
return "L3";
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetHDCPCapability(OEMCrypto_HDCP_Capability */*current*/,
|
||||
OEMCrypto_HDCP_Capability */*maximum*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
bool Level3_SupportsUsageTable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Level3_IsAntiRollbackHwPresent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetNumberOfOpenSessions(size_t* /*count*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_GetMaxNumberOfSessions(size_t* /*maximum*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_Generic_Encrypt(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*in_buffer*/,
|
||||
size_t /*buffer_length*/,
|
||||
const uint8_t* /*iv*/,
|
||||
OEMCrypto_Algorithm /*algorithm*/,
|
||||
uint8_t* /*out_buffer*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_Generic_Decrypt(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*in_buffer*/,
|
||||
size_t /*buffer_length*/,
|
||||
const uint8_t* /*iv*/,
|
||||
OEMCrypto_Algorithm /*algorithm*/,
|
||||
uint8_t* /*out_buffer*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_Generic_Sign(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*in_buffer*/,
|
||||
size_t /*buffer_length*/,
|
||||
OEMCrypto_Algorithm /*algorithm*/,
|
||||
uint8_t* /*signature*/,
|
||||
size_t* /*signature_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_Generic_Verify(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*in_buffer*/,
|
||||
size_t /*buffer_length*/,
|
||||
OEMCrypto_Algorithm /*algorithm*/,
|
||||
const uint8_t* /*signature*/,
|
||||
size_t /*signature_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_UpdateUsageTable() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_DeactivateUsageEntry(const uint8_t */*pst*/,
|
||||
size_t /*pst_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_ReportUsage(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*pst*/, size_t /*pst_length*/,
|
||||
OEMCrypto_PST_Report* /*buffer*/,
|
||||
size_t* /*buffer_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_DeleteUsageEntry(OEMCrypto_SESSION /*session*/,
|
||||
const uint8_t* /*pst*/,
|
||||
size_t /*pst_length*/,
|
||||
const uint8_t */*message*/,
|
||||
size_t /*message_length*/,
|
||||
const uint8_t */*signature*/,
|
||||
size_t /*signature_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_ForceDeleteUsageEntry(const uint8_t* /*pst*/,
|
||||
size_t /*pst_length*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Level3_DeleteUsageTable() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Tool_FieldProvision() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Tool_SaveKeybox() {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
OEMCryptoResult Tool_MakePad(uint8_t* /*preprov*/, uint8_t* /*pad*/) {
|
||||
return OEMCrypto_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
} // namespace wvoec3
|
||||
Binary file not shown.
@@ -1369,8 +1369,14 @@ OEMCryptoResult SessionContext::DecryptCTR(
|
||||
}
|
||||
|
||||
// Local copy (will be modified).
|
||||
uint8_t aes_iv[AES_BLOCK_SIZE];
|
||||
memcpy(aes_iv, &iv[0], AES_BLOCK_SIZE);
|
||||
// Allocated as 64-bit ints to enforce 64-bit alignment for later access as a
|
||||
// 64-bit value.
|
||||
uint64_t aes_iv[2];
|
||||
assert(sizeof(aes_iv) == AES_BLOCK_SIZE);
|
||||
// The double-cast is needed to comply with strict aliasing rules.
|
||||
uint8_t *aes_iv_u8 =
|
||||
reinterpret_cast<uint8_t*>(reinterpret_cast<void*>(aes_iv));
|
||||
memcpy(aes_iv_u8, &iv[0], AES_BLOCK_SIZE);
|
||||
|
||||
// The CENC spec specifies we increment only the low 64 bits of the IV
|
||||
// counter, and leave the high 64 bits alone. This is different from the
|
||||
@@ -1387,12 +1393,12 @@ OEMCryptoResult SessionContext::DecryptCTR(
|
||||
LOGE("[DecryptCTR(): FAILURE]");
|
||||
return OEMCrypto_ERROR_DECRYPT_FAILED;
|
||||
}
|
||||
AES_encrypt(aes_iv, ecount_buf, &aes_key);
|
||||
AES_encrypt(aes_iv_u8, ecount_buf, &aes_key);
|
||||
for (int n = block_offset; n < AES_BLOCK_SIZE && l < cipher_data_length;
|
||||
++n, ++l) {
|
||||
clear_data[l] = cipher_data[l] ^ ecount_buf[n];
|
||||
}
|
||||
ctr128_inc64(aes_iv);
|
||||
ctr128_inc64(aes_iv_u8);
|
||||
block_offset = 0;
|
||||
}
|
||||
|
||||
@@ -1403,7 +1409,7 @@ OEMCryptoResult SessionContext::DecryptCTR(
|
||||
EVP_CIPHER_CTX ctx;
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
EVP_CIPHER_CTX_set_padding(&ctx, 0);
|
||||
if (!EVP_DecryptInit_ex(&ctx, EVP_aes_128_ctr(), NULL, key_u8, aes_iv)) {
|
||||
if (!EVP_DecryptInit_ex(&ctx, EVP_aes_128_ctr(), NULL, key_u8, aes_iv_u8)) {
|
||||
LOGE("[DecryptCTR(): EVP_INIT ERROR]");
|
||||
return OEMCrypto_ERROR_DECRYPT_FAILED;
|
||||
}
|
||||
@@ -1412,9 +1418,9 @@ OEMCryptoResult SessionContext::DecryptCTR(
|
||||
// value is 0xFF the counter is near wrapping. In this case we calculate
|
||||
// the number of bytes we can safely decrypt before the counter wraps.
|
||||
uint64_t decrypt_length = 0;
|
||||
if (aes_iv[8] == 0xFF) {
|
||||
uint64_t bytes_before_iv_wrap = (~wvcdm::ntohll64(
|
||||
*reinterpret_cast<uint64_t*>(&aes_iv[8])) + 1) * AES_BLOCK_SIZE;
|
||||
if (aes_iv_u8[8] == 0xFF) {
|
||||
uint64_t bottom_64_bits = wvcdm::ntohll64(aes_iv[1]);
|
||||
uint64_t bytes_before_iv_wrap = (~bottom_64_bits + 1) * AES_BLOCK_SIZE;
|
||||
decrypt_length =
|
||||
bytes_before_iv_wrap < remaining ? bytes_before_iv_wrap : remaining;
|
||||
} else {
|
||||
@@ -1439,8 +1445,8 @@ OEMCryptoResult SessionContext::DecryptCTR(
|
||||
|
||||
// If remaining is not zero, reset the iv before the second pass.
|
||||
if (remaining) {
|
||||
memcpy(aes_iv, &iv[0], AES_BLOCK_SIZE);
|
||||
memset(&aes_iv[8], 0, AES_BLOCK_SIZE / 2);
|
||||
memcpy(aes_iv_u8, &iv[0], AES_BLOCK_SIZE);
|
||||
memset(&aes_iv_u8[8], 0, AES_BLOCK_SIZE / 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
ifneq ($(TARGET_ARCH),mips)
|
||||
|
||||
ifeq ($(filter mips mips64, $(TARGET_ARCH)),)
|
||||
# Tests need to be compatible with devices that do not support gnu hash-style
|
||||
LOCAL_LDFLAGS+=-Wl,--hash-style=both
|
||||
|
||||
endif
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
|
||||
@@ -359,239 +359,6 @@ static const uint8_t kTestRSAPKCS8PrivateKeyInfo2_2048[] = {
|
||||
0x72, 0x2c, 0xf7, 0xc1, 0x22, 0x36, 0xd9, 0x18,
|
||||
0x56, 0xfe, 0x39, 0x28, 0x33, 0xe0, 0xdb, 0x03 };
|
||||
|
||||
// A 2048 bit RSA Public key
|
||||
// Used to verify the functions that manipulate RSA keys.
|
||||
static const uint8_t kTestRSAPublicKey2_2048[] = {
|
||||
0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01,
|
||||
0x00, 0xa7, 0x00, 0x36, 0x60, 0x65, 0xdc, 0xbd,
|
||||
0x54, 0x5a, 0x2a, 0x40, 0xb4, 0xe1, 0x15, 0x94,
|
||||
0x58, 0x11, 0x4f, 0x94, 0x58, 0xdd, 0xde, 0xa7,
|
||||
0x1f, 0x3c, 0x2c, 0xe0, 0x88, 0x09, 0x29, 0x61,
|
||||
0x57, 0x67, 0x5e, 0x56, 0x7e, 0xee, 0x27, 0x8f,
|
||||
0x59, 0x34, 0x9a, 0x2a, 0xaa, 0x9d, 0xb4, 0x4e,
|
||||
0xfa, 0xa7, 0x6a, 0xd4, 0xc9, 0x7a, 0x53, 0xc1,
|
||||
0x4e, 0x9f, 0xe3, 0x34, 0xf7, 0x3d, 0xb7, 0xc9,
|
||||
0x10, 0x47, 0x4f, 0x28, 0xda, 0x3f, 0xce, 0x31,
|
||||
0x7b, 0xfd, 0x06, 0x10, 0xeb, 0xf7, 0xbe, 0x92,
|
||||
0xf9, 0xaf, 0xfb, 0x3e, 0x68, 0xda, 0xee, 0x1a,
|
||||
0x64, 0x4c, 0xf3, 0x29, 0xf2, 0x73, 0x9e, 0x39,
|
||||
0xd8, 0xf6, 0x6f, 0xd8, 0xb2, 0x80, 0x82, 0x71,
|
||||
0x8e, 0xb5, 0xa4, 0xf2, 0xc2, 0x3e, 0xcd, 0x0a,
|
||||
0xca, 0xb6, 0x04, 0xcd, 0x9a, 0x13, 0x8b, 0x54,
|
||||
0x73, 0x54, 0x25, 0x54, 0x8c, 0xbe, 0x98, 0x7a,
|
||||
0x67, 0xad, 0xda, 0xb3, 0x4e, 0xb3, 0xfa, 0x82,
|
||||
0xa8, 0x4a, 0x67, 0x98, 0x56, 0x57, 0x54, 0x71,
|
||||
0xcd, 0x12, 0x7f, 0xed, 0xa3, 0x01, 0xc0, 0x6a,
|
||||
0x8b, 0x24, 0x03, 0x96, 0x88, 0xbe, 0x97, 0x66,
|
||||
0x2a, 0xbc, 0x53, 0xc9, 0x83, 0x06, 0x51, 0x5a,
|
||||
0x88, 0x65, 0x13, 0x18, 0xe4, 0x3a, 0xed, 0x6b,
|
||||
0xf1, 0x61, 0x5b, 0x4c, 0xc8, 0x1e, 0xf4, 0xc2,
|
||||
0xae, 0x08, 0x5e, 0x2d, 0x5f, 0xf8, 0x12, 0x7f,
|
||||
0xa2, 0xfc, 0xbb, 0x21, 0x18, 0x30, 0xda, 0xfe,
|
||||
0x40, 0xfb, 0x01, 0xca, 0x2e, 0x37, 0x0e, 0xce,
|
||||
0xdd, 0x76, 0x87, 0x82, 0x46, 0x0b, 0x3a, 0x77,
|
||||
0x8f, 0xc0, 0x72, 0x07, 0x2c, 0x7f, 0x9d, 0x1e,
|
||||
0x86, 0x5b, 0xed, 0x27, 0x29, 0xdf, 0x03, 0x97,
|
||||
0x62, 0xef, 0x44, 0xd3, 0x5b, 0x3d, 0xdb, 0x9c,
|
||||
0x5e, 0x1b, 0x7b, 0x39, 0xb4, 0x0b, 0x6d, 0x04,
|
||||
0x6b, 0xbb, 0xbb, 0x2c, 0x5f, 0xcf, 0xb3, 0x7a,
|
||||
0x05, 0x02, 0x03, 0x01, 0x00, 0x01 };
|
||||
|
||||
// A second 2048 bit RSA key in PKCS#8 PrivateKeyInfo format
|
||||
// Used to verify the functions that manipulate RSA keys.
|
||||
static const uint8_t kTestRSAPKCS8PrivateKeyInfo3_2048[] = {
|
||||
0x30, 0x82, 0x04, 0xbe, 0x02, 0x01, 0x00, 0x30,
|
||||
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
|
||||
0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82,
|
||||
0x04, 0xa8, 0x30, 0x82, 0x04, 0xa4, 0x02, 0x01,
|
||||
0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xa5, 0xd0,
|
||||
0xd7, 0x3e, 0x0e, 0x2d, 0xfb, 0x43, 0x51, 0x99,
|
||||
0xea, 0x40, 0x1e, 0x2d, 0x89, 0xe4, 0xa2, 0x3e,
|
||||
0xfc, 0x51, 0x3d, 0x0e, 0x83, 0xa7, 0xe0, 0xa5,
|
||||
0x41, 0x04, 0x1e, 0x14, 0xc5, 0xa7, 0x5c, 0x61,
|
||||
0x36, 0x44, 0xb3, 0x08, 0x05, 0x5b, 0x14, 0xde,
|
||||
0x01, 0x0c, 0x32, 0x3c, 0x9a, 0x91, 0x00, 0x50,
|
||||
0xa8, 0x1d, 0xcc, 0x9f, 0x8f, 0x35, 0xb7, 0xc2,
|
||||
0x75, 0x08, 0x32, 0x8b, 0x10, 0x3a, 0x86, 0xf9,
|
||||
0xd7, 0x78, 0xa3, 0x9d, 0x74, 0x10, 0xc6, 0x24,
|
||||
0xb1, 0x7f, 0xa5, 0xbf, 0x5f, 0xc2, 0xd7, 0x15,
|
||||
0xa3, 0x1d, 0xe0, 0x15, 0x6b, 0x1b, 0x0e, 0x38,
|
||||
0xba, 0x34, 0xbc, 0x95, 0x47, 0x94, 0x40, 0x70,
|
||||
0xac, 0x99, 0x1f, 0x0b, 0x8e, 0x56, 0x93, 0x36,
|
||||
0x2b, 0x6d, 0x04, 0xe7, 0x95, 0x1a, 0x37, 0xda,
|
||||
0x16, 0x57, 0x99, 0xee, 0x03, 0x68, 0x16, 0x31,
|
||||
0xaa, 0xc3, 0xb7, 0x92, 0x75, 0x53, 0xfc, 0xf6,
|
||||
0x20, 0x55, 0x44, 0xf8, 0xd4, 0x8d, 0x78, 0x15,
|
||||
0xc7, 0x1a, 0xb6, 0xde, 0x6c, 0xe8, 0x49, 0x5d,
|
||||
0xaf, 0xa8, 0x4e, 0x6f, 0x7c, 0xe2, 0x6a, 0x4c,
|
||||
0xd5, 0xe7, 0x8c, 0x8f, 0x0b, 0x5d, 0x3a, 0x09,
|
||||
0xd6, 0xb3, 0x44, 0xab, 0xe0, 0x35, 0x52, 0x7c,
|
||||
0x66, 0x85, 0xa4, 0x40, 0xd7, 0x20, 0xec, 0x24,
|
||||
0x05, 0x06, 0xd9, 0x84, 0x51, 0x5a, 0xd2, 0x38,
|
||||
0xd5, 0x1d, 0xea, 0x70, 0x2a, 0x21, 0xe6, 0x82,
|
||||
0xfd, 0xa4, 0x46, 0x1c, 0x4f, 0x59, 0x6e, 0x29,
|
||||
0x3d, 0xae, 0xb8, 0x8e, 0xee, 0x77, 0x1f, 0x15,
|
||||
0x33, 0xcf, 0x94, 0x1d, 0x87, 0x3c, 0x37, 0xc5,
|
||||
0x89, 0xe8, 0x7d, 0x85, 0xb3, 0xbc, 0xe8, 0x62,
|
||||
0x6a, 0x84, 0x7f, 0xfe, 0x9a, 0x85, 0x3f, 0x39,
|
||||
0xe8, 0xaa, 0x16, 0xa6, 0x8f, 0x87, 0x7f, 0xcb,
|
||||
0xc1, 0xd6, 0xf2, 0xec, 0x2b, 0xa7, 0xdd, 0x49,
|
||||
0x98, 0x7b, 0x6f, 0xdd, 0x69, 0x6d, 0x02, 0x03,
|
||||
0x01, 0x00, 0x01, 0x02, 0x82, 0x01, 0x00, 0x43,
|
||||
0x8f, 0x19, 0x83, 0xb1, 0x27, 0x4e, 0xee, 0x98,
|
||||
0xba, 0xcb, 0x54, 0xa0, 0x77, 0x11, 0x6d, 0xd4,
|
||||
0x25, 0x31, 0x8c, 0xb0, 0x01, 0xcf, 0xe6, 0x80,
|
||||
0x83, 0x14, 0x40, 0x67, 0x39, 0x33, 0x67, 0x03,
|
||||
0x1e, 0xa0, 0x8b, 0xd1, 0x1d, 0xfd, 0x80, 0xa4,
|
||||
0xb9, 0xe7, 0x57, 0x5e, 0xc8, 0x8e, 0x79, 0x71,
|
||||
0xd5, 0x6b, 0x09, 0xe9, 0x2b, 0x41, 0xa0, 0x33,
|
||||
0x64, 0xc9, 0x66, 0x33, 0xa1, 0xb1, 0x55, 0x07,
|
||||
0x55, 0x98, 0x53, 0x10, 0xe6, 0xc0, 0x39, 0x6d,
|
||||
0x61, 0xd9, 0xe8, 0x16, 0x52, 0x28, 0xe4, 0x2b,
|
||||
0xda, 0x27, 0x01, 0xaf, 0x21, 0x4a, 0xe8, 0x55,
|
||||
0x1d, 0x0b, 0xd1, 0x1c, 0xdc, 0xfd, 0xb3, 0x0b,
|
||||
0xa6, 0x5c, 0xcc, 0x6e, 0x77, 0xb8, 0xe0, 0xd1,
|
||||
0x4e, 0x0a, 0xd7, 0x7a, 0x5e, 0x18, 0xc3, 0xfb,
|
||||
0xe9, 0xa1, 0x9c, 0xc3, 0x9c, 0xd4, 0x4a, 0x7e,
|
||||
0x70, 0x72, 0x11, 0x18, 0x24, 0x56, 0x24, 0xdf,
|
||||
0xf8, 0xba, 0xac, 0x5b, 0x54, 0xd3, 0xc4, 0x65,
|
||||
0x69, 0xc8, 0x79, 0x94, 0x16, 0x88, 0x9a, 0x68,
|
||||
0x1c, 0xbc, 0xd4, 0xca, 0xec, 0x5e, 0x07, 0x4a,
|
||||
0xc9, 0x54, 0x7a, 0x4b, 0xdb, 0x19, 0x88, 0xf6,
|
||||
0xbe, 0x50, 0x9d, 0x9e, 0x9d, 0x88, 0x5b, 0x4a,
|
||||
0x23, 0x86, 0x2b, 0xa9, 0xa6, 0x6c, 0x70, 0x7d,
|
||||
0xe1, 0x11, 0xba, 0xbf, 0x03, 0x2e, 0xf1, 0x46,
|
||||
0x7e, 0x1b, 0xed, 0x06, 0x11, 0x57, 0xad, 0x4a,
|
||||
0xcb, 0xe5, 0xb1, 0x11, 0x05, 0x0a, 0x30, 0xb1,
|
||||
0x73, 0x79, 0xcd, 0x7a, 0x04, 0xcc, 0x70, 0xe9,
|
||||
0x95, 0xe4, 0x27, 0xc2, 0xd5, 0x2d, 0x92, 0x44,
|
||||
0xdf, 0xb4, 0x94, 0xa8, 0x73, 0xa1, 0x4a, 0xc3,
|
||||
0xcc, 0xc4, 0x0e, 0x8d, 0xa1, 0x6a, 0xc2, 0xd8,
|
||||
0x03, 0x7f, 0xfa, 0xa7, 0x76, 0x0d, 0xad, 0x87,
|
||||
0x88, 0xa0, 0x77, 0xaf, 0x3b, 0x23, 0xd1, 0x66,
|
||||
0x0b, 0x31, 0x2b, 0xaf, 0xef, 0xd5, 0x41, 0x02,
|
||||
0x81, 0x81, 0x00, 0xdb, 0xc1, 0xe7, 0xdd, 0xba,
|
||||
0x3c, 0x1f, 0x9c, 0x64, 0xca, 0xa0, 0x63, 0xdb,
|
||||
0xd2, 0x47, 0x5c, 0x6e, 0x8a, 0xa3, 0x16, 0xd5,
|
||||
0xda, 0xc2, 0x25, 0x64, 0x0a, 0x02, 0xbc, 0x7d,
|
||||
0x7f, 0x50, 0xab, 0xe0, 0x66, 0x03, 0x53, 0x7d,
|
||||
0x77, 0x6d, 0x6c, 0x61, 0x58, 0x09, 0x73, 0xcd,
|
||||
0x18, 0xe9, 0x53, 0x0b, 0x5c, 0xa2, 0x71, 0x14,
|
||||
0x02, 0xfd, 0x55, 0xda, 0xe9, 0x77, 0x24, 0x7c,
|
||||
0x2a, 0x4e, 0xb9, 0xd9, 0x5d, 0x58, 0xf6, 0x26,
|
||||
0xd0, 0xd8, 0x3d, 0xcf, 0x8c, 0x89, 0x65, 0x6c,
|
||||
0x35, 0x19, 0xb6, 0x63, 0xff, 0xa0, 0x71, 0x49,
|
||||
0xcd, 0x6d, 0x5b, 0x3d, 0x8f, 0xea, 0x6f, 0xa9,
|
||||
0xba, 0x43, 0xe5, 0xdd, 0x39, 0x3a, 0x78, 0x8f,
|
||||
0x07, 0xb8, 0xab, 0x58, 0x07, 0xb7, 0xd2, 0xf8,
|
||||
0x07, 0x02, 0x9b, 0x79, 0x26, 0x32, 0x22, 0x38,
|
||||
0x91, 0x01, 0x90, 0x81, 0x29, 0x94, 0xad, 0x77,
|
||||
0xeb, 0x86, 0xb9, 0x02, 0x81, 0x81, 0x00, 0xc1,
|
||||
0x29, 0x88, 0xbd, 0x96, 0x31, 0x33, 0x7b, 0x77,
|
||||
0x5d, 0x32, 0x12, 0x5e, 0xdf, 0x28, 0x0c, 0x96,
|
||||
0x0d, 0xa8, 0x22, 0xdf, 0xd3, 0x35, 0xd7, 0xb0,
|
||||
0x41, 0xcb, 0xe7, 0x94, 0x8a, 0xa4, 0xed, 0xd2,
|
||||
0xfb, 0xd2, 0xf3, 0xf2, 0x95, 0xff, 0xd8, 0x33,
|
||||
0x3f, 0x8c, 0xd7, 0x65, 0xe4, 0x0c, 0xcc, 0xfe,
|
||||
0x32, 0x66, 0xfa, 0x50, 0xe2, 0xcf, 0xf0, 0xbe,
|
||||
0x05, 0xb1, 0xbc, 0xbe, 0x44, 0x09, 0xb4, 0xfe,
|
||||
0x95, 0x06, 0x18, 0xd7, 0x59, 0xc6, 0xef, 0x2d,
|
||||
0x22, 0xa0, 0x73, 0x5e, 0x77, 0xdf, 0x8d, 0x09,
|
||||
0x2c, 0xb8, 0xcc, 0xeb, 0x10, 0x4d, 0xa7, 0xd0,
|
||||
0x4b, 0x46, 0xba, 0x7d, 0x8b, 0x6a, 0x55, 0x47,
|
||||
0x55, 0xd3, 0xd7, 0xb1, 0x88, 0xfd, 0x27, 0x3e,
|
||||
0xf9, 0x5b, 0x7b, 0xae, 0x6d, 0x08, 0x9f, 0x0c,
|
||||
0x2a, 0xe1, 0xdd, 0xb9, 0xe3, 0x55, 0x13, 0x55,
|
||||
0xa3, 0x6d, 0x06, 0xbb, 0xe0, 0x1e, 0x55, 0x02,
|
||||
0x81, 0x80, 0x61, 0x73, 0x3d, 0x64, 0xff, 0xdf,
|
||||
0x05, 0x8d, 0x8e, 0xcc, 0xa4, 0x0f, 0x64, 0x3d,
|
||||
0x7d, 0x53, 0xa9, 0xd9, 0x64, 0xb5, 0x0d, 0xa4,
|
||||
0x72, 0x8f, 0xae, 0x2b, 0x1a, 0x47, 0x87, 0xc7,
|
||||
0x5b, 0x78, 0xbc, 0x8b, 0xc0, 0x51, 0xd7, 0xc3,
|
||||
0x8c, 0x0c, 0x91, 0xa6, 0x3e, 0x9a, 0xd1, 0x8a,
|
||||
0x88, 0x7d, 0x40, 0xfe, 0x95, 0x32, 0x5b, 0xd3,
|
||||
0x6f, 0x90, 0x11, 0x01, 0x92, 0xc9, 0xe5, 0x1d,
|
||||
0xc5, 0xc7, 0x78, 0x72, 0x82, 0xae, 0xb5, 0x4b,
|
||||
0xcb, 0x78, 0xad, 0x7e, 0xfe, 0xb6, 0xb1, 0x23,
|
||||
0x63, 0x01, 0x94, 0x9a, 0x99, 0x05, 0x63, 0xda,
|
||||
0xea, 0xf1, 0x98, 0xfd, 0x26, 0xd2, 0xd9, 0x8b,
|
||||
0x35, 0xec, 0xcb, 0x0b, 0x43, 0xb8, 0x8e, 0x84,
|
||||
0xb8, 0x09, 0x93, 0x81, 0xe8, 0xac, 0x6f, 0x3c,
|
||||
0x7c, 0x95, 0x81, 0x45, 0xc4, 0xd9, 0x94, 0x08,
|
||||
0x09, 0x8f, 0x91, 0x17, 0x65, 0x4c, 0xff, 0x6e,
|
||||
0xbc, 0x51, 0x02, 0x81, 0x81, 0x00, 0xc1, 0x0d,
|
||||
0x9d, 0xd8, 0xbd, 0xaf, 0x56, 0xe0, 0xe3, 0x1f,
|
||||
0x85, 0xd7, 0xce, 0x72, 0x02, 0x38, 0xf2, 0x0f,
|
||||
0x9c, 0x27, 0x9e, 0xc4, 0x1d, 0x60, 0x00, 0x8d,
|
||||
0x02, 0x19, 0xe5, 0xdf, 0xdb, 0x8e, 0xc5, 0xfb,
|
||||
0x61, 0x8e, 0xe6, 0xb8, 0xfc, 0x07, 0x3c, 0xd1,
|
||||
0x1b, 0x16, 0x7c, 0x83, 0x3c, 0x37, 0xf5, 0x26,
|
||||
0xb2, 0xbd, 0x22, 0xf2, 0x4d, 0x19, 0x33, 0x11,
|
||||
0xc5, 0xdd, 0xf9, 0xdb, 0x4e, 0x48, 0x52, 0xd8,
|
||||
0xe6, 0x4b, 0x15, 0x90, 0x68, 0xbe, 0xca, 0xc1,
|
||||
0x7c, 0xd3, 0x51, 0x6b, 0x45, 0x46, 0x54, 0x11,
|
||||
0x1a, 0x71, 0xd3, 0xcd, 0x6b, 0x8f, 0x79, 0x22,
|
||||
0x83, 0x02, 0x08, 0x4f, 0xba, 0x6a, 0x98, 0xed,
|
||||
0x32, 0xd8, 0xb4, 0x5b, 0x51, 0x88, 0x53, 0xec,
|
||||
0x2c, 0x7e, 0xa4, 0x89, 0xdc, 0xbf, 0xf9, 0x0d,
|
||||
0x32, 0xc8, 0xc3, 0xec, 0x6d, 0x2e, 0xf1, 0xbc,
|
||||
0x70, 0x4e, 0xf6, 0x9e, 0xbc, 0x31, 0x02, 0x81,
|
||||
0x81, 0x00, 0xd3, 0x35, 0x1b, 0x19, 0x75, 0x3f,
|
||||
0x61, 0xf2, 0x55, 0x03, 0xce, 0x25, 0xa9, 0xdf,
|
||||
0x0c, 0x0a, 0x3b, 0x47, 0x42, 0xdc, 0x38, 0x4b,
|
||||
0x13, 0x4d, 0x1f, 0x86, 0x58, 0x4f, 0xd8, 0xee,
|
||||
0xfa, 0x76, 0x15, 0xfb, 0x6e, 0x55, 0x31, 0xf2,
|
||||
0xd2, 0x62, 0x32, 0xa5, 0xc4, 0x23, 0x5e, 0x08,
|
||||
0xa9, 0x83, 0x07, 0xac, 0x8c, 0xa3, 0x7e, 0x18,
|
||||
0xc0, 0x1c, 0x57, 0x63, 0x8d, 0x05, 0x17, 0x47,
|
||||
0x1b, 0xd3, 0x74, 0x73, 0x20, 0x04, 0xfb, 0xc8,
|
||||
0x1a, 0x43, 0x04, 0x36, 0xc8, 0x19, 0xbe, 0xdc,
|
||||
0xa6, 0xe5, 0x0f, 0x25, 0x62, 0x24, 0x96, 0x92,
|
||||
0xb6, 0xb3, 0x97, 0xad, 0x57, 0x9a, 0x90, 0x37,
|
||||
0x4e, 0x31, 0x44, 0x74, 0xfa, 0x7c, 0xb4, 0xea,
|
||||
0xfc, 0x15, 0xa7, 0xb0, 0x51, 0xcc, 0xee, 0x1e,
|
||||
0xed, 0x5b, 0x98, 0x18, 0x0e, 0x65, 0xb6, 0x4b,
|
||||
0x69, 0x0b, 0x21, 0xdc, 0x86, 0x17, 0x6e, 0xc8,
|
||||
0xee, 0x24 };
|
||||
|
||||
// A second 2048 bit RSA Public key
|
||||
// Used to verify the functions that manipulate RSA keys.
|
||||
static const uint8_t kTestRSAPublicKey3_2048[] = {
|
||||
0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01,
|
||||
0x00, 0xa5, 0xd0, 0xd7, 0x3e, 0x0e, 0x2d, 0xfb,
|
||||
0x43, 0x51, 0x99, 0xea, 0x40, 0x1e, 0x2d, 0x89,
|
||||
0xe4, 0xa2, 0x3e, 0xfc, 0x51, 0x3d, 0x0e, 0x83,
|
||||
0xa7, 0xe0, 0xa5, 0x41, 0x04, 0x1e, 0x14, 0xc5,
|
||||
0xa7, 0x5c, 0x61, 0x36, 0x44, 0xb3, 0x08, 0x05,
|
||||
0x5b, 0x14, 0xde, 0x01, 0x0c, 0x32, 0x3c, 0x9a,
|
||||
0x91, 0x00, 0x50, 0xa8, 0x1d, 0xcc, 0x9f, 0x8f,
|
||||
0x35, 0xb7, 0xc2, 0x75, 0x08, 0x32, 0x8b, 0x10,
|
||||
0x3a, 0x86, 0xf9, 0xd7, 0x78, 0xa3, 0x9d, 0x74,
|
||||
0x10, 0xc6, 0x24, 0xb1, 0x7f, 0xa5, 0xbf, 0x5f,
|
||||
0xc2, 0xd7, 0x15, 0xa3, 0x1d, 0xe0, 0x15, 0x6b,
|
||||
0x1b, 0x0e, 0x38, 0xba, 0x34, 0xbc, 0x95, 0x47,
|
||||
0x94, 0x40, 0x70, 0xac, 0x99, 0x1f, 0x0b, 0x8e,
|
||||
0x56, 0x93, 0x36, 0x2b, 0x6d, 0x04, 0xe7, 0x95,
|
||||
0x1a, 0x37, 0xda, 0x16, 0x57, 0x99, 0xee, 0x03,
|
||||
0x68, 0x16, 0x31, 0xaa, 0xc3, 0xb7, 0x92, 0x75,
|
||||
0x53, 0xfc, 0xf6, 0x20, 0x55, 0x44, 0xf8, 0xd4,
|
||||
0x8d, 0x78, 0x15, 0xc7, 0x1a, 0xb6, 0xde, 0x6c,
|
||||
0xe8, 0x49, 0x5d, 0xaf, 0xa8, 0x4e, 0x6f, 0x7c,
|
||||
0xe2, 0x6a, 0x4c, 0xd5, 0xe7, 0x8c, 0x8f, 0x0b,
|
||||
0x5d, 0x3a, 0x09, 0xd6, 0xb3, 0x44, 0xab, 0xe0,
|
||||
0x35, 0x52, 0x7c, 0x66, 0x85, 0xa4, 0x40, 0xd7,
|
||||
0x20, 0xec, 0x24, 0x05, 0x06, 0xd9, 0x84, 0x51,
|
||||
0x5a, 0xd2, 0x38, 0xd5, 0x1d, 0xea, 0x70, 0x2a,
|
||||
0x21, 0xe6, 0x82, 0xfd, 0xa4, 0x46, 0x1c, 0x4f,
|
||||
0x59, 0x6e, 0x29, 0x3d, 0xae, 0xb8, 0x8e, 0xee,
|
||||
0x77, 0x1f, 0x15, 0x33, 0xcf, 0x94, 0x1d, 0x87,
|
||||
0x3c, 0x37, 0xc5, 0x89, 0xe8, 0x7d, 0x85, 0xb3,
|
||||
0xbc, 0xe8, 0x62, 0x6a, 0x84, 0x7f, 0xfe, 0x9a,
|
||||
0x85, 0x3f, 0x39, 0xe8, 0xaa, 0x16, 0xa6, 0x8f,
|
||||
0x87, 0x7f, 0xcb, 0xc1, 0xd6, 0xf2, 0xec, 0x2b,
|
||||
0xa7, 0xdd, 0x49, 0x98, 0x7b, 0x6f, 0xdd, 0x69,
|
||||
0x6d, 0x02, 0x03, 0x01, 0x00, 0x01 };
|
||||
|
||||
DeviceFeatures global_features;
|
||||
|
||||
void DeviceFeatures::Initialize(bool is_cast_receiver, bool force_load_test_keybox) {
|
||||
@@ -1359,7 +1126,8 @@ class Session {
|
||||
int status = RSA_public_encrypt(session_key.size(), &session_key[0],
|
||||
&(enc_session_key->front()), public_rsa_,
|
||||
RSA_PKCS1_OAEP_PADDING);
|
||||
if (static_cast<unsigned>(status) != RSA_size(public_rsa_)) {
|
||||
int size = static_cast<int>(RSA_size(public_rsa_));
|
||||
if (status != size) {
|
||||
cout << "GenerateRSASessionKey error encrypting session key. ";
|
||||
dump_openssl_error();
|
||||
return false;
|
||||
@@ -2444,7 +2212,6 @@ INSTANTIATE_TEST_CASE_P(TestRefreshEachKeys, SessionTestRefreshKeyTest,
|
||||
// Decrypt Tests
|
||||
//
|
||||
TEST_F(OEMCryptoSessionTests, Decrypt) {
|
||||
OEMCryptoResult sts;
|
||||
Session s;
|
||||
s.open();
|
||||
|
||||
@@ -2525,7 +2292,6 @@ TEST_F(OEMCryptoSessionTests, DecryptPerformance) {
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoSessionTests, DecryptZeroDuration) {
|
||||
OEMCryptoResult sts;
|
||||
Session s;
|
||||
s.open();
|
||||
|
||||
@@ -2796,7 +2562,6 @@ TEST_F(OEMCryptoSessionTests, DecryptUnencryptedNoKey) {
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoSessionTests, DecryptSecureToClear) {
|
||||
OEMCryptoResult sts;
|
||||
Session s;
|
||||
s.open();
|
||||
s.GenerateTestSessionKeys();
|
||||
@@ -2808,7 +2573,6 @@ TEST_F(OEMCryptoSessionTests, DecryptSecureToClear) {
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoSessionTests, KeyDuration) {
|
||||
OEMCryptoResult sts;
|
||||
Session s;
|
||||
s.open();
|
||||
s.GenerateTestSessionKeys();
|
||||
@@ -4622,7 +4386,6 @@ TEST_F(GenericCryptoTest, KeyDurationDecrypt) {
|
||||
}
|
||||
|
||||
TEST_F(GenericCryptoTest, KeyDurationSign) {
|
||||
OEMCryptoResult sts;
|
||||
EncryptAndLoadKeys();
|
||||
|
||||
unsigned int key_index = 2;
|
||||
@@ -4655,7 +4418,6 @@ TEST_F(GenericCryptoTest, KeyDurationSign) {
|
||||
}
|
||||
|
||||
TEST_F(GenericCryptoTest, KeyDurationVerify) {
|
||||
OEMCryptoResult sts;
|
||||
EncryptAndLoadKeys();
|
||||
|
||||
unsigned int key_index = 3;
|
||||
|
||||
Reference in New Issue
Block a user