TI OAD API Documentation  9.14.00
Data Structures | Macros | Enumerations | Functions
HSMBareMetal.h File Reference

Interface to The HSM IP in a BareMetal-based implementation. More...

Go to the source code of this file.

Data Structures

struct  HSMBareMetal_AESOperationStruct
 Struct containing the parameters required for AES operations. More...
 
struct  HSMBareMetal_AssetOperationStruct
 Struct containing the parameters required for asset create and plaintext key load operations. More...
 
struct  HSMBareMetal_AssetPairKeyBlobStruct
 Struct containing the two buffers for symmetric key blob data. More...
 
struct  HSMBareMetal_AssetPairStruct
 Struct containing the two asset IDs returned for usage in a symmetric operation. More...
 
struct  HSMBareMetal_AsymAssetPairStruct
 Struct containing the two asset IDs returned for ECC operations. More...
 
struct  HSMBareMetal_CryptoKeyAssetStoreStruct
 Struct containing the AssetStore-based crypto key data. More...
 
struct  HSMBareMetal_CryptoKeyPlaintextStruct
 Struct containing the Plaintext-based crypto key data. More...
 
struct  HSMBareMetal_CryptoKeyStruct
 Struct containing the parameters required for AES operations. More...
 
struct  HSMBareMetal_ECCOperationStruct
 Struct containing the parameters required for ECC operations. More...
 
struct  HSMBareMetal_HASHOperationStruct
 Struct containing the parameters required for Hash operations. More...
 
struct  HSMBareMetal_MACOperationStruct
 Struct containing the parameters required for MAC operations. More...
 
struct  HSMBareMetal_RNGOperationStruct
 Struct containing the parameters required for RNG operations. More...
 
struct  HSMBareMetal_systemInfoVersionStruct
 Struct to store HSM system versions. More...
 

Macros

#define HSM_KEYBLOB_SIZE(keyLength)   (HSMBAREMETAL_AES_BLOCK_SIZE + keyLength)
 The expected size of an AES-SIV keyblob. More...
 
#define HSMBAREMETAL_AES_BLOCK_SIZE   16
 The size of an HSM block for symmetric operations.
 
#define HSMBAREMETAL_HUK_ASSET_NUMBER   0x61
 The Hardware Unique key (HUK) asset number in the HSM.
 
#define HSMBAREMETAL_STATUS_ERROR   ((int_fast16_t)-1)
 Generic error status code. More...
 
#define HSMBAREMETAL_STATUS_FEATURE_NOT_SUPPORTED   ((int_fast16_t)-13)
 The combination of parameters passed filtered to a feature that exists but is not supported yet.
 
#define HSMBAREMETAL_STATUS_HSM_ALREADY_INITIALIZED   ((int_fast16_t)-4)
 HSM IP is already initialized.
 
#define HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZED   ((int_fast16_t)-2)
 HSM IP has not been initialized yet. Call HSMBareMetal_init()
 
#define HSMBAREMETAL_STATUS_HUK_ALREADY_PROVISIONED   ((int_fast16_t)-12)
 This device has already been provisioned with a Hardware Unique Key (HUK).
 
#define HSMBAREMETAL_STATUS_HW_ERROR   ((int_fast16_t)-3)
 HSM IP reported a Hardware error. This renders the IP non-functional. More...
 
#define HSMBAREMETAL_STATUS_INVALID_INPUT_DATA_LENGTH   ((int_fast16_t)-14)
 The input data length is not block aligned.
 
#define HSMBAREMETAL_STATUS_INVALID_INPUT_PARAMETERS   ((int_fast16_t)-6)
 One or more of the provided parameter(s) do not match the supported features.
 
#define HSMBAREMETAL_STATUS_INVALID_MAC   ((int_fast16_t)-5)
 The MAC verification failed. More...
 
#define HSMBAREMETAL_STATUS_INVALID_MAC_LENGTH   ((int_fast16_t)-15)
 The mac length is invalid.
 
#define HSMBAREMETAL_STATUS_INVALID_PRIVATE_KEY_SIZE   ((int_fast16_t)-8)
 Private key size is invalid.
 
