Reject Embedded Keys Under 16 Bytes

(This is a merge of http://go/wvgerrit/60620)

The license code handles keys larger than 16 bytes correctly, but it
does not properly reject keys smaller than 16 bytes.

This patch adds unit tests not only for the new error case but also
the existing success cases which were not previously being tested. As
part of this, license_unittest was changed to use a Test Peer instead
of making the test fixture a friend class.

Bug: 111069024
Test: CE CDM unit tests
Test: Android unit tests
Change-Id: Idb2deb6fbe0aeb19b530f9818bebff480541f5c8
This commit is contained in:
John W. Bruce
2018-10-08 10:05:34 -07:00
parent 44fe62b0a6
commit 3d603eb12d
14 changed files with 158 additions and 32 deletions

View File

@@ -155,7 +155,7 @@ class CdmLicense {
CdmLicenseKeyType license_key_type_;
RepeatedPtrField<License_KeyContainer> entitlement_keys_;
#if defined(UNIT_TEST)
friend class CdmLicenseTest;
friend class CdmLicenseTestPeer;
#endif
CORE_DISALLOW_COPY_AND_ASSIGN(CdmLicense);

View File

@@ -12,7 +12,8 @@ static const size_t KEY_CONTROL_SIZE = 16;
static const size_t KEY_ID_SIZE = 16;
static const size_t KEY_IV_SIZE = 16;
static const size_t KEY_PAD_SIZE = 16;
static const size_t KEY_SIZE = 16;
static const size_t CONTENT_KEY_SIZE = 16;
static const size_t SERVICE_KEY_SIZE = 16;
static const size_t MAC_KEY_SIZE = 32;
static const size_t KEYBOX_KEY_DATA_SIZE = 72;
static const size_t SRM_REQUIREMENT_SIZE = 12;

View File

@@ -126,7 +126,7 @@ enum CdmResponseType {
INVALID_SESSION_ID = 83,
KEY_REQUEST_ERROR_1 = 84,
/* previously KEY_REQUEST_ERROR_2 = 85 */
KEY_SIZE_ERROR = 86,
KEY_SIZE_ERROR_1 = 86,
KEYSET_ID_NOT_FOUND_1 = 87,
KEYSET_ID_NOT_FOUND_2 = 88,
KEYSET_ID_NOT_FOUND_3 = 89,
@@ -336,6 +336,7 @@ enum CdmResponseType {
NO_CONTENT_KEY_3 = 292,
DEVICE_CANNOT_REPROVISION = 293,
SESSION_NOT_FOUND_19 = 294,
KEY_SIZE_ERROR_2 = 295,
// Don't forget to add new values to ../test/test_printers.cpp.
};