Support CAST V2 authentication - OEMCrypto Interface - DO NOT MERGE
Squashed commit of these CLs from the widevine cdm repo: Allow Version 8 OEMCrypto to be linked with CDM (KLP Modular Branch) https://widevine-internal-review.googlesource.com/#/c/9434/ Allow OEMCrypto v8 or v9 (KLP Modular Branch) https://widevine-internal-review.googlesource.com/#/c/9172/ Add alternate RSA signing (KLP Modular Branch) https://widevine-internal-review.googlesource.com/#/c/9171/ bug: 12702350 Change-Id: Ifd0c88c566bb10efe2411af49bc83265ed56cb23
This commit is contained in:
@@ -192,7 +192,8 @@ typedef enum OEMCrypto_Algorithm {
|
||||
#define OEMCrypto_FirstSubsample 1
|
||||
#define OEMCrypto_LastSubsample 2
|
||||
|
||||
/* OEMCrypto_Usage_Entry_Status.
|
||||
/*
|
||||
* OEMCrypto_Usage_Entry_Status.
|
||||
* Valid values for status in the usage table.
|
||||
*/
|
||||
typedef enum OEMCrypto_Usage_Entry_Status {
|
||||
@@ -215,7 +216,8 @@ typedef struct {
|
||||
uint8_t pst[];
|
||||
} OEMCrypto_PST_Report;
|
||||
|
||||
/* OEMCrypto_Clock_Security_Level.
|
||||
/*
|
||||
* OEMCrypto_Clock_Security_Level.
|
||||
* Valid values for clock_security_level in OEMCrypto_PST_Report.
|
||||
*/
|
||||
typedef enum OEMCrypto_Clock_Security_Level {
|
||||
@@ -231,7 +233,9 @@ typedef enum RSA_Padding_Scheme {
|
||||
} RSA_Padding_Scheme;
|
||||
|
||||
|
||||
/* Obfuscation Renames. */
|
||||
/*
|
||||
* Obfuscation Renames.
|
||||
*/
|
||||
#define OEMCrypto_Initialize _oecc01
|
||||
#define OEMCrypto_Terminate _oecc02
|
||||
#define OEMCrypto_InstallKeybox _oecc03
|
||||
@@ -246,12 +250,12 @@ typedef enum RSA_Padding_Scheme {
|
||||
#define OEMCrypto_GenerateDerivedKeys _oecc12
|
||||
#define OEMCrypto_GenerateSignature _oecc13
|
||||
#define OEMCrypto_GenerateNonce _oecc14
|
||||
#define OEMCrypto_LoadKeys _oecc15
|
||||
#define OEMCrypto_LoadKeys_V8 _oecc15
|
||||
#define OEMCrypto_RefreshKeys _oecc16
|
||||
#define OEMCrypto_SelectKey _oecc17
|
||||
#define OEMCrypto_RewrapDeviceRSAKey _oecc18
|
||||
#define OEMCrypto_LoadDeviceRSAKey _oecc19
|
||||
#define OEMCrypto_GenerateRSASignature _oecc20
|
||||
#define OEMCrypto_GenerateRSASignature_V8 _oecc20
|
||||
#define OEMCrypto_DeriveKeysFromSessionKey _oecc21
|
||||
#define OEMCrypto_APIVersion _oecc22
|
||||
#define OEMCrypto_SecurityLevel _oecc23
|
||||
@@ -266,27 +270,28 @@ typedef enum RSA_Padding_Scheme {
|
||||
#define OEMCrypto_ReportUsage _oecc32
|
||||
#define OEMCrypto_DeleteUsageEntry _oecc33
|
||||
#define OEMCrypto_DeleteUsageTable _oecc34
|
||||
#define OEMCrypto_LoadKeys _oecc35
|
||||
#define OEMCrypto_GenerateRSASignature _oecc36
|
||||
|
||||
/*
|
||||
* OEMCrypto_Initialize
|
||||
*
|
||||
|
||||
Initializes the crypto hardware.
|
||||
|
||||
Parameters:
|
||||
None
|
||||
|
||||
Returns:
|
||||
OEMCrypto_SUCCESS success
|
||||
OEMCrypto_ERROR_INIT_FAILED failed to initialize crypto hardware
|
||||
|
||||
Threading:
|
||||
No other function calls will be made while this function is running. This
|
||||
function will not be called again before OEMCrypto_Terminate().
|
||||
|
||||
Version:
|
||||
This method is supported by all API versions.
|
||||
|
||||
* Description:
|
||||
* Initialize the crypto firmware/hardware.
|
||||
*
|
||||
* Parameters:
|
||||
* N/A
|
||||
*
|
||||
* Threading:
|
||||
* No other function calls will be made while this function is running. This
|
||||
* function will not be called again before OEMCrypto_Terminate.
|
||||
*
|
||||
* Returns:
|
||||
* OEMCrypto_SUCCESS success
|
||||
* OEMCrypto_ERROR_INIT_FAILED failed to initialize crypto hardware
|
||||
*
|
||||
* Version:
|
||||
* This method is supported by all API versions.
|
||||
*/
|
||||
OEMCryptoResult OEMCrypto_Initialize(void);
|
||||
|
||||
@@ -428,8 +433,12 @@ OEMCryptoResult OEMCrypto_GenerateDerivedKeys(
|
||||
*
|
||||
* Because the nonce will be used to prevent replay attacks, it is desirable
|
||||
* that a rogue application cannot rapidly call this function until a
|
||||
* repeated nonce is created randomly. With this in mind, we require that
|
||||
* creation of more than 20 nonces will take at least one full second.
|
||||
* repeated nonce is created randomly. With this in mind, if more than 20
|
||||
* nonces are requested within one second, OEMCrypto will return an error
|
||||
* after the 20th and not generate any more nonces for the rest of the
|
||||
* second. After an error, if the application waits at least one second
|
||||
* before requesting more nonces, then OEMCrypto will reset the error
|
||||
* condition and generate valid nonces again.
|
||||
*
|
||||
* Parameters:
|
||||
* session (in) - crypto session identifier.
|
||||
@@ -1028,52 +1037,52 @@ OEMCryptoResult OEMCrypto_InstallKeybox(const uint8_t *keybox,
|
||||
/*
|
||||
* OEMCrypto_IsKeyboxValid
|
||||
*
|
||||
Validates the Widevine Keybox loaded into the security processor device. This
|
||||
method verifies two fields in the keybox:
|
||||
|
||||
Verify the MAGIC field contains a valid signature (such as, ‘k’’b’’o’’x’).
|
||||
|
||||
Compute the CRC using CRC-32-POSIX-1003.2 standard and compare the checksum
|
||||
to the CRC stored in the Keybox. The CRC is computed over the entire Keybox
|
||||
excluding the 4 bytes of the CRC (for example, Keybox[0..123]). For a
|
||||
description of the fields stored in the keybox, see Keybox Definition.
|
||||
|
||||
Parameters:
|
||||
none
|
||||
|
||||
Returns:
|
||||
OEMCrypto_SUCCESS
|
||||
OEMCrypto_ERROR_BAD_MAGIC
|
||||
OEMCrypto_ERROR_BAD_CRC
|
||||
|
||||
Threading:
|
||||
This function may be called simultaneously with any session functions.
|
||||
|
||||
Version:
|
||||
This method is supported in all API versions.
|
||||
* Description:
|
||||
* Validate the Widevine Keybox stored on the device.
|
||||
*
|
||||
* The API performs two verification steps on the Keybox. It first verifies
|
||||
* the MAGIC field contains a valid signature (must be 'kbox'). The API then
|
||||
* computes the CRC using CRC-32 (Posix 1003.2 standard) and compares the
|
||||
* checksum to the CRC stored in the Keybox. The CRC is computed over the
|
||||
* entire Keybox excluding the 4 CRC bytes (i.e. Keybox[0..123]).
|
||||
*
|
||||
* Parameters:
|
||||
* none
|
||||
*
|
||||
* Threading:
|
||||
* This function may be called simultaneously with any session functions.
|
||||
*
|
||||
* Returns:
|
||||
* OEMCrypto_SUCCESS
|
||||
* OEMCrypto_ERROR_BAD_MAGIC
|
||||
* OEMCrypto_ERROR_BAD_CRC
|
||||
*
|
||||
* Version:
|
||||
* This method is supported by all API versions.
|
||||
*/
|
||||
OEMCryptoResult OEMCrypto_IsKeyboxValid(void);
|
||||
|
||||
/*
|
||||
* OEMCrypto_GetDeviceID
|
||||
*
|
||||
Retrieve DeviceID from the Keybox.
|
||||
|
||||
Parameters:
|
||||
[out] deviceId - pointer to the buffer that receives the Device ID
|
||||
[in/out] idLength – on input, size of the caller’s device ID buffer. On
|
||||
output, the number of bytes written into the buffer.
|
||||
|
||||
Returns:
|
||||
OEMCrypto_SUCCESS success
|
||||
OEMCrypto_ERROR_SHORT_BUFFER if the buffer is too small to return device ID
|
||||
OEMCrypto_ERROR_NO_DEVICEID failed to return Device Id
|
||||
|
||||
Threading:
|
||||
This function may be called simultaneously with any session functions.
|
||||
|
||||
Version:
|
||||
This method is supported in all API versions.
|
||||
* Description:
|
||||
* Retrieve the device's unique identifier from the Keybox.
|
||||
*
|
||||
* Parameters:
|
||||
* deviceId (out) - pointer to the buffer that receives the Device ID
|
||||
* idLength (in/out) - on input, size of the caller's device ID buffer.
|
||||
* On output, the number of bytes written into the buffer.
|
||||
*
|
||||
* Threading:
|
||||
* This function may be called simultaneously with any session functions.
|
||||
*
|
||||
* Returns:
|
||||
* OEMCrypto_SUCCESS success
|
||||
* OEMCrypto_ERROR_SHORT_BUFFER buffer is too small to return the device ID
|
||||
* OEMCrypto_ERROR_NO_DEVICEID failed to return Device Id
|
||||
*
|
||||
* Version:
|
||||
* This method is supported by all API versions.
|
||||
*/
|
||||
OEMCryptoResult OEMCrypto_GetDeviceID(uint8_t* deviceID,
|
||||
size_t *idLength);
|
||||
@@ -1081,24 +1090,31 @@ OEMCryptoResult OEMCrypto_GetDeviceID(uint8_t* deviceID,
|
||||
/*
|
||||
* OEMCrypto_GetKeyData
|
||||
*
|
||||
Return the Key Data field from the Keybox.
|
||||
|
||||
Parameters:
|
||||
[out] keyData - pointer to the buffer to hold the Key Data field from the
|
||||
Keybox
|
||||
[in/out] keyDataLength – on input, the allocated buffer size. On output, the
|
||||
number of bytes in Key Data
|
||||
|
||||
Returns:
|
||||
OEMCrypto_SUCCESS success
|
||||
OEMCrypto_ERROR_SHORT_BUFFER if the buffer is too small to return KeyData
|
||||
OEMCrypto_ERROR_NO_KEYDATA
|
||||
|
||||
Threading:
|
||||
This function may be called simultaneously with any session functions.
|
||||
|
||||
Version:
|
||||
This method is supported in all API versions.
|
||||
* Description:
|
||||
* Returns the Key Data field from the Keybox. The Key Data field does not
|
||||
* need to be encrypted by an OEM root key, but may be if desired.
|
||||
*
|
||||
* If the Key Data field was encrypted with an OEM root key when the Keybox
|
||||
* was stored on the device, then this function should decrypt it and return
|
||||
* the clear Key Data. If the Key Data was not encrypted, then this function
|
||||
* should just access and return the clear Key data.
|
||||
*
|
||||
* Parameters:
|
||||
* keyData (out) - pointer to a caller-managed buffer to hold the Key Data
|
||||
* field from the Keybox
|
||||
* dataLength (in/out) - on input, the allocated buffer size. On output,
|
||||
* the number of bytes in KeyData.
|
||||
*
|
||||
* Threading:
|
||||
* This function may be called simultaneously with any session functions.
|
||||
*
|
||||
* Returns:
|
||||
* OEMCrypto_SUCCESS success
|
||||
* OEMCrypto_ERROR_SHORT_BUFFER the buffer is too small to return the KeyData
|
||||
* OEMCrypto_ERROR_NO_KEYDATA failed to return KeyData
|
||||
*
|
||||
* Version:
|
||||
* This method is supported by all API versions.
|
||||
*/
|
||||
OEMCryptoResult OEMCrypto_GetKeyData(uint8_t* keyData,
|
||||
size_t *keyDataLength);
|
||||
@@ -1106,23 +1122,25 @@ OEMCryptoResult OEMCrypto_GetKeyData(uint8_t* keyData,
|
||||
/*
|
||||
* OEMCrypto_GetRandom
|
||||
*
|
||||
Returns a buffer filled with hardware-generated random bytes, if supported by
|
||||
the hardware.
|
||||
|
||||
Parameters:
|
||||
[out] randomData - pointer to the buffer that receives random data
|
||||
[in] dataLength - length of the random data buffer in bytes
|
||||
|
||||
Returns:
|
||||
OEMCrypto_SUCCESS success
|
||||
OEMCrypto_ERROR_RNG_FAILED failed to generate random number
|
||||
OEMCrypto_ERROR_RNG_NOT_SUPPORTED function not supported
|
||||
|
||||
Threading:
|
||||
This function may be called simultaneously with any session functions.
|
||||
|
||||
Version:
|
||||
This method is supported in all API versions.
|
||||
* Description:
|
||||
* Return a buffer filled with hardware-generated random bytes. If the
|
||||
* hardware feature does not exist, return OEMCrypto_ERROR_RNG_NOT_SUPPORTED.
|
||||
*
|
||||
* Parameters:
|
||||
* randomData (out) - Pointer to caller-manager buffer that will receive the
|
||||
* random data.
|
||||
* dataLength (in) - Length of the random data buffer in bytes.
|
||||
*
|
||||
* Threading:
|
||||
* This function may be called simultaneously with any session functions.
|
||||
*
|
||||
* Returns:
|
||||
* OEMCrypto_SUCCESS success
|
||||
* OEMCrypto_ERROR_RNG_FAILED failed to generate random number
|
||||
* OEMCrypto_ERROR_RNG_NOT_SUPPORTED function not supported
|
||||
*
|
||||
* Version:
|
||||
* This method is supported by all API versions.
|
||||
*/
|
||||
OEMCryptoResult OEMCrypto_GetRandom(uint8_t* randomData,
|
||||
size_t dataLength);
|
||||
@@ -1263,8 +1281,6 @@ OEMCryptoResult OEMCrypto_RewrapDeviceRSAKey(OEMCrypto_SESSION session,
|
||||
* - padding. This is the wrapped key generated
|
||||
* - by OEMCrypto_RewrapDeviceRSAKey.
|
||||
* wrapped_rsa_key_length (in) - length of the wrapped key buffer, in bytes.
|
||||
* wrapped_rsa_key_iv (in) - The initialization vector used to encrypt
|
||||
* - wrapped_rsa_key.
|
||||
*
|
||||
* Threading:
|
||||
* This function may be called simultaneously with functions on other sessions,
|
||||
@@ -1546,41 +1562,25 @@ bool OEMCrypto_SupportsUsageTable();
|
||||
* that entry is “inactive”, then return OEMCrypto_ERROR_INVALID_SESSION.
|
||||
*
|
||||
* Parameters:
|
||||
* current (out) - this is the current HDCP version, based on the device itself,
|
||||
* and the display to which it is connected.
|
||||
* maximum (out) - this is the maximum supported HDCP version for the device,
|
||||
* ignoring any attached device.
|
||||
*
|
||||
* Threading:
|
||||
* This function may be called simultaneously with any other functions.
|
||||
* [in] session: crypto session identifier.
|
||||
* [in] in_buffer: pointer to memory containing data to be encrypted.
|
||||
* [in] buffer_length: length of the buffer, in bytes.
|
||||
* [in] iv: IV for encrypting data. Size is specified by the algorithm.
|
||||
* [in] algorithm: Specifies which encryption algorithm to use. See
|
||||
* OEMCrypto_Algorithm for valid values.
|
||||
* [out] out_buffer: pointer to buffer in which encrypted data should be stored.
|
||||
*
|
||||
* Returns:
|
||||
* OEMCrypto_SUCCESS
|
||||
* OEMCrypto_ERROR_UNKNOWN_FAILURE
|
||||
*
|
||||
* Version:
|
||||
* This method changed in API version 9.
|
||||
*/
|
||||
typedef uint8_t OEMCrypto_HDCP_Capability;
|
||||
OEMCryptoResult OEMCrypto_GetHDCPCapability(OEMCrypto_HDCP_Capability *current,
|
||||
OEMCrypto_HDCP_Capability *maximum);
|
||||
|
||||
/*
|
||||
* OEMCrypto_SupportsUsageTable()
|
||||
*
|
||||
* Description:
|
||||
* This is used to determine if the device can support a usage table. Since this
|
||||
* function is spoofable, it is not relied on for security purposes. It is for
|
||||
* information only. The usage table is described in the section above.
|
||||
*
|
||||
* Parameters:
|
||||
* none
|
||||
* OEMCrypto_SUCCESS success
|
||||
* OEMCrypto_ERROR_KEY_EXPIRED
|
||||
* OEMCrypto_ERROR_NO_DEVICE_KEY
|
||||
* OEMCrypto_ERROR_INVALID_SESSION
|
||||
* OEMCrypto_ERROR_INSUFFICIENT_RESOURCES
|
||||
* OEMCrypto_ERROR_UNKNOWN_FAILURE
|
||||
*
|
||||
* Threading:
|
||||
* This function may be called simultaneously with any other functions.
|
||||
*
|
||||
* Returns:
|
||||
* Returns true if the device can maintain a usage table. Returns false otherwise.
|
||||
* This function may be called simultaneously with functions on other sessions,
|
||||
* but not with other functions on this session.
|
||||
*
|
||||
* Version:
|
||||
* This method changed in API version 9.
|
||||
|
||||
@@ -43,6 +43,13 @@ namespace wvoec3 {
|
||||
#define Level3_Generic_Decrypt _lcc25
|
||||
#define Level3_Generic_Sign _lcc26
|
||||
#define Level3_Generic_Verify _lcc27
|
||||
#define Level3_GetHDCPCapability _lcc28
|
||||
#define Level3_SupportsUsageTable _lcc29
|
||||
#define Level3_UpdateUsageTable _lcc30
|
||||
#define Level3_DeactivateUsageEntry _lcc31
|
||||
#define Level3_ReportUsage _lcc32
|
||||
#define Level3_DeleteUsageEntry _lcc33
|
||||
#define Level3_DeleteUsageTable _lcc34
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -125,7 +132,7 @@ OEMCryptoResult Level3_GenerateRSASignature(OEMCrypto_SESSION session,
|
||||
size_t message_length,
|
||||
uint8_t* signature,
|
||||
size_t *signature_length,
|
||||
RSA_Padding_Scheme algorithm);
|
||||
RSA_Padding_Scheme padding_scheme);
|
||||
OEMCryptoResult Level3_DeriveKeysFromSessionKey(OEMCrypto_SESSION session,
|
||||
const uint8_t* enc_session_key,
|
||||
size_t enc_session_key_length,
|
||||
@@ -159,6 +166,26 @@ OEMCryptoResult Level3_Generic_Verify(OEMCrypto_SESSION session,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
const uint8_t* signature,
|
||||
size_t signature_length);
|
||||
OEMCryptoResult Level3_GetHDCPCapability(OEMCrypto_HDCP_Capability *current,
|
||||
OEMCrypto_HDCP_Capability *maximum);
|
||||
bool Level3_SupportsUsageTable();
|
||||
OEMCryptoResult Level3_UpdateUsageTable();
|
||||
OEMCryptoResult Level3_DeactivateUsageEntry(const uint8_t *pst,
|
||||
size_t pst_length);
|
||||
OEMCryptoResult Level3_ReportUsage(OEMCrypto_SESSION session,
|
||||
const uint8_t *pst,
|
||||
size_t pst_length,
|
||||
OEMCrypto_PST_Report *buffer,
|
||||
size_t *buffer_length);
|
||||
OEMCryptoResult Level3_DeleteUsageEntry(OEMCrypto_SESSION session,
|
||||
const uint8_t* pst,
|
||||
size_t pst_length,
|
||||
const uint8_t *message,
|
||||
size_t message_length,
|
||||
const uint8_t *signature,
|
||||
size_t signature_length);
|
||||
OEMCryptoResult Level3_DeleteUsageTable();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user