#define HSMBAREMETAL_STATUS_INVALID_PUBLIC_KEY_OCTET_VALUE   ((int_fast16_t)-10)
 The public key's first byte is an invalid value.
 
#define HSMBAREMETAL_STATUS_INVALID_PUBLIC_KEY_SIZE   ((int_fast16_t)-9)
 Public key size is invalid.
 
#define HSMBAREMETAL_STATUS_INVALID_SHARED_SECRET_KEY_SIZE   ((int_fast16_t)-11)
 Shared secret key size is invalid.
 
#define HSMBAREMETAL_STATUS_NRBG_ALREADY_IN_MODE   ((int_fast16_t)-7)
 the NRBG engine is already in mode.
 
#define HSMBAREMETAL_STATUS_SUCCESS   ((int_fast16_t)0)
 Successful status code. More...
 
#define HSMBareMetal_WAIT_FOREVER   ~(0)
 Wait forever for a result token define.
 

Enumerations

enum  HSMBareMetal_AESOperationMode {
  HSMBareMetal_AES_MODE_ECB = 0, HSMBareMetal_AES_MODE_CBC = 1, HSMBareMetal_AES_MODE_CTR = 2, HSMBareMetal_AES_MODE_CCM = 5,
  HSMBareMetal_AES_MODE_GCM = 7
}
 Enum for AES operation modes.
 
enum  HSMBareMetal_AssetOperationType { HSMBareMetal_ASSET_OPERATION_TYPE_LOAD_PLAINTEXT = 0, HSMBareMetal_ASSET_OPERATION_TYPE_LOAD_IMPORT_KEY_BLOB = 1, HSMBareMetal_ASSET_OPERATION_TYPE_LOAD_EXPORT_KEY_BLOB = 2 }
 Enum for the Asset operation type.
 
enum  HSMBareMetal_ECCOperationCurveLength {
  HSMBareMetal_PK_CURVE_LENGTH_224 = 224, HSMBareMetal_PK_CURVE_LENGTH_255 = 255, HSMBareMetal_PK_CURVE_LENGTH_256 = 256, HSMBareMetal_PK_CURVE_LENGTH_384 = 384,
  HSMBareMetal_PK_CURVE_LENGTH_512 = 512, HSMBareMetal_PK_CURVE_LENGTH_521 = 521
}
 Enum for ECC operation curve lengths.
 
enum  HSMBareMetal_ECCOperationCurveType {
  HSMBareMetal_PK_CURVE_TYPE_SEC_P_224_R1 = 1, HSMBareMetal_PK_CURVE_TYPE_SEC_P_256_R1 = 2, HSMBareMetal_PK_CURVE_TYPE_SEC_P_384_R1 = 3, HSMBareMetal_PK_CURVE_TYPE_SEC_P_521_R1 = 4,
  HSMBareMetal_PK_CURVE_TYPE_BRP_P_256_R1 = 5, HSMBareMetal_PK_CURVE_TYPE_BRP_P_384_R1 = 6, HSMBareMetal_PK_CURVE_TYPE_BRP_P_512_R1 = 7, HSMBareMetal_PK_CURVE_TYPE_25519 = 8
}
 Enum for ECC operation curve types.
 
enum  HSMBareMetal_ECCOperationDigestLength { HSMBareMetal_PK_DIGEST_LENGTH_224 = 224, HSMBareMetal_PK_DIGEST_LENGTH_256 = 256, HSMBareMetal_PK_DIGEST_LENGTH_384 = 384, HSMBareMetal_PK_DIGEST_LENGTH_512 = 512 }
 Enum for ECC operation digest lengths.
 
enum  HSMBareMetal_ECCOperationMode { HSMBareMetal_PK_MODE_ECDH_GEN_PUB_KEY = 1, HSMBareMetal_PK_MODE_ECDH_GEN_SHRD_SCRT = 2, HSMBareMetal_PK_MODE_ECDSA_SIGN = 3, HSMBareMetal_PK_MODE_ECDSA_VERIFY = 4 }
 Enum for ECC operation modes.
 
