Merge "Test Simultaneous decrypt and remove NULL pointer comparison" into nyc-dev
This commit is contained in:
@@ -357,7 +357,6 @@ bool InitializationData::ConstructWidevineInitData(
|
||||
json_init_data.size());
|
||||
|
||||
// Parse the Json string using jsmn
|
||||
int result = 0;
|
||||
jsmn_parser parser;
|
||||
jsmntok_t tokens[kDefaultNumJsonTokens];
|
||||
jsmn_init(&parser);
|
||||
|
||||
@@ -526,7 +526,7 @@ static void dump_openssl_error() {
|
||||
// is different from the OpenSSL implementation, so we implement the CTR loop
|
||||
// ourselves.
|
||||
void ctr128_inc64(int64_t increaseBy, uint8_t* iv) {
|
||||
ASSERT_TRUE(NULL != iv);
|
||||
ASSERT_NE(static_cast<void*>(NULL), iv);
|
||||
uint64_t* counterBuffer = reinterpret_cast<uint64_t*>(&iv[8]);
|
||||
(*counterBuffer) =
|
||||
wvcdm::htonll64(wvcdm::ntohll64(*counterBuffer) + increaseBy);
|
||||
@@ -877,9 +877,9 @@ class Session {
|
||||
void EncryptCTR(const vector<uint8_t>& in_buffer,const uint8_t *key,
|
||||
const uint8_t* starting_iv,
|
||||
vector<uint8_t>* out_buffer) {
|
||||
ASSERT_TRUE(NULL != key);
|
||||
ASSERT_TRUE(NULL != starting_iv);
|
||||
ASSERT_TRUE(NULL != out_buffer);
|
||||
ASSERT_NE(static_cast<void*>(NULL), key);
|
||||
ASSERT_NE(static_cast<void*>(NULL), starting_iv);
|
||||
ASSERT_NE(static_cast<void*>(NULL), out_buffer);
|
||||
AES_KEY aes_key;
|
||||
AES_set_encrypt_key(key, AES_BLOCK_SIZE * 8, &aes_key);
|
||||
out_buffer->resize(in_buffer.size());
|
||||
@@ -1646,9 +1646,7 @@ TEST_F(OEMCryptoKeyboxTest, NormalGetKeyData) {
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
}
|
||||
|
||||
// TODO(fredgc): warn people that this will be turned on. It causes a
|
||||
// seg fault on some devices at the moment.
|
||||
TEST_F(OEMCryptoKeyboxTest, DISABLED_GetKeyDataNullPointer) {
|
||||
TEST_F(OEMCryptoKeyboxTest, GetKeyDataNullPointer) {
|
||||
OEMCryptoResult sts;
|
||||
uint8_t key_data[256];
|
||||
sts = OEMCrypto_GetKeyData(key_data, NULL);
|
||||
@@ -2366,6 +2364,59 @@ TEST_F(OEMCryptoSessionTests, DecryptZeroDuration) {
|
||||
ASSERT_NO_FATAL_FAILURE(s.TestDecryptCTR());
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoSessionTests, SimultaneousDecrypt) {
|
||||
vector<Session> s(8);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].open());
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].GenerateTestSessionKeys());
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].FillSimpleMessage(kDuration, 0,
|
||||
s[i].get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].EncryptAndSign());
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].LoadTestKeys());
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].TestDecryptCTR());
|
||||
}
|
||||
// Second call to decrypt for each session.
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].TestDecryptCTR());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoSessionTests, SimultaneousDecryptWithLostMessage) {
|
||||
vector<Session> s(8);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].open());
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].GenerateTestSessionKeys());
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].FillSimpleMessage(kDuration, 0,
|
||||
s[i].get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].EncryptAndSign());
|
||||
}
|
||||
// First set of messages are lost. Generate second set.
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].GenerateTestSessionKeys());
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].FillSimpleMessage(kDuration, 0,
|
||||
s[i].get_nonce()));
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].EncryptAndSign());
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].LoadTestKeys());
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].TestDecryptCTR());
|
||||
}
|
||||
// Second call to decrypt for each session.
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ASSERT_NO_FATAL_FAILURE(s[i].TestDecryptCTR());
|
||||
}
|
||||
}
|
||||
|
||||
struct SampleSize {
|
||||
size_t clear_size;
|
||||
size_t encrypted_size;
|
||||
|
||||
Reference in New Issue
Block a user