OEMCrypto v13 Header and Stubs

Merge from Widevine repo of http://go/wvgerrit/22899

This is most of the header changes for OEMCrypto v13.  This updates
just enough of the code that existing unit tests build and pass.

The documentation will be reviewed in http://go/wvgerrit/22887.  When
that CL has been approved, comments in the code will be updated to
match.

Real code will be broken into several other CLs.

bug:31458046

arm/libwvlevel3.a  Level3 Library 4445 Jan 17 2017 20:01:26
x86/libwvlevel3.a  Level3 Library 4464 Jan 17 2017 19:00:37
mips/libwvlevel3.a  Level3 Library 4465 Jan 17 2017 19:24:35

Change-Id: I0318c53235c0b33afb623cba933365e09dec4e61
This commit is contained in:
Fred Gylys-Colwell
2017-01-20 18:29:20 -08:00
committed by Jeff Tinker
parent d7b27e49a0
commit b2a3921b37
14 changed files with 754 additions and 113 deletions

View File

@@ -6,9 +6,9 @@
* Reference APIs needed to support Widevine's crypto algorithms.
*
* See the document "WV Modular DRM Security Integration Guide for Common
* Encryption (CENC) -- version 12" for a description of this API. You
* Encryption (CENC) -- version 13" for a description of this API. You
* can find this document in the widevine repository as
* docs/WidevineModularDRMSecurityIntegrationGuideforCENC.pdf
* docs/WidevineModularDRMSecurityIntegrationGuideforCENC_v13.pdf
* Changes between different versions of this API are documented in the files
* docs/Widevine_Modular_DRM_Version_*_Delta.pdf
*
@@ -33,10 +33,10 @@ typedef enum OEMCryptoResult {
OEMCrypto_ERROR_TERMINATE_FAILED = 2,
OEMCrypto_ERROR_OPEN_FAILURE = 3,
OEMCrypto_ERROR_CLOSE_FAILURE = 4,
OEMCrypto_ERROR_ENTER_SECURE_PLAYBACK_FAILED = 5,
OEMCrypto_ERROR_EXIT_SECURE_PLAYBACK_FAILED = 6,
OEMCrypto_ERROR_ENTER_SECURE_PLAYBACK_FAILED = 5, // deprecated
OEMCrypto_ERROR_EXIT_SECURE_PLAYBACK_FAILED = 6, // deprecated
OEMCrypto_ERROR_SHORT_BUFFER = 7,
OEMCrypto_ERROR_NO_DEVICE_KEY = 8,
OEMCrypto_ERROR_NO_DEVICE_KEY = 8, // no keybox device key.
OEMCrypto_ERROR_NO_ASSET_KEY = 9,
OEMCrypto_ERROR_KEYBOX_INVALID = 10,
OEMCrypto_ERROR_NO_KEYDATA = 11,
@@ -68,6 +68,13 @@ typedef enum OEMCryptoResult {
OEMCrypto_ERROR_INSUFFICIENT_RESOURCES = 37,
OEMCrypto_ERROR_INSUFFICIENT_HDCP = 38,
OEMCrypto_ERROR_BUFFER_TOO_LARGE = 39,
OEMCrypto_WARNING_GENERATION_SKEW = 40, // Warning, not an error.
OEMCrypto_ERROR_GENERATION_SKEW = 41,
OEMCrypto_LOCAL_DISPLAY_ONLY = 42, // Info, not an error.
OEMCrypto_ERROR_ANALOG_OUTPUT = 43,
OEMCrypto_ERROR_WRONG_PST = 44,
OEMCrypto_ERROR_WRONG_KEYS = 45,
OEMCrypto_ERROR_MISSING_MASTER = 46,
} OEMCryptoResult;
/*
@@ -235,7 +242,7 @@ typedef struct {
typedef enum OEMCrypto_Usage_Entry_Status {
kUnused = 0,
kActive = 1,
kInactive = 2
kInactive = 2 // TODO(fredgc): http://b/32714323. used and unused.
} OEMCrypto_Usage_Entry_Status;
/*
@@ -274,12 +281,12 @@ typedef enum RSA_Padding_Scheme {
* level, and in GetHDCPCapability for reporting.
*/
typedef enum OEMCrypto_HDCP_Capability {
HDCP_NONE = 0, // No HDCP supported, no secure data path.
HDCP_V1 = 1, // HDCP version 1.0
HDCP_V2 = 2, // HDCP version 2.0
HDCP_V2_1 = 3, // HDCP version 2.1
HDCP_V2_2 = 4, // HDCP version 2.2 Type 1.
HDCP_NO_DIGITAL_OUTPUT = 0xff // No digital output.
HDCP_NONE = 0, // No HDCP supported, no secure data path.
HDCP_V1 = 1, // HDCP version 1.0
HDCP_V2 = 2, // HDCP version 2.0 Type 1.
HDCP_V2_1 = 3, // HDCP version 2.1 Type 1.
HDCP_V2_2 = 4, // HDCP version 2.2 Type 1.
HDCP_NO_DIGITAL_OUTPUT = 0xff // No digital output.
} OEMCrypto_HDCP_Capability;
/* Return value for OEMCrypto_GetProvisioningMethod(). */
@@ -291,6 +298,19 @@ typedef enum OEMCrypto_ProvisioningMethod {
OEMCrypto_OEMCertificate = 3 // Device has factory installed OEM certificate.
} OEMCrypto_ProvisioningMethod;
/*
* Flags indicating RSA keys supported.
*/
#define OEMCrypto_Supports_RSA_2048bit 0x1
#define OEMCrypto_Supports_RSA_3072bit 0x2
#define OEMCrypto_Supports_RSA_CAST 0x10
/*
* Flags indicating full decrypt path hash supported.
*/
#define OEMCrypto_Hash_Not_Supported 0
#define OEMCrypto_HMAC_Clear_Buffer 1
/*
* Obfuscation Renames.
*/
@@ -324,10 +344,10 @@ typedef enum OEMCrypto_ProvisioningMethod {
#define OEMCrypto_GetHDCPCapability_V9 _oecc28
#define OEMCrypto_SupportsUsageTable _oecc29
#define OEMCrypto_UpdateUsageTable _oecc30
#define OEMCrypto_DeactivateUsageEntry _oecc31
#define OEMCrypto_DeactivateUsageEntry_V12 _oecc31
#define OEMCrypto_ReportUsage _oecc32
#define OEMCrypto_DeleteUsageEntry _oecc33
#define OEMCrypto_DeleteUsageTable _oecc34
#define OEMCrypto_DeleteOldUsageTable _oecc34
#define OEMCrypto_LoadKeys_V9_or_V10 _oecc35
#define OEMCrypto_GenerateRSASignature _oecc36
#define OEMCrypto_GetMaxNumberOfSessions _oecc37
@@ -340,11 +360,30 @@ typedef enum OEMCrypto_ProvisioningMethod {
#define OEMCrypto_GetHDCPCapability _oecc44
#define OEMCrypto_LoadTestRSAKey _oecc45
#define OEMCrypto_Security_Patch_Level _oecc46
#define OEMCrypto_LoadKeys _oecc47
#define OEMCrypto_LoadKeys_V12 _oecc47
#define OEMCrypto_DecryptCENC _oecc48
#define OEMCrypto_GetProvisioningMethod _oecc49
#define OEMCrypto_GetOEMPublicCertificate _oecc50
#define OEMCrypto_RewrapDeviceRSAKey30 _oecc51
#define OEMCrypto_SupportedCertificates _oecc52
#define OEMCrypto_IsSRMUpdateSupported _oecc53
#define OEMCrypto_GetCurrentSRMVersion _oecc54
#define OEMCrypto_LoadSRM _oecc55
#define OEMCrypto_LoadKeys _oecc56
#define OEMCrypto_RemoveSRM _oecc57
#define OEMCrypto_SupportsDecryptHash _oecc58
#define OEMCrypto_SetDecryptHash _oecc59
#define OEMCrypto_VerifyDecryptHash _oecc60
#define OEMCrypto_CreateUsageTableHeader _oecc61
#define OEMCrypto_LoadUsageTableHeader _oecc62
#define OEMCrypto_CreateNewUsageEntry _oecc63
#define OEMCrypto_LoadUsageEntry _oecc64
#define OEMCrypto_UpdateUsageEntry _oecc65
#define OEMCrypto_DeactivateUsageEntry _oecc66
#define OEMCrypto_ShrinkUsageTableHeader _oecc67
#define OEMCrypto_MoveEntry _oecc68
#define OEMCrypto_CopyOldUsageEntry _oecc69
#define OEMCrypto_CreateOldUsageEntry _oecc70
/*
@@ -442,6 +481,7 @@ OEMCryptoResult OEMCrypto_OpenSession(OEMCrypto_SESSION* session);
* Version:
* This method changed in API version 5.
*/
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_CloseSession(OEMCrypto_SESSION session);
/*
@@ -774,12 +814,14 @@ OEMCryptoResult OEMCrypto_GenerateSignature(OEMCrypto_SESSION session,
* Version:
* This method changed in API version 11.
*/
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_LoadKeys(
OEMCrypto_SESSION session, const uint8_t* message, size_t message_length,
const uint8_t* signature, size_t signature_length,
const uint8_t* enc_mac_keys_iv, const uint8_t* enc_mac_keys,
size_t num_keys, const OEMCrypto_KeyObject* key_array, const uint8_t* pst,
size_t pst_length);
size_t pst_length, const uint8_t* srm_requirement);
/*
* OEMCrypto_RefreshKeys
@@ -1001,6 +1043,7 @@ OEMCryptoResult OEMCrypto_QueryKeyControl(OEMCrypto_SESSION session,
* Version:
* This method changed in API version 8.
*/
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_SelectKey(OEMCrypto_SESSION session,
const uint8_t* key_id,
size_t key_id_length);
@@ -1177,6 +1220,7 @@ OEMCryptoResult OEMCrypto_SelectKey(OEMCrypto_SESSION session,
* This method changed in API version 11.
* This method changed its name in API version 11.
*/
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_DecryptCENC(
OEMCrypto_SESSION session, const uint8_t* data_addr, size_t data_length,
bool is_encrypted, const uint8_t* iv, size_t block_offset,
@@ -1252,6 +1296,7 @@ OEMCryptoResult OEMCrypto_DecryptCENC(
* Version
* This method is added in API version 10.
*/
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_CopyBuffer(const uint8_t* data_addr,
size_t data_length,
OEMCrypto_DestBufferDesc* out_buffer,
@@ -2237,6 +2282,9 @@ OEMCryptoResult OEMCrypto_GetNumberOfOpenSessions(size_t* count);
*/
OEMCryptoResult OEMCrypto_GetMaxNumberOfSessions(size_t* max);
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
uint32_t OEMCrypto_SupportedCertificates();
/*
* OEMCrypto_Generic_Encrypt
*
@@ -2508,7 +2556,8 @@ OEMCryptoResult OEMCrypto_Generic_Verify(OEMCrypto_SESSION session,
* OEMCrypto_ERROR_UNKNOWN_FAILURE
*
* Version:
* This method changed in API version 9.
* This method is deprecated in API version 13.
* TODO(fredgc): remove this.
*/
OEMCryptoResult OEMCrypto_UpdateUsageTable();
@@ -2548,9 +2597,15 @@ OEMCryptoResult OEMCrypto_UpdateUsageTable();
* too large.
*
* Version:
* This method changed in API version 9.
* This method is deprecated in API version 13.
* TODO(fredgc): remove this.
*/
OEMCryptoResult OEMCrypto_DeactivateUsageEntry(const uint8_t* pst,
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_DeactivateUsageEntry_12(const uint8_t* pst,
size_t pst_length);
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_DeactivateUsageEntry(OEMCrypto_SESSION session,
const uint8_t* pst,
size_t pst_length);
/*
@@ -2576,7 +2631,8 @@ OEMCryptoResult OEMCrypto_DeactivateUsageEntry(const uint8_t* pst,
* Valid values for status are:
* 0 = kUnused -- the keys have not been used to decrypt.
* 1 = kActive -- the keys have been used, and have not been deactivated.
* 2 = kInactive -- the keys have been marked inactive.
* 2 = kInactiveUsed -- the keys have been marked inactive after a decrypt.
* 3 = kInactiveUnused -- the keys have been marked inactive, no decrypt.
*
* The clock_security_level is reported as follows:
* 0 = Insecure Clock - clock just uses system time.
@@ -2634,6 +2690,7 @@ OEMCryptoResult OEMCrypto_DeactivateUsageEntry(const uint8_t* pst,
* Version:
* This method changed in API version 9.
*/
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_ReportUsage(OEMCrypto_SESSION session,
const uint8_t* pst, size_t pst_length,
OEMCrypto_PST_Report* buffer,
@@ -2700,6 +2757,8 @@ OEMCryptoResult OEMCrypto_ReportUsage(OEMCrypto_SESSION session,
* Version:
* This method changed in API version 9.
*/
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
/* TODO(fredgc): remove this. */
OEMCryptoResult OEMCrypto_DeleteUsageEntry(
OEMCrypto_SESSION session, const uint8_t* pst, size_t pst_length,
const uint8_t* message, size_t message_length, const uint8_t* signature,
@@ -2746,6 +2805,8 @@ OEMCryptoResult OEMCrypto_DeleteUsageEntry(
* Version
* This method changed in API version 10.
*/
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
/* TODO(fredgc): remove this. */
OEMCryptoResult OEMCrypto_ForceDeleteUsageEntry(const uint8_t* pst,
size_t pst_length);
@@ -2772,7 +2833,70 @@ OEMCryptoResult OEMCrypto_ForceDeleteUsageEntry(const uint8_t* pst,
* Version:
* This method changed in API version 9.
*/
OEMCryptoResult OEMCrypto_DeleteUsageTable();
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_DeleteOldUsageTable();
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_CreateOldUsageEntry(uint64_t time_since_license_received,
uint64_t time_since_first_decrypt,
uint64_t time_since_last_decrypt,
OEMCrypto_Usage_Entry_Status status,
uint8_t *server_mac_key,
uint8_t *client_mac_key,
const uint8_t* pst,
size_t pst_length);
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
bool OEMCrypto_IsSRMUpdateSupported();
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_GetCurrentSRMVersion(uint16_t* version);
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_LoadSRM(const uint8_t* buffer,
size_t buffer_length);
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_RemoveSRM();
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_CreateUsageTableHeader();
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_LoadUsageTableHeader(const uint8_t* buffer,
size_t buffer_length);
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_CreateNewUsageEntry(OEMCrypto_SESSION session,
uint32_t* usage_entry_number);
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_LoadUsageEntry(OEMCrypto_SESSION session,
uint32_t index,
const uint8_t* buffer,
size_t buffer_size);
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_UpdateUsageEntry(OEMCrypto_SESSION session,
uint8_t* header_buffer,
size_t* header_buffer_length,
uint8_t* entry_buffer,
size_t* entry_buffer_length);
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_ShrinkUsageTableHeader(uint32_t new_entry_count,
uint8_t* header_buffer,
size_t* header_buffer_length);
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_MoveEntry(OEMCrypto_SESSION session,
uint32_t new_index);
/* TODO(fredgc): copy text from http://go/wvgerrit/22887 */
OEMCryptoResult OEMCrypto_CopyOldUsageEntry(OEMCrypto_SESSION session,
const uint8_t*pst,
size_t pst_length);
#ifdef __cplusplus
}

View File

@@ -31,7 +31,6 @@ namespace wvoec3 {
#define Level3_GenerateDerivedKeys _lcc12
#define Level3_GenerateSignature _lcc13
#define Level3_GenerateNonce _lcc14
#define Level3_LoadKeys _lcc15
#define Level3_RefreshKeys _lcc16
#define Level3_SelectKey _lcc17
#define Level3_RewrapDeviceRSAKey _lcc18
@@ -50,7 +49,7 @@ namespace wvoec3 {
#define Level3_DeactivateUsageEntry _lcc31
#define Level3_ReportUsage _lcc32
#define Level3_DeleteUsageEntry _lcc33
#define Level3_DeleteUsageTable _lcc34
#define Level3_DeleteOldUsageTable _lcc34
#define Level3_GetMaxNumberOfSessions _lcc37
#define Level3_GetNumberOfOpenSessions _lcc38
#define Level3_IsAntiRollbackHwPresent _lcc39
@@ -63,7 +62,24 @@ namespace wvoec3 {
#define Level3_GetProvisioningMethod _lcc49
#define Level3_GetOEMPublicCertificate _lcc50
#define Level3_RewrapDeviceRSAKey30 _lcc51
#define Level3_SupportedCertificates _lcc52
#define Level3_IsSRMUpdateSupported _lcc53
#define Level3_GetCurrentSRMVersion _lcc54
#define Level3_LoadSRM _lcc55
#define Level3_LoadKeys _lcc56
#define Level3_RemoveSRM _lcc57
#define Level3_SupportsDecryptHash _lcc58
#define Level3_SetDecryptHash _lcc59
#define Level3_VerifyDecryptHash _lcc60
#define Level3_CreateUsageTableHeader _lcc61
#define Level3_LoadUsageTableHeader _lcc62
#define Level3_CreateNewUsageEntry _lcc63
#define Level3_LoadUsageEntry _lcc64
#define Level3_UpdateUsageEntry _lcc65
#define Level3_ShrinkUsageTableHeader _lcc67
#define Level3_MoveEntry _lcc68
#define Level3_CopyOldUsageEntry _lcc69
#define Level3_CreateOldUsageEntry _lcc70
extern "C" {
bool Level3_IsInApp(const char* path);
@@ -83,17 +99,12 @@ OEMCryptoResult Level3_GenerateSignature(OEMCrypto_SESSION session,
size_t message_length,
uint8_t* signature,
size_t* signature_length);
OEMCryptoResult Level3_LoadKeys(OEMCrypto_SESSION session,
const uint8_t* message,
size_t message_length,
const uint8_t* signature,
size_t signature_length,
const uint8_t* enc_mac_key_iv,
const uint8_t* enc_mac_key,
size_t num_keys,
const OEMCrypto_KeyObject* key_array,
const uint8_t* pst,
size_t pst_length);
OEMCryptoResult Level3_LoadKeys(
OEMCrypto_SESSION session, const uint8_t* message, size_t message_length,
const uint8_t* signature, size_t signature_length,
const uint8_t* enc_mac_keys_iv, const uint8_t* enc_mac_keys,
size_t num_keys, const OEMCrypto_KeyObject* key_array, const uint8_t* pst,
size_t pst_length, const uint8_t* srm_requirement);
OEMCryptoResult Level3_RefreshKeys(OEMCrypto_SESSION session,
const uint8_t* message,
size_t message_length,
@@ -188,6 +199,7 @@ bool Level3_SupportsUsageTable();
bool Level3_IsAntiRollbackHwPresent();
OEMCryptoResult Level3_GetNumberOfOpenSessions(size_t* count);
OEMCryptoResult Level3_GetMaxNumberOfSessions(size_t* maximum);
uint32_t Level3_SupportedCertificates();
OEMCryptoResult Level3_Generic_Encrypt(OEMCrypto_SESSION session,
const uint8_t* in_buffer,
size_t buffer_length,
@@ -213,7 +225,8 @@ OEMCryptoResult Level3_Generic_Verify(OEMCrypto_SESSION session,
const uint8_t* signature,
size_t signature_length);
OEMCryptoResult Level3_UpdateUsageTable();
OEMCryptoResult Level3_DeactivateUsageEntry(const uint8_t *pst,
OEMCryptoResult Level3_DeactivateUsageEntry(OEMCrypto_SESSION session,
const uint8_t *pst,
size_t pst_length);
OEMCryptoResult Level3_ReportUsage(OEMCrypto_SESSION session,
const uint8_t *pst,
@@ -229,7 +242,48 @@ OEMCryptoResult Level3_DeleteUsageEntry(OEMCrypto_SESSION session,
size_t signature_length);
OEMCryptoResult Level3_ForceDeleteUsageEntry(const uint8_t* pst,
size_t pst_length);
OEMCryptoResult Level3_DeleteUsageTable();
OEMCryptoResult Level3_DeleteOldUsageTable();
bool Level3_IsSRMUpdateSupported();
OEMCryptoResult Level3_GetCurrentSRMVersion(uint16_t* version);
OEMCryptoResult Level3_LoadSRM(const uint8_t* buffer,
size_t buffer_length);
OEMCryptoResult Level3_RemoveSRM();
uint32_t Level3_SupportsDecryptHash();
OEMCryptoResult Level3_SetDecryptHash(OEMCrypto_SESSION session,
const uint8_t* hash,
size_t hash_length);
OEMCryptoResult Level3_VerifyDecryptHash(OEMCrypto_SESSION session,
uint64_t* failure_data);
OEMCryptoResult Level3_CreateUsageTableHeader();
OEMCryptoResult Level3_LoadUsageTableHeader(const uint8_t* buffer,
size_t buffer_length);
OEMCryptoResult Level3_CreateNewUsageEntry(OEMCrypto_SESSION session,
uint32_t *usage_entry_number);
OEMCryptoResult Level3_LoadUsageEntry(OEMCrypto_SESSION session,
uint32_t index,
const uint8_t *buffer,
size_t buffer_size);
OEMCryptoResult Level3_UpdateUsageEntry(OEMCrypto_SESSION session,
uint8_t* header_buffer,
size_t* header_buffer_length,
uint8_t* entry_buffer,
size_t* entry_buffer_length);
OEMCryptoResult Level3_ShrinkUsageTableHeader(uint32_t new_table_size,
uint8_t* header_buffer,
size_t* header_buffer_length);
OEMCryptoResult Level3_MoveEntry(OEMCrypto_SESSION session,
uint32_t new_index);
OEMCryptoResult Level3_CopyOldUsageEntry(OEMCrypto_SESSION session,
const uint8_t*pst,
size_t pst_length);
OEMCryptoResult Level3_CreateOldUsageEntry(uint64_t time_since_license_received,
uint64_t time_since_first_decrypt,
uint64_t time_since_last_decrypt,
OEMCrypto_Usage_Entry_Status status,
uint8_t *server_mac_key,
uint8_t *client_mac_key,
const uint8_t* pst,
size_t pst_length);
} // extern "C"
} // namespace wvoec3