Merge "Modify Code to Work with Clang/C++11"
This commit is contained in:
committed by
Android (Google) Code Review
commit
2057d49b3c
@@ -168,7 +168,8 @@ std::string kOfflineClip2PstInitData = wvcdm::a2bs_hex(
|
|||||||
|
|
||||||
bool StringToInt64(const std::string& input, int64_t* output) {
|
bool StringToInt64(const std::string& input, int64_t* output) {
|
||||||
std::istringstream ss(input);
|
std::istringstream ss(input);
|
||||||
return ss >> *output;
|
ss >> *output;
|
||||||
|
return !ss.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -2068,13 +2068,15 @@ TEST_F(WvCdmRequestLicenseTest, QueryKeyStatus) {
|
|||||||
itr = query_info.find(wvcdm::QUERY_KEY_LICENSE_DURATION_REMAINING);
|
itr = query_info.find(wvcdm::QUERY_KEY_LICENSE_DURATION_REMAINING);
|
||||||
ASSERT_TRUE(itr != query_info.end());
|
ASSERT_TRUE(itr != query_info.end());
|
||||||
ss.str(itr->second);
|
ss.str(itr->second);
|
||||||
ASSERT_TRUE(ss >> remaining_time);
|
ss >> remaining_time;
|
||||||
|
ASSERT_FALSE(ss.fail());
|
||||||
EXPECT_LT(0, remaining_time);
|
EXPECT_LT(0, remaining_time);
|
||||||
itr = query_info.find(wvcdm::QUERY_KEY_PLAYBACK_DURATION_REMAINING);
|
itr = query_info.find(wvcdm::QUERY_KEY_PLAYBACK_DURATION_REMAINING);
|
||||||
ASSERT_TRUE(itr != query_info.end());
|
ASSERT_TRUE(itr != query_info.end());
|
||||||
ss.clear();
|
ss.clear();
|
||||||
ss.str(itr->second);
|
ss.str(itr->second);
|
||||||
ASSERT_TRUE(ss >> remaining_time);
|
ss >> remaining_time;
|
||||||
|
ASSERT_FALSE(ss.fail());
|
||||||
EXPECT_LT(0, remaining_time);
|
EXPECT_LT(0, remaining_time);
|
||||||
|
|
||||||
itr = query_info.find(wvcdm::QUERY_KEY_RENEWAL_SERVER_URL);
|
itr = query_info.find(wvcdm::QUERY_KEY_RENEWAL_SERVER_URL);
|
||||||
@@ -2103,7 +2105,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
|
|||||||
ASSERT_TRUE(itr != query_info.end());
|
ASSERT_TRUE(itr != query_info.end());
|
||||||
std::istringstream ss(itr->second);
|
std::istringstream ss(itr->second);
|
||||||
uint32_t system_id;
|
uint32_t system_id;
|
||||||
EXPECT_TRUE(ss >> system_id);
|
ss >> system_id;
|
||||||
|
ASSERT_FALSE(ss.fail());
|
||||||
EXPECT_TRUE(ss.eof());
|
EXPECT_TRUE(ss.eof());
|
||||||
|
|
||||||
itr = query_info.find(wvcdm::QUERY_KEY_PROVISIONING_ID);
|
itr = query_info.find(wvcdm::QUERY_KEY_PROVISIONING_ID);
|
||||||
@@ -2138,7 +2141,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
|
|||||||
ss.clear();
|
ss.clear();
|
||||||
ss.str(itr->second);
|
ss.str(itr->second);
|
||||||
uint32_t open_sessions;
|
uint32_t open_sessions;
|
||||||
EXPECT_TRUE(ss >> open_sessions);
|
ss >> open_sessions;
|
||||||
|
ASSERT_FALSE(ss.fail());
|
||||||
EXPECT_TRUE(ss.eof());
|
EXPECT_TRUE(ss.eof());
|
||||||
|
|
||||||
itr = query_info.find(QUERY_KEY_MAX_NUMBER_OF_SESSIONS);
|
itr = query_info.find(QUERY_KEY_MAX_NUMBER_OF_SESSIONS);
|
||||||
@@ -2146,7 +2150,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
|
|||||||
ss.clear();
|
ss.clear();
|
||||||
ss.str(itr->second);
|
ss.str(itr->second);
|
||||||
uint32_t max_sessions;
|
uint32_t max_sessions;
|
||||||
EXPECT_TRUE(ss >> max_sessions);
|
ss >> max_sessions;
|
||||||
|
ASSERT_FALSE(ss.fail());
|
||||||
EXPECT_TRUE(ss.eof());
|
EXPECT_TRUE(ss.eof());
|
||||||
EXPECT_LE(open_sessions, max_sessions);
|
EXPECT_LE(open_sessions, max_sessions);
|
||||||
EXPECT_LE(8u, max_sessions);
|
EXPECT_LE(8u, max_sessions);
|
||||||
@@ -2156,7 +2161,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
|
|||||||
ss.clear();
|
ss.clear();
|
||||||
ss.str(itr->second);
|
ss.str(itr->second);
|
||||||
uint32_t api_version;
|
uint32_t api_version;
|
||||||
EXPECT_TRUE(ss >> api_version);
|
ss >> api_version;
|
||||||
|
ASSERT_FALSE(ss.fail());
|
||||||
EXPECT_TRUE(ss.eof());
|
EXPECT_TRUE(ss.eof());
|
||||||
EXPECT_LE(10u, api_version);
|
EXPECT_LE(10u, api_version);
|
||||||
}
|
}
|
||||||
@@ -2181,7 +2187,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatusL3) {
|
|||||||
ASSERT_TRUE(itr != query_info.end());
|
ASSERT_TRUE(itr != query_info.end());
|
||||||
std::istringstream ss(itr->second);
|
std::istringstream ss(itr->second);
|
||||||
uint32_t system_id;
|
uint32_t system_id;
|
||||||
EXPECT_TRUE(ss >> system_id);
|
ss >> system_id;
|
||||||
|
ASSERT_FALSE(ss.fail());
|
||||||
EXPECT_TRUE(ss.eof());
|
EXPECT_TRUE(ss.eof());
|
||||||
|
|
||||||
itr = query_info.find(wvcdm::QUERY_KEY_PROVISIONING_ID);
|
itr = query_info.find(wvcdm::QUERY_KEY_PROVISIONING_ID);
|
||||||
@@ -2198,7 +2205,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatusL3) {
|
|||||||
ASSERT_TRUE(itr != query_info_default.end());
|
ASSERT_TRUE(itr != query_info_default.end());
|
||||||
std::istringstream ss(itr->second);
|
std::istringstream ss(itr->second);
|
||||||
uint32_t default_system_id;
|
uint32_t default_system_id;
|
||||||
EXPECT_TRUE(ss >> system_id);
|
ss >> system_id;
|
||||||
|
ASSERT_FALSE(ss.fail());
|
||||||
EXPECT_TRUE(ss.eof());
|
EXPECT_TRUE(ss.eof());
|
||||||
EXPECT_NE(system_id, default_system_id);
|
EXPECT_NE(system_id, default_system_id);
|
||||||
}
|
}
|
||||||
@@ -2222,7 +2230,8 @@ TEST_F(WvCdmRequestLicenseTest, QueryKeyControlInfo) {
|
|||||||
ASSERT_TRUE(itr != query_info.end());
|
ASSERT_TRUE(itr != query_info.end());
|
||||||
std::istringstream ss;
|
std::istringstream ss;
|
||||||
ss.str(itr->second);
|
ss.str(itr->second);
|
||||||
EXPECT_TRUE(ss >> oem_crypto_session_id);
|
ss >> oem_crypto_session_id;
|
||||||
|
ASSERT_FALSE(ss.fail());
|
||||||
|
|
||||||
decryptor_.CloseSession(session_id_);
|
decryptor_.CloseSession(session_id_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ $(call assert-not-null,test_name)
|
|||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_CLANG := false
|
|
||||||
|
|
||||||
LOCAL_MODULE := $(test_name)
|
LOCAL_MODULE := $(test_name)
|
||||||
LOCAL_MODULE_TAGS := tests
|
LOCAL_MODULE_TAGS := tests
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ LOCAL_PATH:= $(call my-dir)
|
|||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
LOCAL_CLANG := false
|
|
||||||
|
|
||||||
LOCAL_MODULE:=oemcrypto_test
|
LOCAL_MODULE:=oemcrypto_test
|
||||||
LOCAL_MODULE_TAGS := tests
|
LOCAL_MODULE_TAGS := tests
|
||||||
|
|
||||||
|
|||||||
@@ -98,11 +98,6 @@ struct RSAPrivateKeyMessage {
|
|||||||
uint32_t nonce;
|
uint32_t nonce;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PaddedPSTReport {
|
|
||||||
OEMCrypto_PST_Report report;
|
|
||||||
uint8_t padding[256];
|
|
||||||
};
|
|
||||||
|
|
||||||
// These are test keyboxes. They will not be accepted by production systems.
|
// These are test keyboxes. They will not be accepted by production systems.
|
||||||
// By using known keyboxes for these tests, the results for a given set of
|
// By using known keyboxes for these tests, the results for a given set of
|
||||||
// inputs to a test are predictable and can be compared to the actual results.
|
// inputs to a test are predictable and can be compared to the actual results.
|
||||||
@@ -1400,16 +1395,17 @@ class Session {
|
|||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
OEMCryptoResult sts = OEMCrypto_ReportUsage(
|
OEMCryptoResult sts = OEMCrypto_ReportUsage(
|
||||||
session_id(), reinterpret_cast<const uint8_t*>(pst.c_str()),
|
session_id(), reinterpret_cast<const uint8_t*>(pst.c_str()),
|
||||||
pst.length(), &pst_report_.report, &length);
|
pst.length(), pst_report(), &length);
|
||||||
if (expect_success) {
|
if (expect_success) {
|
||||||
ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, sts);
|
ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, sts);
|
||||||
}
|
}
|
||||||
if (sts == OEMCrypto_ERROR_SHORT_BUFFER) {
|
if (sts == OEMCrypto_ERROR_SHORT_BUFFER) {
|
||||||
ASSERT_GE(sizeof(PaddedPSTReport), length);
|
ASSERT_LE(sizeof(OEMCrypto_PST_Report), length);
|
||||||
|
pst_report_buffer_.resize(length);
|
||||||
}
|
}
|
||||||
sts = OEMCrypto_ReportUsage(session_id(),
|
sts = OEMCrypto_ReportUsage(session_id(),
|
||||||
reinterpret_cast<const uint8_t*>(pst.c_str()),
|
reinterpret_cast<const uint8_t*>(pst.c_str()),
|
||||||
pst.length(), &pst_report_.report, &length);
|
pst.length(), pst_report(), &length);
|
||||||
if (!expect_success) {
|
if (!expect_success) {
|
||||||
ASSERT_NE(OEMCrypto_SUCCESS, sts);
|
ASSERT_NE(OEMCrypto_SUCCESS, sts);
|
||||||
return;
|
return;
|
||||||
@@ -1418,16 +1414,19 @@ class Session {
|
|||||||
vector<uint8_t> computed_signature(SHA_DIGEST_LENGTH);
|
vector<uint8_t> computed_signature(SHA_DIGEST_LENGTH);
|
||||||
unsigned int sig_len = SHA_DIGEST_LENGTH;
|
unsigned int sig_len = SHA_DIGEST_LENGTH;
|
||||||
HMAC(EVP_sha1(), &mac_key_client_[0], mac_key_client_.size(),
|
HMAC(EVP_sha1(), &mac_key_client_[0], mac_key_client_.size(),
|
||||||
reinterpret_cast<uint8_t*>(&pst_report_.report) + SHA_DIGEST_LENGTH,
|
reinterpret_cast<uint8_t*>(pst_report()) + SHA_DIGEST_LENGTH,
|
||||||
length - SHA_DIGEST_LENGTH, &computed_signature[0], &sig_len);
|
length - SHA_DIGEST_LENGTH, &computed_signature[0], &sig_len);
|
||||||
EXPECT_EQ(0, memcmp(&computed_signature[0], pst_report_.report.signature,
|
EXPECT_EQ(0, memcmp(&computed_signature[0], pst_report()->signature,
|
||||||
SHA_DIGEST_LENGTH));
|
SHA_DIGEST_LENGTH));
|
||||||
EXPECT_GE(kInactive, pst_report_.report.status);
|
EXPECT_GE(kInactive, pst_report()->status);
|
||||||
EXPECT_GE(kHardwareSecureClock, pst_report_.report.clock_security_level);
|
EXPECT_GE(kHardwareSecureClock, pst_report()->clock_security_level);
|
||||||
EXPECT_EQ(pst.length(), pst_report_.report.pst_length);
|
EXPECT_EQ(pst.length(), pst_report()->pst_length);
|
||||||
EXPECT_EQ(0, memcmp(pst.c_str(), pst_report_.report.pst, pst.length()));
|
EXPECT_EQ(0, memcmp(pst.c_str(), pst_report()->pst, pst.length()));
|
||||||
|
}
|
||||||
|
|
||||||
|
OEMCrypto_PST_Report* pst_report() {
|
||||||
|
return reinterpret_cast<OEMCrypto_PST_Report*>(&pst_report_buffer_[0]);
|
||||||
}
|
}
|
||||||
OEMCrypto_PST_Report* pst_report() { return &pst_report_.report; }
|
|
||||||
|
|
||||||
void DeleteEntry(const std::string& pst) {
|
void DeleteEntry(const std::string& pst) {
|
||||||
uint8_t* pst_ptr = encrypted_license_.pst;
|
uint8_t* pst_ptr = encrypted_license_.pst;
|
||||||
@@ -1462,7 +1461,7 @@ class Session {
|
|||||||
vector<uint8_t> enc_key_;
|
vector<uint8_t> enc_key_;
|
||||||
uint32_t nonce_;
|
uint32_t nonce_;
|
||||||
RSA* public_rsa_;
|
RSA* public_rsa_;
|
||||||
PaddedPSTReport pst_report_;
|
vector<uint8_t> pst_report_buffer_;
|
||||||
MessageData license_;
|
MessageData license_;
|
||||||
MessageData encrypted_license_;
|
MessageData encrypted_license_;
|
||||||
OEMCrypto_KeyObject key_array_[kNumKeys];
|
OEMCrypto_KeyObject key_array_[kNumKeys];
|
||||||
|
|||||||
Reference in New Issue
Block a user