Source release v3.0.3
This commit is contained in:
@@ -678,7 +678,7 @@ class Session {
|
||||
}
|
||||
|
||||
void RefreshTestKeys(const size_t key_count, uint32_t control_bits,
|
||||
uint32_t nonce, bool expect_good) {
|
||||
uint32_t nonce, OEMCryptoResult expected_result) {
|
||||
// Note: we store the message in encrypted_license_, but the refresh key
|
||||
// message is not actually encrypted. It is, however, signed.
|
||||
FillRefreshMessage(key_count, control_bits, nonce);
|
||||
@@ -688,17 +688,13 @@ class Session {
|
||||
OEMCryptoResult sts = OEMCrypto_RefreshKeys(
|
||||
session_id(), message_ptr(), sizeof(MessageData), &signature_[0],
|
||||
signature_.size(), key_count, key_array);
|
||||
if (expect_good) {
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
} else {
|
||||
ASSERT_NE(OEMCrypto_SUCCESS, sts);
|
||||
}
|
||||
ASSERT_EQ(expected_result, sts);
|
||||
|
||||
TestDecryptCTR();
|
||||
sleep(kShortSleep); // Should still be valid key.
|
||||
TestDecryptCTR(false);
|
||||
sleep(kShortSleep + kLongSleep); // Should be after first expiration.
|
||||
if (expect_good) {
|
||||
if (expected_result == OEMCrypto_SUCCESS) {
|
||||
TestDecryptCTR(false, OEMCrypto_SUCCESS);
|
||||
} else {
|
||||
TestDecryptCTR(false, OEMCrypto_ERROR_UNKNOWN_FAILURE);
|
||||
@@ -2157,7 +2153,8 @@ TEST_P(SessionTestRefreshKeyTest, RefreshWithNonce) {
|
||||
s.LoadTestKeys("", new_mac_keys_);
|
||||
uint32_t nonce;
|
||||
s.GenerateNonce(&nonce);
|
||||
s.RefreshTestKeys(num_keys_, wvoec_mock::kControlNonceEnabled, nonce, true);
|
||||
s.RefreshTestKeys(num_keys_, wvoec_mock::kControlNonceEnabled, nonce,
|
||||
OEMCrypto_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_P(SessionTestRefreshKeyTest, RefreshNoNonce) {
|
||||
@@ -2169,7 +2166,7 @@ TEST_P(SessionTestRefreshKeyTest, RefreshNoNonce) {
|
||||
s.LoadTestKeys("", new_mac_keys_);
|
||||
uint32_t nonce;
|
||||
s.GenerateNonce(&nonce);
|
||||
s.RefreshTestKeys(num_keys_, 0, 0, true);
|
||||
s.RefreshTestKeys(num_keys_, 0, 0, OEMCrypto_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_P(SessionTestRefreshKeyTest, RefreshOldNonce) {
|
||||
@@ -2181,7 +2178,8 @@ TEST_P(SessionTestRefreshKeyTest, RefreshOldNonce) {
|
||||
s.EncryptAndSign();
|
||||
s.LoadTestKeys("", new_mac_keys_);
|
||||
uint32_t nonce = s.get_nonce();
|
||||
s.RefreshTestKeys(num_keys_, wvoec_mock::kControlNonceEnabled, nonce, false);
|
||||
s.RefreshTestKeys(num_keys_, wvoec_mock::kControlNonceEnabled, nonce,
|
||||
OEMCrypto_ERROR_INVALID_NONCE);
|
||||
}
|
||||
|
||||
TEST_P(SessionTestRefreshKeyTest, RefreshBadNonce) {
|
||||
@@ -2195,7 +2193,8 @@ TEST_P(SessionTestRefreshKeyTest, RefreshBadNonce) {
|
||||
uint32_t nonce;
|
||||
s.GenerateNonce(&nonce);
|
||||
nonce ^= 42;
|
||||
s.RefreshTestKeys(num_keys_, wvoec_mock::kControlNonceEnabled, nonce, false);
|
||||
s.RefreshTestKeys(num_keys_, wvoec_mock::kControlNonceEnabled, nonce,
|
||||
OEMCrypto_ERROR_INVALID_NONCE);
|
||||
}
|
||||
|
||||
// Of only one key control block in the refesh, we update all the keys.
|
||||
|
||||
Reference in New Issue
Block a user