enum  HSMBareMetal_entropyType { ENTROPY_TYPE_DRBG = 0x0000, ENTROPY_TYPE_CRNG = 0x7264, ENTROPY_TYPE_TRNG = 0x5244 }
 Enum for entropy type. More...
 
enum  HSMBareMetal_HASHOperationMode { HSMBareMetal_HASH_MODE_SHA2_224 = 2, HSMBareMetal_HASH_MODE_SHA2_256 = 3, HSMBareMetal_HASH_MODE_SHA2_384 = 4, HSMBareMetal_HASH_MODE_SHA2_512 = 5 }
 Enum for Hash operation modes (algorithms).
 
enum  HSMBareMetal_HASHOperationType { HSMBareMetal_HASH_TYPE_INIT_TO_FINAL = 0, HSMBareMetal_HASH_TYPE_CONT_TO_FINAL = 1, HSMBareMetal_HASH_TYPE_INIT_TO_CONT = 2, HSMBareMetal_HASH_TYPE_CONT_TO_CONT = 3 }
 Enum for Hash operation types (hash mode).
 
enum  HSMBareMetal_KeyInput { HSMBareMetal_KEY_INPUT_PLAINTEXT = 0, HSMBareMetal_KEY_INPUT_ASSETSTORE = 1 }
 Enum for the AES operation mode.
 
enum  HSMBareMetal_MACOperationMode {
  HSMBareMetal_MAC_MODE_HMAC_224 = 2, HSMBareMetal_MAC_MODE_HMAC_256 = 3, HSMBareMetal_MAC_MODE_HMAC_384 = 4, HSMBareMetal_MAC_MODE_HMAC_512 = 5,
  HSMBareMetal_MAC_MODE_CMAC = 8, HSMBareMetal_MAC_MODE_CBC_MAC = 9
}
 Enum for the MAC operation mode.
 
enum  HSMBareMetal_NRBGMode { NRBG_TYPE_CRNG = 1, NRBG_TYPE_TRNG = 0 }
 Enum for the current NRBG IP for the HSM to pull entropy from. More...
 
enum  HSMBareMetal_operationAlgorithm { HSMBareMetal_OPERATION_ALGO_AES = 1, HSMBareMetal_OPERATION_ALGO_MAC = 2, HSMBareMetal_OPERATION_ALGO_HASH = 3, HSMBareMetal_OPERATION_ALGO_ECC = 4 }
 Enum for operation algorithm. More...
 
enum  HSMBareMetal_operationDirection { HSMBareMetal_OPERATION_DIR_ENC_GEN = 1, HSMBareMetal_OPERATION_DIR_DEC_VRFY = 2 }
 Enum for the direction of an AES operation. More...
 

Functions

int_fast16_t HSMBareMetal_AESOperation (HSMBareMetal_AESOperationStruct *operationStruct)
 Perform a Bare Metal AES Operation. More...
 
void HSMBareMetal_AESOperation_init (HSMBareMetal_AESOperationStruct *operationStruct)
 Function to initialize an HSMBareMetal_AESOperation struct to its default (all zeroes)
 
int_fast16_t HSMBareMetal_AssetOperation (HSMBareMetal_AssetOperationStruct *operationStruct)
 Perform a Bare Metal Asset Create and Load Operations. More...
 
void HSMBareMetal_AssetOperation_init (HSMBareMetal_AssetOperationStruct *operationStruct)
 Function to initialize an HSMBareMetal_AssetOperation struct to its default (all zeroes)
 
int_fast16_t HSMBareMetal_checkHSMStatus (void)
 Check HSM HW status. More...
 
void HSMBareMetal_CryptoKeyPlaintext_initKey (HSMBareMetal_CryptoKeyStruct *cryptoKey, uint8_t *key, size_t keyLength)
 Initializes a CryptoKey with plaintext encoding. More...
 
int_fast16_t HSMBareMetal_deInit (void)
 Close the HSMBareMetal Module. More...
 
int_fast16_t HSMBareMetal_ECCOperation (HSMBareMetal_ECCOperationStruct *operationStruct)
 Perform a Bare Metal Public Key Operation. More...
 
void HSMBareMetal_ECCOperation_init (HSMBareMetal_ECCOperationStruct *operationStruct)
 Function to initialize an HSMBareMetal_ECCOperation struct to its default (all zeroes)
 
int_fast16_t HSMBareMetal_freeAssetPair (HSMBareMetal_AssetPairStruct keyAssetPair)
 Perform a Bare Metal Asset Delete Operations. More...
 
int_fast16_t HSMBareMetal_freeKeyAsset (uint32_t *keyAssetID)
 Perform a Bare Metal Asset Delete Operation. More...
 
int_fast16_t HSMBareMetal_getHSMFirmwareVersion (HSMBareMetal_systemInfoVersionStruct *firmwareVersionStruct)
 Returns the HSM FW image version number (major, minor, and patch) More...
 
int_fast16_t HSMBareMetal_HASHOperation (HSMBareMetal_HASHOperationStruct *operationStruct)
 Perform a Bare Metal Hash Operation. More...
 
void HSMBareMetal_HASHOperation_init (HSMBareMetal_HASHOperationStruct *operationStruct)
 Function to initialize an HSMBareMetal_HASHOperation struct to its default (all zeroes)
 
int_fast16_t HSMBareMetal_init (void)
 Initialize HSMBareMetal Module. More...
 
int_fast16_t HSMBareMetal_MACOperation (HSMBareMetal_MACOperationStruct *operationStruct)
 Perform a Bare Metal MAC Operation. More...
 
void HSMBareMetal_MACOperation_init (HSMBareMetal_MACOperationStruct *operationStruct)
 Function to initialize an HSMBareMetal_MACOperation struct to its default (all zeroes)
 
int_fast16_t HSMBareMetal_provisionHUK (void)
 Provision the Hardware Unique Key (HUK) for this device. More...
 
int_fast16_t HSMBareMetal_RNGOperation (HSMBareMetal_RNGOperationStruct *operationStruct)
 Perform a Bare Metal Random Number Generation Operation. More...
 
void HSMBareMetal_RNGOperation_init (HSMBareMetal_RNGOperationStruct *operationStruct)
 Function to initialize an HSMBareMetal_RNGOperation struct to its default (all zeroes)
 
int_fast16_t HSMBareMetal_RNGSwitchNRBGMode (HSMBareMetal_NRBGMode NRBGMode)
 Switch the current NRBG engine: CRNG -> TRNG or vice-versa. More...
 
int_fast16_t HSMBareMetal_searchStaticAsset (uint32_t assetNumber, uint32_t *assetId)
 Perform an HSM OTP search for static asset. More...
 

Detailed Description

Interface to The HSM IP in a BareMetal-based implementation.


This module provides cryptographic functions for use of the Hardware Security Module.

Summary and List of Features:

NOTE: The above features do not support segmented operations. All operations are performed as a 'one-shot' operation. NOTE: the above features and their APIs are synchonous and conduct their operations in a polling return behavior-like fashion.

Usage

Before starting a BareMetal operation

Before starting a BareMetal operation

Starting a BareMetal operation

The HSMBareMetal implementation provides a simplified approach to leverage the Hardware Security Module (HSM) functional capability while also bypassing the complex SW architecture of the HSM and the RTOS while offering a centralized suit of APIs to conduct all major cryptographic operations.

This implementation delivers multiple features in a switch-like approach. For example, it allows multiple modes of an Advanced Encryption Standard (AES) operations in one API by simply choosing from an Enum for all AEAD operations such as (CCM, GCM, CBC, CTR, ECB, CMAC, CBC-MAC), (ENC, DEC).

Examples

// Import the HSMBareMetal defintions
#include <ti/drivers/cryptoutils/hsm/HSMBareMetal.h>
int_fast16_t status;
HSMBareMetal_AssetOperationStruct assetOperationStruct;
HSMBareMetal_AESOperationMode aesOperationMode = HSMBareMetal_AES_MODE_CCM;
HSMBareMetal_KeyInput keyInput = HSMBareMetal_KEY_INPUT_ASSETSTORE;
uint32_t encKeyAssetId = 0U;
uint32_t decKeyAssetId = 0U;
assetPair.encGenKeyAssetID = &encKeyAssetId;
assetPair.decVrfyKeyAssetID = &decKeyAssetId;
uint8_t nonce[] = "Thisisanonce";
uint8_t aad[] = "This string will be authenticated but not encrypted.";
uint8_t plaintext[] = "This string will be encrypted and authenticated.";
uint8_t mac[16];
uint8_t ciphertext[sizeof(plaintext)];
uint8_t keyingMaterial[32] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F};
status = HSMBareMetal_init();
{
// handle error
}
if (keyInput == HSMBareMetal_KEY_INPUT_ASSETSTORE)
{
HSMBareMetal_AssetOperation_init(&assetOperationStruct);
assetOperationStruct.keyAssetIDs = assetPair;
assetOperationStruct.isKeyGenerated = true;
assetOperationStruct.key = &keyingMaterial[0];
assetOperationStruct.keyLength = sizeof(keyingMaterial);
assetOperationStruct.algorithm = HSMBareMetal_OPERATION_ALGO_AES;
assetOperationStruct.aesOperationMode = aesOperationMode;
status = HSMBareMetal_AssetOperation(&assetOperationStruct);
{
// handle error
}
}
HSMBareMetal_AESOperation_init(&AESOperationStruct);
if (keyInput == HSMBareMetal_KEY_INPUT_ASSETSTORE)
{
AESOperationStruct.keyAssetID = encKeyAssetId;
}
else
{
AESOperationStruct.key = (uint8_t *)keyingMaterial;
}
AESOperationStruct.keyLength = sizeof(keyingMaterial);
AESOperationStruct.isKeyInAssetStore = keyInput;
AESOperationStruct.input = plaintext;
AESOperationStruct.inputLength = sizeof(plaintext);
AESOperationStruct.aad = aad;
AESOperationStruct.aadLength = sizeof(aad);
AESOperationStruct.mac = mac;
AESOperationStruct.macLength = sizeof(mac);
AESOperationStruct.nonce = nonce;
AESOperationStruct.nonceLength = sizeof(nonce);
AESOperationStruct.output = ciphertext;
AESOperationStruct.operationMode = aesOperationMode;
AESOperationStruct.operationDirection = HSMBareMetal_OPERATION_DIR_ENC_GEN;
status = HSMBareMetal_AESOperation(&AESOperationStruct);
{
// handle error
}
if (keyInput == HSMBareMetal_KEY_INPUT_ASSETSTORE)
{
status = HSMBareMetal_freeAssetPair(assetPair);
}

Macro Definition Documentation

§ HSM_KEYBLOB_SIZE

#define HSM_KEYBLOB_SIZE (   keyLength)    (HSMBAREMETAL_AES_BLOCK_SIZE + keyLength)

The expected size of an AES-SIV keyblob.

Note: keyLength is the size of the Asset in octects (bytes).

§ HSMBAREMETAL_STATUS_ERROR

#define HSMBAREMETAL_STATUS_ERROR   ((int_fast16_t)-1)

Generic error status code.

Functions return HSMBAREMETAL_STATUS_ERROR if the function was not executed successfully and no more specific error is applicable.

§ HSMBAREMETAL_STATUS_HW_ERROR

#define HSMBAREMETAL_STATUS_HW_ERROR   ((int_fast16_t)-3)

HSM IP reported a Hardware error. This renders the IP non-functional.

To fix this, a hard reset must be performed on the device.

§ HSMBAREMETAL_STATUS_INVALID_MAC

#define HSMBAREMETAL_STATUS_INVALID_MAC   ((int_fast16_t)-5)

The MAC verification failed.

A MAC operation-related error code.

Functions return HSMBAREMETAL_STATUS_INVALID_MAC if the MAC computed for the provided (key, message) pair did not match the MAC provided.

§ HSMBAREMETAL_STATUS_SUCCESS

#define HSMBAREMETAL_STATUS_SUCCESS   ((int_fast16_t)0)

Successful status code.

Functions return HSMBAREMETAL_STATUS_SUCCESS if the function was executed successfully.

Enumeration Type Documentation

§ HSMBareMetal_entropyType

Enum for entropy type.

For key generation, users MUST choose #ENTROPY_TYPE_DRBG.

§ HSMBareMetal_NRBGMode

Enum for the current NRBG IP for the HSM to pull entropy from.

By default, the HSM is set to use the #NRBG_TYPE_CRNG.

§ HSMBareMetal_operationAlgorithm

Enum for operation algorithm.

These values to be used in Dynamic asset creation to determine the proper asset Policy for an HSM Key.

§ HSMBareMetal_operationDirection

Enum for the direction of an AES operation.

  • Encryption/Decryption for (CCM, GCM, CBC, CTR, ECB)
  • Generate/Verify for (CMAC, CBC-MAC, HMAC)

Function Documentation

§ HSMBareMetal_AESOperation()

int_fast16_t HSMBareMetal_AESOperation ( HSMBareMetal_AESOperationStruct operationStruct)

Perform a Bare Metal AES Operation.

Precondition
HSMBareMetal must be initialized using HSMBareMetal_init()
Parameters
[in]operationStructPointer to the operation's structure.
Return values
HSMBAREMETAL_STATUS_SUCCESSThe operation succeeded.
HSMBAREMETAL_STATUS_ERRORThe operation failed.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.
HSMBAREMETAL_STATUS_INVALID_INPUT_PARAMETERSOne or more of the input parameters is incorrect.

§ HSMBareMetal_AssetOperation()

int_fast16_t HSMBareMetal_AssetOperation ( HSMBareMetal_AssetOperationStruct operationStruct)

Perform a Bare Metal Asset Create and Load Operations.

Precondition
HSMBareMetal must be initialized using HSMBareMetal_init()

!!!!Important!!!! When operationStruct.isKeyGenerated is set to true, the HSMBareMetal module will IGNORE the key input parameter and instead generate a random key internally and use that as the data for an asset create and load operations.

The user MUST specify buffers for both #HSMBareMetal_AssetPairStruct.encGenKeyAssetID and #HSMBareMetal_AssetPairStruct.decVrfyKeyAssetID inside of HSMBareMetal_AssetPairStruct. This API creates TWO assets and returns the corresponding asset IDs for them.

Parameters
[in]operationStructPointer to the operation's structure.
Return values
HSMBAREMETAL_STATUS_SUCCESSThe operation succeeded.
HSMBAREMETAL_STATUS_ERRORThe operation failed.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.
HSMBAREMETAL_STATUS_INVALID_INPUT_PARAMETERSOne or more of the input parameters is incorrect.

§ HSMBareMetal_checkHSMStatus()

int_fast16_t HSMBareMetal_checkHSMStatus ( void  )

Check HSM HW status.

Return values
HSMBAREMETAL_STATUS_HSM_ALREADY_INITIALIZEDHSM is initialized properly and ready for use.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.

§ HSMBareMetal_CryptoKeyPlaintext_initKey()

void HSMBareMetal_CryptoKeyPlaintext_initKey ( HSMBareMetal_CryptoKeyStruct cryptoKey,
uint8_t *  key,
size_t  keyLength 
)

Initializes a CryptoKey with plaintext encoding.

Parameters
[in]cryptoKeyPointer to a CryptoKey which will be initialized to type HSMBareMetal_KEY_INPUT_PLAINTEXT and ready for use
[in]keyPointer to keying material
[in]keyLengthLength of keying material in bytes

§ HSMBareMetal_deInit()

int_fast16_t HSMBareMetal_deInit ( void  )

Close the HSMBareMetal Module.

This operation turns off the HSM and clears all static objects.

§ HSMBareMetal_ECCOperation()

int_fast16_t HSMBareMetal_ECCOperation ( HSMBareMetal_ECCOperationStruct operationStruct)

Perform a Bare Metal Public Key Operation.

Precondition
HSMBareMetal must be initialized using HSMBareMetal_init()

!!!!Important!!!! For ECC operations:

  • ECDSA sign and verify operations do not support curve type: CURVE25519.
  • All input keys must be supplied in plaintext.
  • ECC operations takes in a digest (not the input buffer). Therefore, the input buffer must be hashed using HSMBareMetal_HASHOperation() API and supplying the digest in the ECC operation.
  • Digest length must match curve length. Ex. For SEC_P_384_R1 and BRP_P_384_R1 curve types, the digest must be generated using SHA2-384. Ex. For BRP_P_512_R1 and SEC_P_521_R1 curve types, the digest must be generated using SHA2-512.
Parameters
[in]operationStructPointer to the operation's structure.
Return values
HSMBAREMETAL_STATUS_SUCCESSThe operation succeeded.
HSMBAREMETAL_STATUS_ERRORThe operation failed.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.
HSMBAREMETAL_STATUS_INVALID_INPUT_PARAMETERSOne or more of the input parameters is incorrect.

§ HSMBareMetal_freeAssetPair()

int_fast16_t HSMBareMetal_freeAssetPair ( HSMBareMetal_AssetPairStruct  keyAssetPair)

Perform a Bare Metal Asset Delete Operations.

Precondition
HSMBareMetal must be initialized using HSMBareMetal_init() and a previous call to HSMBareMetal_AssetOperation()
Parameters
[in]keyAssetPairENC/GEN and DEC/VRFY asset IDs
Return values
HSMBAREMETAL_STATUS_SUCCESSThe operation succeeded.
HSMBAREMETAL_STATUS_ERRORThe operation failed.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.
HSMBAREMETAL_STATUS_INVALID_INPUT_PARAMETERSOne or more of the input parameters is incorrect.

§ HSMBareMetal_freeKeyAsset()

int_fast16_t HSMBareMetal_freeKeyAsset ( uint32_t *  keyAssetID)

Perform a Bare Metal Asset Delete Operation.

Precondition
HSMBareMetal must be initialized using HSMBareMetal_init() and a previous call to HSMBareMetal_AssetOperation()
Parameters
[in]keyAssetIDAsset ID
Return values
HSMBAREMETAL_STATUS_SUCCESSThe operation succeeded.
HSMBAREMETAL_STATUS_ERRORThe operation failed.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.

§ HSMBareMetal_getHSMFirmwareVersion()

int_fast16_t HSMBareMetal_getHSMFirmwareVersion ( HSMBareMetal_systemInfoVersionStruct firmwareVersionStruct)

Returns the HSM FW image version number (major, minor, and patch)

Precondition
HSMBareMetal must be initialized using HSMBareMetal_init()

This function sends a system info token and extracts HSM version numbers and returns the FW version.

Parameters
[in]firmwareVersionStructfirmware version structure
Return values
HSMBAREMETAL_STATUS_SUCCESSSystem info token returned data successfully.
HSMBAREMETAL_STATUS_ERRORError. System info failed or HSMBareMetal is not initialized.

§ HSMBareMetal_HASHOperation()

int_fast16_t HSMBareMetal_HASHOperation ( HSMBareMetal_HASHOperationStruct operationStruct)

Perform a Bare Metal Hash Operation.

Precondition
HSMBareMetal must be initialized using HSMBareMetal_init()
Parameters
[in]operationStructPointer to the operation's structure.
Return values
HSMBAREMETAL_STATUS_SUCCESSThe operation succeeded.
HSMBAREMETAL_STATUS_ERRORThe operation failed.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.
HSMBAREMETAL_STATUS_INVALID_INPUT_PARAMETERSOne or more of the input parameters is incorrect.

§ HSMBareMetal_init()

int_fast16_t HSMBareMetal_init ( void  )

Initialize HSMBareMetal Module.

The initialization process include:

  1. Turning on the HSM IP by enabling the clock.
  2. Initializing the HSM Mailboxes and corresponding registers.
  3. Booting the HSM (Sending a boot token and ensuring that the HSM FW image is accepted).
Return values
HSMBAREMETAL_STATUS_SUCCESSInitialization process was successful
HSMBAREMETAL_STATUS_ERRORInitialization process was unsuccessful.
HSMBAREMETAL_STATUS_HSM_ALREADY_INITIALIZEDHSM already initialized.

§ HSMBareMetal_MACOperation()

int_fast16_t HSMBareMetal_MACOperation ( HSMBareMetal_MACOperationStruct operationStruct)

Perform a Bare Metal MAC Operation.

Precondition
HSMBareMetal must be initialized using HSMBareMetal_init()
Parameters
[in]operationStructPointer to the operation's structure.
Return values
HSMBAREMETAL_STATUS_SUCCESSThe operation succeeded.
HSMBAREMETAL_STATUS_ERRORThe operation failed.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.
HSMBAREMETAL_STATUS_INVALID_INPUT_PARAMETERSOne or more of the input parameters is incorrect.

§ HSMBareMetal_provisionHUK()

int_fast16_t HSMBareMetal_provisionHUK ( void  )

Provision the Hardware Unique Key (HUK) for this device.

This is an operation that should be done only once per device lifetime.

Precondition
Must call HSMBareMetal_init() prior.
Return values
HSMBAREMETAL_STATUS_SUCCESSThe operation succeeded.
HSMBAREMETAL_STATUS_HUK_ALREADY_PROVISIONEDHUK already provisioned.
HSMBAREMETAL_STATUS_ERRORThe operation failed.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.

§ HSMBareMetal_RNGOperation()

int_fast16_t HSMBareMetal_RNGOperation ( HSMBareMetal_RNGOperationStruct operationStruct)

Perform a Bare Metal Random Number Generation Operation.

Precondition
HSMBareMetal must be initialized using HSMBareMetal_init()

!!!!IMPORTANT!!!!

  1. Size must be 0 < x < (2^16 Bytes).
  2. For DRBG data, size must be 32-bit aligned. (Multiple of 4 bytes).
  3. For NRBG data, size can be anywhere between 1-256 bytes and multiple of 256 bytes if larger than 256 bytes.

For symmetric key generation, users MUST choose #ENTROPY_TYPE_DRBG. However, the HSMBareMetal_AssetOperation() API provide an In-API key generation feature that generates a key, creates two assets (ENC/GEN and DEC/VRFY) and loads the key into both assets and returns an a pair of asset IDs.

Parameters
[in]operationStructPointer to the operation's structure.
Return values
HSMBAREMETAL_STATUS_SUCCESSThe operation succeeded.
HSMBAREMETAL_STATUS_ERRORThe operation failed.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.
HSMBAREMETAL_STATUS_INVALID_INPUT_PARAMETERSOne or more of the input parameters is incorrect.

§ HSMBareMetal_RNGSwitchNRBGMode()

int_fast16_t HSMBareMetal_RNGSwitchNRBGMode ( HSMBareMetal_NRBGMode  NRBGMode)

Switch the current NRBG engine: CRNG -> TRNG or vice-versa.

Precondition
HSMBareMetal must be initialized using HSMBareMetal_init()
Parameters
[in]NRBGModeUsed to select which NRBG noise source to use.
Return values
HSMBAREMETAL_STATUS_SUCCESSThe operation succeeded.
HSMBAREMETAL_STATUS_ERRORThe operation failed.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.
HSMBAREMETAL_STATUS_INVALID_INPUT_PARAMETERSOne or more of the input parameters is incorrect.

§ HSMBareMetal_searchStaticAsset()

int_fast16_t HSMBareMetal_searchStaticAsset ( uint32_t  assetNumber,
uint32_t *  assetId 
)

Perform an HSM OTP search for static asset.

This API searches the HSM OTP for the specified asset number and returns found or not found.

Parameters
[in]assetNumberStatic asset number
[out]assetIdThe corresponding asset ID
Return values
HSMBAREMETAL_STATUS_SUCCESSAsset found.
HSMBAREMETAL_STATUS_ERRORAsset not found.
HSMBAREMETAL_STATUS_HSM_NOT_INITIALIZEDCall HSMBareMetal_init() first.
HSMBAREMETAL_STATUS_HW_ERRORHSM in fatal mode. Reset Device.