Update key control block verification

This is a merge of http://go/wvgerrit/13752

Replace the mock's macro with a memcmp because that is
even cleaner.

Change-Id: Ie402689ca9e14a67736db7eea928204f067427ac
This commit is contained in:
Fred Gylys-Colwell
2015-03-19 20:49:14 -07:00
parent 047f543e7c
commit 69d7ffb22d
2 changed files with 7 additions and 11 deletions

View File

@@ -14,15 +14,11 @@
namespace wvoec_mock {
#define FOURCC(c1, c2, c3, c4) \
(c1 << 24 | c2 << 16 | c3 << 8 | c4)
bool KeyControlBlock::Validate() {
if ((FOURCC('k', 'c', 't', 'l') != verification_) && // original verification
(FOURCC('k', 'c', '0', '9') != verification_) && // add in version 9 api
(FOURCC('k', 'c', '1', '0') != verification_)) { // add in version 10 api
LOGE("KCB: BAD verification string: %08X (not %08X or %08X)", verification_,
0x6b63746c, 0x6b633039);
if (memcmp(verification_, "kctl", 4) && // original verification
memcmp(verification_, "kc09", 4) && // add in version 9 api
memcmp(verification_, "kc10", 4)) { // add in version 10 api
LOGE("KCB: BAD verification string: %4.4s", verification_);
return false;
}
valid_ = true;
@@ -49,7 +45,7 @@ KeyControlBlock::KeyControlBlock(
return;
}
verification_ = ExtractField(key_control_string, 0);
memcpy(verification_, &key_control_string[0], 4);
duration_ = ExtractField(key_control_string, 1);
nonce_ = ExtractField(key_control_string, 2);
control_bits_ = ExtractField(key_control_string, 3);