am 5a4134e8: am 67c794ba: Add unit test for empty mac key

* commit '5a4134e85231bccaa3dcf2bffae1d1d5eb2e0501':
  Add unit test for empty mac key
This commit is contained in:
Fred Gylys-Colwell
2013-10-02 14:38:13 -07:00
committed by Android Git Automerger
2 changed files with 28 additions and 12 deletions

View File

@@ -8,9 +8,6 @@ LOCAL_SRC_FILES:= \
LOCAL_MODULE_TAGS := tests
# Define CAN_INSTALL_KEYBOX and the unit test will install a known keybox and test decryption.
LOCAL_CFLAGS += -DCAN_INSTALL_KEYBOX
LOCAL_C_INCLUDES += \
bionic \
external/gtest/include \

View File

@@ -1738,14 +1738,6 @@ TEST_F(OEMCryptoClientTest, GenerateDerivedKeys) {
testTearDown();
}
// Define CAN_INSTALL_KEYBOX if you are compiling with the reference
// implementation of OEMCrypto, or if your version of OEMCrypto supports
// OEMCrypto_InstallKeybox with a clear keybox.
// The Below tests are based on a specific keybox which is installed for testing.
// They are disabled by default. Just because you can install a test keybox,
// does not mean you want to install a test keybox.
#if defined(CAN_INSTALL_KEYBOX)
///////////////////////////////////////////////////
// AddKey Tests
///////////////////////////////////////////////////
@@ -1926,6 +1918,34 @@ TEST_F(DISABLED_TestKeybox, LoadKeyWithNonce) {
testTearDown();
}
TEST_F(DISABLED_TestKeybox, LoadKeyWithNoMAC) {
testSetUp();
InstallKeybox(kDefaultKeybox, true);
Session& s = createSession("ONE");
s.open();
s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0, 0);
MessageData encrypted;
s.EncryptMessage(data, &encrypted);
std::vector<uint8_t> signature;
s.ServerSignMessage(encrypted, &signature);
OEMCrypto_KeyObject key_array[kNumKeys];
const uint8_t* message_ptr = reinterpret_cast<const uint8_t*>(&encrypted);
s.FillKeyArray(encrypted, key_array);
OEMCryptoResult sts = OEMCrypto_LoadKeys(s.session_id(),
message_ptr, sizeof(encrypted),
&signature[0], signature.size(),
NULL, NULL,
kNumKeys, key_array);
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
s.close();
testTearDown();
}
/* The Bad Range tests verify that OEMCrypto_LoadKeys checks the range
of all the pointers. It should reject a message if the pointer does
not point into the message buffer */
@@ -3719,5 +3739,4 @@ TEST_F(DISABLED_GenericDRMTest, KeyDurationVerify) {
s.close();
testTearDown();
}
#endif // CAN_INSTALL_KEYBOX
} // namespace wvoec