Unit Test for OEMCrypto_ERROR_KEY_EXPIRED

Merge from widevine repo of http://go/wvgerrit/21141

All of the decrypt calls and the SelectKey call should return
OEMCrypto_ERROR_KEY_EXPIRED on error.  This CL updates the oemcrypto
unit tests, reference mock, and level 3 code.

b/28294273

Change-Id: I7ac6a3652e0b2fe5a46071e1c2eda00daeed7a33
This commit is contained in:
Fred Gylys-Colwell
2016-11-28 21:52:11 -08:00
parent 7214064635
commit 47f454839e
4 changed files with 31 additions and 10 deletions

View File

@@ -1145,7 +1145,7 @@ bool SessionContext::QueryKeyControlBlock(const KeyId& key_id, uint32_t* data) {
return true;
}
bool SessionContext::SelectContentKey(const KeyId& key_id) {
OEMCryptoResult SessionContext::SelectContentKey(const KeyId& key_id) {
const Key* content_key = session_keys_.Find(key_id);
if (LogCategoryEnabled(kLoggingTraceDecryption)){
@@ -1157,10 +1157,17 @@ bool SessionContext::SelectContentKey(const KeyId& key_id) {
if (NULL == content_key) {
LOGE("[SelectContentKey(): No key matches key id]");
return false;
return OEMCrypto_ERROR_NO_CONTENT_KEY;
}
current_content_key_ = content_key;
return true;
const KeyControlBlock& control = current_content_key()->control();
if (control.duration() > 0) {
if (control.duration() < CurrentTimer()) {
LOGE("[SelectContentKey(): KEY_EXPIRED]");
return OEMCrypto_ERROR_KEY_EXPIRED;
}
}
return OEMCrypto_SUCCESS;
}
void SessionContext::AddNonce(uint32_t nonce) {