Use mac keys from usage entry if keys are not loaded am: 8138df1c86

am: af34b31112

Change-Id: I1617e3f91576201228ca896682697681c1fede71
This commit is contained in:
Fred Gylys-Colwell
2017-05-31 17:41:22 +00:00
committed by android-build-merger
4 changed files with 16 additions and 5 deletions

View File

@@ -192,9 +192,14 @@ bool SessionContext::GenerateSignature(const uint8_t* message,
return false;
}
if (mac_key_client_.empty() ||
mac_key_client_.size() != wvcdm::MAC_KEY_SIZE) {
LOGE("[GenerateSignature(): No MAC Key]");
const uint8_t *mac_key = NULL;
if (mac_key_client_.size() == wvcdm::MAC_KEY_SIZE) {
// If we have a mac key, use it.
mac_key = &mac_key_client_[0];
} else if (usage_entry_status_ == kUsageEntryLoaded) {
// If not, but we have a usage entry, use its key.
mac_key = usage_entry_->mac_key_client();
} else {
return false;
}
@@ -204,7 +209,7 @@ bool SessionContext::GenerateSignature(const uint8_t* message,
}
unsigned int md_len = *signature_length;
if (HMAC(EVP_sha256(), &mac_key_client_[0], mac_key_client_.size(), message,
if (HMAC(EVP_sha256(), mac_key, wvcdm::MAC_KEY_SIZE, message,
message_length, signature, &md_len)) {
*signature_length = md_len;
return true;

View File

@@ -69,6 +69,8 @@ class UsageTableEntry {
void set_index(int32_t index) { data_.index = index; }
uint32_t index() { return data_.index; }
static size_t SignedEntrySize();
const uint8_t* mac_key_server() { return data_.mac_key_server; }
const uint8_t* mac_key_client() { return data_.mac_key_client; }
private:
UsageTable* usage_table_; // Owner of this object.