Source release 19.1.0
This commit is contained in:
@@ -11,9 +11,12 @@ using ::testing::Range;
|
||||
|
||||
namespace wvoec {
|
||||
|
||||
/// @addtogroup generic
|
||||
/// @{
|
||||
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyLoad) { EncryptAndLoadKeys(); }
|
||||
|
||||
// Test that the Generic_Encrypt function works correctly.
|
||||
/** Test that the Generic_Encrypt function works correctly. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyEncrypt) {
|
||||
EncryptAndLoadKeys();
|
||||
unsigned int key_index = 0;
|
||||
@@ -34,7 +37,7 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericKeyEncrypt) {
|
||||
ASSERT_EQ(expected_encrypted, encrypted);
|
||||
}
|
||||
|
||||
// Test that the Generic_Encrypt function fails when not allowed.
|
||||
/** Test that the Generic_Encrypt function fails when not allowed. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyBadEncrypt) {
|
||||
EncryptAndLoadKeys();
|
||||
BadEncrypt(0, OEMCrypto_HMAC_SHA256, buffer_size_);
|
||||
@@ -45,8 +48,8 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericKeyBadEncrypt) {
|
||||
BadEncrypt(3, OEMCrypto_AES_CBC_128_NO_PADDING, buffer_size_);
|
||||
}
|
||||
|
||||
// Test that the Generic_Encrypt works if the input and output buffers are the
|
||||
// same.
|
||||
/** Test that the Generic_Encrypt works if the input and output buffers are the
|
||||
* same. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyEncryptSameBufferAPI12) {
|
||||
EncryptAndLoadKeys();
|
||||
unsigned int key_index = 0;
|
||||
@@ -87,7 +90,7 @@ TEST_P(
|
||||
OEMCrypto_AES_CBC_128_NO_PADDING, buffer.data()));
|
||||
}
|
||||
|
||||
// Test Generic_Decrypt works correctly.
|
||||
/** Test Generic_Decrypt works correctly. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyDecrypt) {
|
||||
EncryptAndLoadKeys();
|
||||
unsigned int key_index = 1;
|
||||
@@ -108,8 +111,8 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericKeyDecrypt) {
|
||||
ASSERT_EQ(clear_buffer_, resultant);
|
||||
}
|
||||
|
||||
// Test that Generic_Decrypt works correctly when the input and output buffers
|
||||
// are the same.
|
||||
/** Test that Generic_Decrypt works correctly when the input and output buffers
|
||||
* are the same. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyDecryptSameBufferAPI12) {
|
||||
EncryptAndLoadKeys();
|
||||
unsigned int key_index = 1;
|
||||
@@ -122,16 +125,16 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericKeyDecryptSameBufferAPI12) {
|
||||
session_.license().keys[key_index].key_id,
|
||||
session_.license().keys[key_index].key_id_length,
|
||||
OEMCrypto_CipherMode_CENC, key_handle));
|
||||
vector<uint8_t> buffer = encrypted;
|
||||
vector<uint8_t> resultant(encrypted.size());
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS,
|
||||
GenericDecrypt(key_handle.data(), key_handle.size(), buffer.data(),
|
||||
buffer.size(), iv_, OEMCrypto_AES_CBC_128_NO_PADDING,
|
||||
buffer.data()));
|
||||
ASSERT_EQ(clear_buffer_, buffer);
|
||||
GenericDecrypt(key_handle.data(), key_handle.size(),
|
||||
encrypted.data(), encrypted.size(), iv_,
|
||||
OEMCrypto_AES_CBC_128_NO_PADDING, resultant.data()));
|
||||
ASSERT_EQ(clear_buffer_, resultant);
|
||||
}
|
||||
|
||||
// Test that Generic_Decrypt fails to decrypt to an insecure buffer if the key
|
||||
// requires a secure data path.
|
||||
/** Test that Generic_Decrypt fails to decrypt to an insecure buffer if the key
|
||||
* requires a secure data path. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericSecureToClear) {
|
||||
license_messages_.set_control(wvoec::kControlObserveDataPath |
|
||||
wvoec::kControlDataPathSecure);
|
||||
@@ -155,7 +158,7 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericSecureToClear) {
|
||||
ASSERT_NE(clear_buffer_, resultant);
|
||||
}
|
||||
|
||||
// Test that the Generic_Decrypt function fails when not allowed.
|
||||
/** Test that the Generic_Decrypt function fails when not allowed. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyBadDecrypt) {
|
||||
EncryptAndLoadKeys();
|
||||
BadDecrypt(1, OEMCrypto_HMAC_SHA256, buffer_size_);
|
||||
@@ -194,7 +197,7 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericKeySign) {
|
||||
ASSERT_EQ(expected_signature, signature);
|
||||
}
|
||||
|
||||
// Test that the Generic_Sign function fails when not allowed.
|
||||
/** Test that the Generic_Sign function fails when not allowed. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyBadSign) {
|
||||
EncryptAndLoadKeys();
|
||||
BadSign(0, OEMCrypto_HMAC_SHA256); // Can't sign with encrypt key.
|
||||
@@ -223,7 +226,7 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericKeyVerify) {
|
||||
signature.data(), signature.size()));
|
||||
}
|
||||
|
||||
// Test that the Generic_Verify function fails when not allowed.
|
||||
/** Test that the Generic_Verify function fails when not allowed. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyBadVerify) {
|
||||
EncryptAndLoadKeys();
|
||||
BadVerify(0, OEMCrypto_HMAC_SHA256, SHA256_DIGEST_LENGTH, false);
|
||||
@@ -235,7 +238,7 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericKeyBadVerify) {
|
||||
BadVerify(3, OEMCrypto_AES_CBC_128_NO_PADDING, SHA256_DIGEST_LENGTH, false);
|
||||
}
|
||||
|
||||
// Test Generic_Encrypt with the maximum buffer size.
|
||||
/** Test Generic_Encrypt with the maximum buffer size. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyEncryptLargeBuffer) {
|
||||
ResizeBuffer(GetResourceValue(kMaxGenericBuffer));
|
||||
EncryptAndLoadKeys();
|
||||
@@ -257,7 +260,7 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericKeyEncryptLargeBuffer) {
|
||||
ASSERT_EQ(expected_encrypted, encrypted);
|
||||
}
|
||||
|
||||
// Test Generic_Decrypt with the maximum buffer size.
|
||||
/** Test Generic_Decrypt with the maximum buffer size. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyDecryptLargeBuffer) {
|
||||
// Some applications are known to pass in a block that is almost 400k.
|
||||
ResizeBuffer(GetResourceValue(kMaxGenericBuffer));
|
||||
@@ -280,7 +283,7 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericKeyDecryptLargeBuffer) {
|
||||
ASSERT_EQ(clear_buffer_, resultant);
|
||||
}
|
||||
|
||||
// Test Generic_Sign with the maximum buffer size.
|
||||
/** Test Generic_Sign with the maximum buffer size. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeySignLargeBuffer) {
|
||||
ResizeBuffer(GetResourceValue(kMaxGenericBuffer));
|
||||
EncryptAndLoadKeys();
|
||||
@@ -310,7 +313,7 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericKeySignLargeBuffer) {
|
||||
ASSERT_EQ(expected_signature, signature);
|
||||
}
|
||||
|
||||
// Test Generic_Verify with the maximum buffer size.
|
||||
/** Test Generic_Verify with the maximum buffer size. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, GenericKeyVerifyLargeBuffer) {
|
||||
ResizeBuffer(GetResourceValue(kMaxGenericBuffer));
|
||||
EncryptAndLoadKeys();
|
||||
@@ -332,7 +335,7 @@ TEST_P(OEMCryptoGenericCryptoTest, GenericKeyVerifyLargeBuffer) {
|
||||
signature.data(), signature.size()));
|
||||
}
|
||||
|
||||
// Test Generic_Encrypt when the key duration has expired.
|
||||
/** Test Generic_Encrypt when the key duration has expired. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, KeyDurationEncrypt) {
|
||||
license_messages_.core_response()
|
||||
.timer_limits.total_playback_duration_seconds = kDuration;
|
||||
@@ -368,7 +371,7 @@ TEST_P(OEMCryptoGenericCryptoTest, KeyDurationEncrypt) {
|
||||
ASSERT_NO_FATAL_FAILURE(session_.TestGetKeyHandleExpired(key_index));
|
||||
}
|
||||
|
||||
// Test Generic_Decrypt when the key duration has expired.
|
||||
/** Test Generic_Decrypt when the key duration has expired. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, KeyDurationDecrypt) {
|
||||
license_messages_.core_response()
|
||||
.timer_limits.total_playback_duration_seconds = kDuration;
|
||||
@@ -403,7 +406,7 @@ TEST_P(OEMCryptoGenericCryptoTest, KeyDurationDecrypt) {
|
||||
ASSERT_NO_FATAL_FAILURE(session_.TestGetKeyHandleExpired(key_index));
|
||||
}
|
||||
|
||||
// Test Generic_Sign when the key duration has expired.
|
||||
/** Test Generic_Sign when the key duration has expired. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, KeyDurationSign) {
|
||||
license_messages_.core_response()
|
||||
.timer_limits.total_playback_duration_seconds = kDuration;
|
||||
@@ -442,7 +445,7 @@ TEST_P(OEMCryptoGenericCryptoTest, KeyDurationSign) {
|
||||
ASSERT_NO_FATAL_FAILURE(session_.TestGetKeyHandleExpired(key_index));
|
||||
}
|
||||
|
||||
// Test Generic_Verify when the key duration has expired.
|
||||
/** Test Generic_Verify when the key duration has expired. */
|
||||
TEST_P(OEMCryptoGenericCryptoTest, KeyDurationVerify) {
|
||||
license_messages_.core_response()
|
||||
.timer_limits.total_playback_duration_seconds = kDuration;
|
||||
@@ -574,4 +577,4 @@ INSTANTIATE_TEST_SUITE_P(TestAll, OEMCryptoGenericCryptoKeyIdLengthTest,
|
||||
Range<uint32_t>(kCoreMessagesAPI, kCurrentAPI + 1));
|
||||
|
||||
/// @}
|
||||
} // namespace wvoec
|
||||
} // namespace wvoec
|
||||
|
||||
Reference in New Issue
Block a user