Fix RefreshKey Test
The test for refresh keys with a stale nonce was not performed correctly. It was supposed to test that RefreshKeys fails when the nonce is stale. However, the nonce in the test was not stale. The reference implementation did fail, but it failed because the control bits were in network byte order instead of host byte order. Both of these problems are fixed in this CL. This CL changes test code only. The change has already been communicated with Qualcomm. bug: 8621521 Merge of https://widevine-internal-review.googlesource.com/#/c/5263/ from Widevine CDM repo. Change-Id: I0821eff914d1680481006b9b68d49e8f2c5b9cd8
This commit is contained in:
@@ -2137,12 +2137,11 @@ class OEMCryptoRefreshKeyTest : public OEMCryptoClientTest {
|
||||
Session& s = createSession("ONE");
|
||||
s.open();
|
||||
s.GenerateDerivedKeys();
|
||||
s.LoadTestKeys(kDuration, 0);
|
||||
s.LoadTestKeys(kDuration, wvoec_mock::kControlNonceEnabled);
|
||||
uint32_t nonce;
|
||||
s.GenerateNonce(&nonce);
|
||||
s.RefreshTestKeys(key_count,
|
||||
htonl(wvoec_mock::kControlNonceEnabled), nonce,
|
||||
true );
|
||||
s.RefreshTestKeys(key_count, wvoec_mock::kControlNonceEnabled, nonce,
|
||||
true);
|
||||
s.close();
|
||||
}
|
||||
|
||||
@@ -2153,7 +2152,7 @@ class OEMCryptoRefreshKeyTest : public OEMCryptoClientTest {
|
||||
s.LoadTestKeys(kDuration, 0);
|
||||
uint32_t nonce;
|
||||
s.GenerateNonce(&nonce);
|
||||
s.RefreshTestKeys(key_count,0, 0, true );
|
||||
s.RefreshTestKeys(key_count,0, 0, true);
|
||||
s.close();
|
||||
}
|
||||
|
||||
@@ -2161,37 +2160,41 @@ class OEMCryptoRefreshKeyTest : public OEMCryptoClientTest {
|
||||
Session& s = createSession("ONE");
|
||||
s.open();
|
||||
s.GenerateDerivedKeys();
|
||||
s.LoadTestKeys(kDuration, 0);
|
||||
s.LoadTestKeys(kDuration, wvoec_mock::kControlNonceEnabled);
|
||||
uint32_t nonce = s.get_nonce();
|
||||
s.RefreshTestKeys(key_count,
|
||||
htonl(wvoec_mock::kControlNonceEnabled), nonce,
|
||||
false );
|
||||
s.RefreshTestKeys(key_count, wvoec_mock::kControlNonceEnabled, nonce,
|
||||
false);
|
||||
s.close();
|
||||
}
|
||||
void RefreshBadNonce(const int key_count) {
|
||||
Session& s = createSession("ONE");
|
||||
s.open();
|
||||
s.GenerateDerivedKeys();
|
||||
s.LoadTestKeys(kDuration, 0);
|
||||
s.LoadTestKeys(kDuration, wvoec_mock::kControlNonceEnabled);
|
||||
uint32_t nonce;
|
||||
s.GenerateNonce(&nonce);
|
||||
nonce = 42;
|
||||
s.RefreshTestKeys(key_count,
|
||||
htonl(wvoec_mock::kControlNonceEnabled), nonce,
|
||||
false );
|
||||
s.RefreshTestKeys(key_count, wvoec_mock::kControlNonceEnabled, nonce,
|
||||
false);
|
||||
s.close();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
TEST_F(OEMCryptoRefreshKeyTest, RefreshKeys) {
|
||||
TEST_F(OEMCryptoRefreshKeyTest, RefreshAllKeys) {
|
||||
testSetUp();
|
||||
InstallKeybox(kDefaultKeybox);
|
||||
RefreshWithNonce(1);
|
||||
RefreshWithNonce(kNumKeys);
|
||||
RefreshWithNonce(1); // One key control block to refresh all keys.
|
||||
RefreshOldNonce(1);
|
||||
RefreshOldNonce(kNumKeys);
|
||||
RefreshBadNonce(1);
|
||||
testTearDown();
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoRefreshKeyTest, RefreshEachKeys) {
|
||||
testSetUp();
|
||||
InstallKeybox(kDefaultKeybox);
|
||||
RefreshWithNonce(kNumKeys); // Each key control block updates a different key.
|
||||
RefreshOldNonce(kNumKeys);
|
||||
RefreshBadNonce(kNumKeys);
|
||||
testTearDown();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user