Skip padding for content keys differently

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

A previous patch changed how we skip padding when extracting keys from
key containers in license.cpp. Unfortunately, this broke generic
signing when an ODK core message is not in use:

1) "Content" keys for signing are 32 bytes long, but content keys were
   assumed to be 16 bytes long.
2) When an ODK core message IS in use, the result of the extraction in
   license.cpp is ignored.

The only way to know the correct length of a content key container in
License Protocol 2.1 is to leverage the knowledge that it will always be
padded by exactly 16 bytes. This will have to change if we ever
implement support for License Protocol 2.2, as all key containers are
unpadded in that version.

Bug: 231439638
Bug: 114159862
Test: oemcrypto_dynamic_v15
Change-Id: I1d6c24b3a922247b970fd1517c6f23aded570adf
This commit is contained in:
John "Juce" Bruce
2022-05-16 18:32:00 -07:00
parent 46f2e5bcc5
commit a7cded376e
2 changed files with 25 additions and 7 deletions

View File

@@ -20,6 +20,8 @@ static const size_t ENTITLEMENT_KEY_SIZE = 32;
static const size_t KEYBOX_KEY_DATA_SIZE = 72;
static const size_t SRM_REQUIREMENT_SIZE = 12;
static const size_t LICENSE_PROTOCOL_2_1_PADDING = 16;
// Initial estimate of certificate size. Code that
// uses this estimate should be able to adapt to a larger or smaller size.
static const size_t CERTIFICATE_DATA_SIZE = 4 * 1024;