Pack structure OEMCrypto_PST_Report

Because the OEMCrypto_PST_Report is sent as a signed block to the
server, it needs to be a fixed, platform independent, size.  This CL
adds the packed attribute to the structure, which reduces its size
from 56 bytes to 48 bytes.

Copy of widevine change:
https://widevine-internal-review.googlesource.com/#/c/10321/

Library Versions:
libwvdrmengine/level3/x86/libwvlevel3.a  Level3 Library May 30 2014 15:40:50
libwvdrmengine/level3/arm/libwvlevel3.a  Level3 Library May 30 2014 15:39:04

bug: 15184821
Change-Id: I54db2c3bbc4e20ee0c19c33d6fd56f86f432e110
This commit is contained in:
Fred Gylys-Colwell
2014-05-30 10:10:36 -07:00
parent 52683d3e28
commit 6f3e866882
5 changed files with 27 additions and 3 deletions

View File

@@ -208,12 +208,13 @@ typedef enum OEMCrypto_Usage_Entry_Status {
*/
typedef struct {
uint8_t signature[20]; // -- HMAC SHA1 of the rest of the report.
int64_t seconds_since_license_received; // now - time_of_license_received
int64_t seconds_since_first_decrypt; // now - time_of_first_decrypt
int64_t seconds_since_last_decrypt; // now - time_of_last_decrypt
uint8_t status; // current status of entry. (OEMCrypto_Usage_Entry_Status)
uint8_t clock_security_level;
uint8_t pst_length;
uint8_t padding; // make int64's word aligned.
int64_t seconds_since_license_received; // now - time_of_license_received
int64_t seconds_since_first_decrypt; // now - time_of_first_decrypt
int64_t seconds_since_last_decrypt; // now - time_of_last_decrypt
uint8_t pst[];
} __attribute__((packed)) OEMCrypto_PST_Report;

View File

@@ -4447,6 +4447,29 @@ TEST_F(OEMCryptoClientTest, SupportsUsageTable) {
}
}
TEST_F(OEMCryptoClientTest, PSTReportSizes) {
if (OEMCrypto_SupportsUsageTable()) {
OEMCrypto_PST_Report report;
uint8_t* location = reinterpret_cast<uint8_t*>(&report);
EXPECT_EQ(48, sizeof(report));
uint8_t *field;
field = reinterpret_cast<uint8_t *>(&report.status);
EXPECT_EQ(20, field - location);
field = reinterpret_cast<uint8_t *>(&report.clock_security_level);
EXPECT_EQ(21, field - location);
field = reinterpret_cast<uint8_t *>(&report.pst_length);
EXPECT_EQ(22, field - location);
field = reinterpret_cast<uint8_t *>(&report.seconds_since_license_received);
EXPECT_EQ(24, field - location);
field = reinterpret_cast<uint8_t *>(&report.seconds_since_first_decrypt);
EXPECT_EQ(32, field - location);
field = reinterpret_cast<uint8_t *>(&report.seconds_since_last_decrypt);
EXPECT_EQ(40, field - location);
field = reinterpret_cast<uint8_t *>(&report.pst);
EXPECT_EQ(48, field - location);
}
}
class DISABLED_UsageTableTest : public DISABLED_GenericDRMTest,
public WithParamInterface<bool> {
public: