Merge "Update oemcrypto_test.cpp"

This commit is contained in:
Fred Gylys-Colwell
2016-10-11 00:13:33 +00:00
committed by Android (Google) Code Review

View File

@@ -1135,7 +1135,7 @@ TEST_F(OEMCryptoSessionTests, SimultaneousDecrypt) {
} }
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
ASSERT_NO_FATAL_FAILURE(s[i].GenerateTestSessionKeys()); ASSERT_NO_FATAL_FAILURE(s[i].GenerateTestSessionKeys());
ASSERT_NO_FATAL_FAILURE(s[i].FillSimpleMessage(kDuration, 0, ASSERT_NO_FATAL_FAILURE(s[i].FillSimpleMessage(kLongDuration, 0,
s[i].get_nonce())); s[i].get_nonce()));
ASSERT_NO_FATAL_FAILURE(s[i].EncryptAndSign()); ASSERT_NO_FATAL_FAILURE(s[i].EncryptAndSign());
} }
@@ -1158,14 +1158,14 @@ TEST_F(OEMCryptoSessionTests, SimultaneousDecryptWithLostMessage) {
} }
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
ASSERT_NO_FATAL_FAILURE(s[i].GenerateTestSessionKeys()); ASSERT_NO_FATAL_FAILURE(s[i].GenerateTestSessionKeys());
ASSERT_NO_FATAL_FAILURE(s[i].FillSimpleMessage(kDuration, 0, ASSERT_NO_FATAL_FAILURE(s[i].FillSimpleMessage(kLongDuration, 0,
s[i].get_nonce())); s[i].get_nonce()));
ASSERT_NO_FATAL_FAILURE(s[i].EncryptAndSign()); ASSERT_NO_FATAL_FAILURE(s[i].EncryptAndSign());
} }
// First set of messages are lost. Generate second set. // First set of messages are lost. Generate second set.
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
ASSERT_NO_FATAL_FAILURE(s[i].GenerateTestSessionKeys()); ASSERT_NO_FATAL_FAILURE(s[i].GenerateTestSessionKeys());
ASSERT_NO_FATAL_FAILURE(s[i].FillSimpleMessage(kDuration, 0, ASSERT_NO_FATAL_FAILURE(s[i].FillSimpleMessage(kLongDuration, 0,
s[i].get_nonce())); s[i].get_nonce()));
ASSERT_NO_FATAL_FAILURE(s[i].EncryptAndSign()); ASSERT_NO_FATAL_FAILURE(s[i].EncryptAndSign());
} }
@@ -1293,7 +1293,7 @@ class OEMCryptoSessionTestsDecryptTests
} }
void TestDecryptCENC(const vector<uint8_t>& key, void TestDecryptCENC(const vector<uint8_t>& key,
const vector<uint8_t>& encryptionIv, const vector<uint8_t>& /* encryptionIv */,
const vector<uint8_t>& encryptedData, const vector<uint8_t>& encryptedData,
const vector<uint8_t>& unencryptedData) { const vector<uint8_t>& unencryptedData) {
OEMCryptoResult sts; OEMCryptoResult sts;
@@ -1615,8 +1615,8 @@ TEST_P(OEMCryptoSessionTestsDecryptTests, DecryptCENCPerformance) {
s.license().keys[0].cipher_mode = GetParam().mode; s.license().keys[0].cipher_mode = GetParam().mode;
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign()); ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys()); ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
vector<uint8_t> keyId = wvcdm::a2b_hex("000000000000000000000000"); sts = OEMCrypto_SelectKey(s.session_id(), s.license().keys[0].key_id,
sts = OEMCrypto_SelectKey(s.session_id(), &keyId[0], keyId.size()); s.license().keys[0].key_id_length);
ASSERT_EQ(OEMCrypto_SUCCESS, sts); ASSERT_EQ(OEMCrypto_SUCCESS, sts);
vector<uint8_t> encryptionIv = vector<uint8_t> encryptionIv =
wvcdm::a2b_hex("719dbcb253b2ec702bb8c1b1bc2f3bc6"); wvcdm::a2b_hex("719dbcb253b2ec702bb8c1b1bc2f3bc6");
@@ -3191,6 +3191,10 @@ TEST_F(OEMCryptoCastReceiverTest, TestSignaturePKCS1_15_20) {
class GenericCryptoTest : public OEMCryptoSessionTests { class GenericCryptoTest : public OEMCryptoSessionTests {
protected: protected:
// buffer_size_ must be a multiple of encryption block size, 16. We'll use a
// reasonable number of blocks for most of the tests.
GenericCryptoTest() : buffer_size_(160) {}
virtual void SetUp() { virtual void SetUp() {
OEMCryptoSessionTests::SetUp(); OEMCryptoSessionTests::SetUp();
ASSERT_NO_FATAL_FAILURE(session_.open()); ASSERT_NO_FATAL_FAILURE(session_.open());
@@ -3331,7 +3335,7 @@ class GenericCryptoTest : public OEMCryptoSessionTests {
} }
// This must be a multiple of encryption block size. // This must be a multiple of encryption block size.
size_t buffer_size_ = 160; size_t buffer_size_;
vector<uint8_t> clear_buffer_; vector<uint8_t> clear_buffer_;
vector<uint8_t> encrypted_buffer_; vector<uint8_t> encrypted_buffer_;
uint8_t iv_[wvcdm::KEY_IV_SIZE]; uint8_t iv_[wvcdm::KEY_IV_SIZE];