Support Offline Licenses

Bug: 8621588

Merge of the following CLs from the Widevine CDM repository:

https://widevine-internal-review.googlesource.com/#/c/5602/
https://widevine-internal-review.googlesource.com/#/c/5431/
https://widevine-internal-review.googlesource.com/#/c/5660/

Change-Id: If37940e2535e1a1eca95e4394d8cf9bf689e9c3a
This commit is contained in:
Jeff Tinker
2013-05-15 19:23:36 -07:00
parent 898d870126
commit 1b295f4c81
30 changed files with 1647 additions and 471 deletions

View File

@@ -934,9 +934,9 @@ class Session {
enc_key_ = wvcdm::a2b_hex("D0BFC35DA9E33436E81C4229E78CB9F4");
}
void LoadTestKeys(uint32_t duration, uint32_t control) {
void LoadTestKeys(uint32_t duration, uint32_t control, uint32_t nonce) {
MessageData data;
FillSimpleMessage(&data, duration, control);
FillSimpleMessage(&data, duration, control, nonce);
MessageData encrypted;
EncryptMessage(data, &encrypted);
std::vector<uint8_t> signature;
@@ -1059,7 +1059,8 @@ class Session {
}
}
void FillSimpleMessage(MessageData* data, uint32_t duration, uint32_t control) {
void FillSimpleMessage(MessageData* data, uint32_t duration, uint32_t control,
uint32_t nonce) {
OEMCrypto_GetRandom(data->mac_key_iv, sizeof(data->mac_key_iv));
OEMCrypto_GetRandom(data->mac_keys, sizeof(data->mac_keys));
for (unsigned int i = 0; i < kNumKeys; i++) {
@@ -1072,7 +1073,7 @@ class Session {
sizeof(data->keys[i].control_iv));
memcpy(data->keys[i].control.verification, "kctl", 4);
data->keys[i].control.duration = htonl(duration);
data->keys[i].control.nonce = htonl(nonce_);
data->keys[i].control.nonce = htonl(nonce);
data->keys[i].control.control_bits = htonl(control);
}
// For the canned decryption content, The first key is:
@@ -1918,7 +1919,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeyNoNonce) {
Session& s = createSession("ONE");
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(kDuration, 0);
s.LoadTestKeys(kDuration, 0, 42);
s.close();
testTearDown();
}
@@ -1930,7 +1931,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeyWithNonce) {
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(0, wvoec_mock::kControlNonceEnabled);
s.LoadTestKeys(0, wvoec_mock::kControlNonceEnabled, s.get_nonce());
s.close();
testTearDown();
}
@@ -1946,7 +1947,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeyWithBadRange1) {
s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0);
s.FillSimpleMessage(&data, 0, 0, 0);
MessageData encrypted;
s.EncryptMessage(data, &encrypted);
@@ -1978,7 +1979,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeyWithBadRange2) {
s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0);
s.FillSimpleMessage(&data, 0, 0, 0);
MessageData encrypted;
s.EncryptMessage(data, &encrypted);
@@ -2011,7 +2012,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeyWithBadRange3) {
s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0);
s.FillSimpleMessage(&data, 0, 0, 0);
MessageData encrypted;
s.EncryptMessage(data, &encrypted);
@@ -2045,7 +2046,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeyWithBadRange4) {
s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0);
s.FillSimpleMessage(&data, 0, 0, 0);
MessageData encrypted;
s.EncryptMessage(data, &encrypted);
@@ -2079,7 +2080,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeyWithBadRange5) {
s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0);
s.FillSimpleMessage(&data, 0, 0, 0);
MessageData encrypted;
s.EncryptMessage(data, &encrypted);
@@ -2113,7 +2114,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeyWithBadRange6) {
s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0);
s.FillSimpleMessage(&data, 0, 0, 0);
MessageData encrypted;
s.EncryptMessage(data, &encrypted);
@@ -2147,7 +2148,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeyWithBadRange7) {
s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0);
s.FillSimpleMessage(&data, 0, 0, 0);
MessageData encrypted;
s.EncryptMessage(data, &encrypted);
@@ -2181,12 +2182,8 @@ TEST_F(DISABLED_TestKeybox, LoadKeyWithBadNonce) {
s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0);
data.keys[0].control.control_bits = htonl(wvoec_mock::kControlNonceEnabled);
data.keys[1].control.control_bits = htonl(wvoec_mock::kControlNonceEnabled);
data.keys[2].control.control_bits = htonl(wvoec_mock::kControlNonceEnabled);
data.keys[1].control.nonce = 42; // This one is bad.
s.FillSimpleMessage(&data, 0, wvoec_mock::kControlNonceEnabled,
42); // bad nonce.
MessageData encrypted;
s.EncryptMessage(data, &encrypted);
std::vector<uint8_t> signature;
@@ -2218,7 +2215,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeyWithBadVerification) {
s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0);
s.FillSimpleMessage(&data, 0, 0, 0);
data.keys[1].control.verification[2] = 'Z';
MessageData encrypted;
@@ -2252,7 +2249,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeysBadSignature) {
s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0);
s.FillSimpleMessage(&data, 0, 0, 0);
MessageData encrypted;
s.EncryptMessage(data, &encrypted);
@@ -2287,7 +2284,7 @@ TEST_F(DISABLED_TestKeybox, LoadKeysWithNoDerivedKeys) {
// s.GenerateDerivedKeys();
MessageData data;
s.FillSimpleMessage(&data, 0, 0);
s.FillSimpleMessage(&data, 0, 0, 0);
MessageData encrypted;
s.EncryptMessage(data, &encrypted);
@@ -2321,11 +2318,10 @@ class DISABLED_RefreshKeyTest : public DISABLED_TestKeybox {
Session& s = createSession("ONE");
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(kDuration, wvoec_mock::kControlNonceEnabled);
s.LoadTestKeys(kDuration, wvoec_mock::kControlNonceEnabled, s.get_nonce());
uint32_t nonce;
s.GenerateNonce(&nonce);
s.RefreshTestKeys(key_count, wvoec_mock::kControlNonceEnabled, nonce,
true);
s.RefreshTestKeys(key_count, wvoec_mock::kControlNonceEnabled, nonce, true);
s.close();
}
@@ -2333,7 +2329,7 @@ class DISABLED_RefreshKeyTest : public DISABLED_TestKeybox {
Session& s = createSession("ONE");
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(kDuration, 0);
s.LoadTestKeys(kDuration, 0, 0);
uint32_t nonce;
s.GenerateNonce(&nonce);
s.RefreshTestKeys(key_count,0, 0, true);
@@ -2344,7 +2340,7 @@ class DISABLED_RefreshKeyTest : public DISABLED_TestKeybox {
Session& s = createSession("ONE");
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(kDuration, wvoec_mock::kControlNonceEnabled);
s.LoadTestKeys(kDuration, wvoec_mock::kControlNonceEnabled, s.get_nonce());
uint32_t nonce = s.get_nonce();
s.RefreshTestKeys(key_count, wvoec_mock::kControlNonceEnabled, nonce,
false);
@@ -2354,7 +2350,7 @@ class DISABLED_RefreshKeyTest : public DISABLED_TestKeybox {
Session& s = createSession("ONE");
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(kDuration, wvoec_mock::kControlNonceEnabled);
s.LoadTestKeys(kDuration, wvoec_mock::kControlNonceEnabled, s.get_nonce());
uint32_t nonce;
s.GenerateNonce(&nonce);
nonce = 42;
@@ -2395,7 +2391,7 @@ TEST_F(DISABLED_TestKeybox, Decrypt) {
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(kDuration, 0);
s.LoadTestKeys(kDuration, 0, 0);
// Select the key (from FillSimpleMessage)
vector<uint8_t> keyId = wvcdm::a2b_hex("000000000000000000000000");
@@ -2452,7 +2448,7 @@ TEST_F(DISABLED_TestKeybox, DecryptZeroDuration) {
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(0, 0);
s.LoadTestKeys(0, 0, 0);
// Select the key (from FillSimpleMessage)
vector<uint8_t> keyId = wvcdm::a2b_hex("000000000000000000000000");
@@ -2509,7 +2505,7 @@ TEST_F(DISABLED_TestKeybox, DecryptWithOffset) {
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(kDuration, 0);
s.LoadTestKeys(kDuration, 0, 0);
// Select the key (from FillSimpleMessage)
vector<uint8_t> keyId = wvcdm::a2b_hex("000000000000000000000000");
@@ -2568,7 +2564,7 @@ TEST_F(DISABLED_TestKeybox, DecryptUnencrypted) {
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(kDuration, 0);
s.LoadTestKeys(kDuration, 0, 0);
// Select the key (from FillSimpleMessage)
vector<uint8_t> keyId = wvcdm::a2b_hex("000000000000000000000000");
@@ -2658,7 +2654,7 @@ TEST_F(DISABLED_TestKeybox, DecryptSecureToClear) {
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(kDuration, wvoec_mock::kControlObserveDataPath
| wvoec_mock::kControlDataPathSecure);
| wvoec_mock::kControlDataPathSecure, 0);
// Select the key (from FillSimpleMessage)
vector<uint8_t> keyId = wvcdm::a2b_hex("000000000000000000000000");
@@ -2714,7 +2710,7 @@ TEST_F(DISABLED_TestKeybox, KeyDuration) {
Session& s = createSession("ONE");
s.open();
s.GenerateDerivedKeys();
s.LoadTestKeys(kDuration, wvoec_mock::kControlNonceEnabled);
s.LoadTestKeys(kDuration, wvoec_mock::kControlNonceEnabled, s.get_nonce());
// Select the key (from FillSimpleMessage)
vector<uint8_t> keyId = wvcdm::a2b_hex("000000000000000000000000");
@@ -3168,7 +3164,7 @@ TEST_F(DISABLED_TestKeybox, CertificateDecrypt) {
s.open();
s.InstallRSASessionTestKey(wrapped_rsa_key);
s.LoadTestKeys(kDuration, 0);
s.LoadTestKeys(kDuration, 0, 0);
// Select the key (from FillSimpleMessage)
vector<uint8_t> keyId = wvcdm::a2b_hex("000000000000000000000000");
@@ -3228,7 +3224,7 @@ class DISABLED_GenericDRMTest : public DISABLED_TestKeybox {
void MakeFourKeys(Session* s) {
s->FillSimpleMessage(&message_data_, kDuration, 0);
s->FillSimpleMessage(&message_data_, kDuration, 0, 0);
message_data_.keys[0].control.control_bits = htonl(wvoec_mock::kControlAllowEncrypt);
message_data_.keys[1].control.control_bits = htonl(wvoec_mock::kControlAllowDecrypt);
message_data_.keys[2].control.control_bits = htonl(wvoec_mock::kControlAllowSign);