Merge "Update unit tests for v15.2" into qt-dev am: 2f79fe2773
am: d0b62c1b8d
Change-Id: I537e6e9c0161084cc0b12a32779fa52c275421cd
This commit is contained in:
@@ -538,6 +538,7 @@ void Session::FillSimpleMessage(uint32_t duration, uint32_t control,
|
||||
uint32_t nonce, const std::string& pst) {
|
||||
EXPECT_EQ(
|
||||
1, GetRandBytes(license_.mac_key_iv, sizeof(license_.mac_key_iv)));
|
||||
memset(license_.padding, 0, sizeof(license_.padding));
|
||||
EXPECT_EQ(1, GetRandBytes(license_.mac_keys, sizeof(license_.mac_keys)));
|
||||
for (unsigned int i = 0; i < num_keys_; i++) {
|
||||
memset(license_.keys[i].key_id, 0, kTestKeyIdMaxLength);
|
||||
|
||||
@@ -81,6 +81,7 @@ typedef struct {
|
||||
struct MessageData {
|
||||
MessageKeyData keys[kMaxNumKeys];
|
||||
uint8_t mac_key_iv[KEY_IV_SIZE];
|
||||
uint8_t padding[KEY_IV_SIZE];
|
||||
uint8_t mac_keys[2 * MAC_KEY_SIZE];
|
||||
uint8_t pst[kMaxPSTLength];
|
||||
};
|
||||
|
||||
@@ -1250,6 +1250,27 @@ TEST_F(OEMCryptoSessionTests, LoadKeyWithBadRange7) {
|
||||
ASSERT_NE(OEMCrypto_SUCCESS, sts);
|
||||
}
|
||||
|
||||
// The IV should not be identical to the data right before the encrypted mac
|
||||
// keys.
|
||||
TEST_F(OEMCryptoSessionTests, LoadKeyWithSuspiciousIV) {
|
||||
Session s;
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(0, 0, 0));
|
||||
// This is suspicious: the data right before the mac keys is identical to the
|
||||
// iv.
|
||||
memcpy(s.license().padding, s.license().mac_key_iv,
|
||||
sizeof(s.license().padding));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
|
||||
OEMCryptoResult sts = OEMCrypto_LoadKeys(
|
||||
s.session_id(), s.message_ptr(), s.message_size(), s.signature().data(),
|
||||
s.signature().size(), s.enc_mac_keys_iv_substr(), s.enc_mac_keys_substr(),
|
||||
s.num_keys(), s.key_array(), GetSubstring(), GetSubstring(),
|
||||
OEMCrypto_ContentLicense);
|
||||
ASSERT_NE(OEMCrypto_SUCCESS, sts);
|
||||
}
|
||||
|
||||
// Test that LoadKeys fails when a key is loaded with no key control block.
|
||||
TEST_F(OEMCryptoSessionTests, LoadKeyWithNullKeyControl) {
|
||||
Session s;
|
||||
|
||||
Reference in New Issue
Block a user