RAFW Flexible Software Package Documentation  Release v2.0.1

 
R_CC312_OPENABLE_W

Functions

void init_crypto_primitives (const CRYPTO_PRIMITIVE_TYPE *primitive)
 Initiaize ROMCrypto Library. More...
 
void R_CC312_Debug_SecureBoot (uint32_t mode)
 Set Debug Mode. More...
 
uint32_t R_CC312_Debug_SecureBoot_Mode (void)
 Set Debug Mode. More...
 
uint32_t R_CC312_Debug_Get_ErrorCode (void)
 Get Error Mode. More...
 
uint32_t R_CC312_SecureBoot (uint32_t taddress, uint32_t *jaddress, void(*stopproc)(void *))
 Run SecureBoot. More...
 
uint32_t R_CC312_SecureDebug (void *fhandler, uint32_t faddress)
 Run SecureDebug for DCU Protection. More...
 
uint32_t R_CC312_SecureSocID (void)
 Check Soc-ID. More...
 
uint32_t R_CC312_SecureSocID_internal (uint8_t *pSocID)
 Get Soc-ID. More...
 
uint32_t R_CC312_SecureBoot_Fatal (uint32_t *rcRmaFlag)
 Force the Fatal Error for Secure Boot (test only) More...
 
uint32_t R_CC312_SecureBoot_RMA (void)
 Manually run the RMA process to erase the OTP secrets. (test only) More...
 
uint32_t R_CC312_SecureBoot_CMPU (uint8_t *pCmpuData, uint32_t rflag)
 Register CMPU to write HUKey & CMKeys in OTP. More...
 
uint32_t R_CC312_SecureBoot_DMPU (uint8_t *pDmpuData)
 Register DMPU to write DMKeys in OTP. More...
 
uint32_t R_CC312_SecureBoot_GetLock (void)
 Get the OTP flag used to check whether to run a SecureBoot. More...
 
uint32_t R_CC312_SecureBoot_SetLock (void)
 Set the OTP flag to lock the SecureBoot. More...
 
void R_CC312_SecureBoot_OTPLock (uint32_t mode)
 Lock/Unlock the OTP Protection. More...
 
uint32_t R_CC312_SecureBoot_SecureLCS (void)
 Check if current state is a Secure-Lcs. More...
 
uint32_t R_CC312_SecureBoot_GetLock2 (void)
 Get the OTP flag used to check whether to run a SecureBoot (optional). More...
 
uint32_t R_CC312_SecureBoot_SetLock2 (void)
 Set the OTP flag to lock the SecureBoot (optional). More...
 
uint32_t R_CC312_Secure_Asset (uint32_t Owner, uint32_t AssetID, uint32_t *InAssetData, uint32_t AssetSize, uint32_t *OutAssetData, uint32_t *OutAssetSize)
 Decrypt SecureAsset. More...
 
int32_t R_CC312_Secure_Asset_RuntimePack (AssetKeyType_t KeyType, uint32_t noncetype, AssetUserKeyData_t *KeyData, uint32_t AssetID, char *title, uint8_t *InAssetData, uint32_t AssetSize, uint8_t *OutAssetPkgData)
 Encrypt RuntimeAsset. More...
 
int32_t R_CC312_Secure_Asset_RuntimeUnpack (AssetKeyType_t KeyType, AssetUserKeyData_t *KeyData, uint32_t AssetID, uint8_t *InAssetPkgData, uint32_t AssetPkgSize, uint8_t *OutAssetData)
 Decrypt RuntimeAsset. More...
 
void R_CC312_Crypto_ClkMgmt (uint32_t mode)
 Initialize Crypto Clock. More...
 
uint32_t R_CC312_Crypto_Init (uint32_t rflag)
 Initialize Crypto Engine. More...
 
void R_CC312_Crypto_ReInit (void)
 Re-initialize Crypto Engine after wakeup.
 
void R_CC312_Crypto_Finish (void)
 Deinitialize Crypto Engine.
 
void R_CC312_SetCryptoCoreClkGating (uint32_t mode)
 Enable the clock of HW Crypto. More...
 
int R_CC312_Crypto_TRNG (uint32_t sampleCount, uint32_t buffSize, uint8_t *pRndWorkBuff)
 Reads requested length of random data from the TRNG. Generate buffSize of random bytes and store them in pRndWorkBuff buffer. More...
 

Detailed Description

Data Structures

struct  CRYPTO_PRIMITIVE_TYPE
 Structure for Retargeted symbols in ROMCrypto. More...
 
struct  AssetUserKeyData_t
 User Key Format. More...
 
struct  AssetInfoData_t
 Encrypted RunTime Asset Info. More...
 

Macros

#define CC_RUNASSET_PROV_TOKEN
 ID code for RunTime Asset.
 
#define CC_RUNASSET_PROV_VERSION
 Version code for RunTime Asset.
 

Enumerations

enum  AssetKeyType_t
 KEY Type list. More...
 

Data Structure Documentation

◆ CRYPTO_PRIMITIVE_TYPE

struct CRYPTO_PRIMITIVE_TYPE

Structure for Retargeted symbols in ROMCrypto.

Data Fields

void(* retarget_dump )(uint16_t tag, void *srcdata, uint16_t len)
 callback of hexadump function
 
void(* retarget_text )(uint16_t tag, void *srcdata, uint16_t len)
 callback of puts function
 
void(* retarget_vprint )(uint16_t tag, const char *format, va_list arg)
 callback of vprintf function
 
char(* retarget_getchar )(uint32_t mode)
 callback of getchar function
 
void *(* raw_malloc )(size_t size)
 callback of malloc function
 
void *(* raw_realloc )(void *Buffer, size_t NewSize)
 callback of realloc function
 
void(* raw_free )(void *f)
 callback of free function
 
uint32_t(* raw_otpread )(uint32_t otpwoffset)
 callback of OTP read Wrapper
 
uint32_t(* raw_otpwrite )(uint32_t otpwoffset, uint32_t otpData)
 callback of OTP write Wrapper
 
void *(* flash_image_open )(uint32_t mode, uint32_t imghdr_offset, void *locker)
 callback for flash access
 
void(* flash_image_close )(void *handler)
 callback for flash access
 
uint32_t(* flash_image_check )(void *handler, uint32_t imgtype, uint32_t imghdr_offset)
 callback for flash access
 
void *(* flash_image_certificate )(void *handler, uint32_t imghdr_offset, uint32_t certindex, uint32_t *certsize)
 callback for flash access
 
uint32_t(* flash_image_extract )(void *handler, uint32_t imghdr_offset, uint32_t *load_addr, uint32_t *jmp_addr)
 callback for flash access
 
uint32_t(* flash_image_load )(void *handler, uint32_t imghdr_offset, uint32_t *load_addr, uint32_t *jmp_addr)
 callback for flash access
 
uint32_t(* flash_image_read )(void *handler, uint32_t img_offset, void *load_addr, uint32_t img_secsize)
 callback for flash access
 
void(* rtosdelay )(uint32_t usec)
 callback of OS delay function
 
uint64_t(* tickmeasure )(uint32_t flag)
 callback for time measurement
 

◆ AssetUserKeyData_t

struct AssetUserKeyData_t

User Key Format.

Data Fields
uint8_t * pKey

key data

size_t keySize

key size

◆ AssetInfoData_t

struct AssetInfoData_t

Encrypted RunTime Asset Info.

Data Fields
uint32_t token

ID for package provisioning

uint32_t version

version info

uint32_t assetSize

size of asset

Enumeration Type Documentation

◆ AssetKeyType_t

KEY Type list.

Enumerator
ASSET_USER_KEY 

User Key

ASSET_ROOT_KEY 

HUK Key

ASSET_KCP_KEY 

DMKey - Kcp, asset(product) encryption key

ASSET_KCE_KEY 

DMKey - Kcp, code encryption key

ASSET_KPICV_KEY 

CMKey - Kpicv, asset(product) encryption key

ASSET_KCEICV_KEY 

CMKey - Kceicv, code encryption key

Function Documentation

◆ init_crypto_primitives()

void init_crypto_primitives ( const CRYPTO_PRIMITIVE_TYPE primitive)

Initiaize ROMCrypto Library.

Parameters
[in]primitiveretargeted symbols used in RomCrypto

◆ R_CC312_Debug_SecureBoot()

void R_CC312_Debug_SecureBoot ( uint32_t  mode)

Set Debug Mode.

Parameters
[in]modedebug mode

◆ R_CC312_Debug_SecureBoot_Mode()

uint32_t R_CC312_Debug_SecureBoot_Mode ( void  )

Set Debug Mode.

Return values
modecurrent debug mode

◆ R_CC312_Debug_Get_ErrorCode()

uint32_t R_CC312_Debug_Get_ErrorCode ( void  )

Get Error Mode.

Return values
codelastest error mode

◆ R_CC312_SecureBoot()

uint32_t R_CC312_SecureBoot ( uint32_t  taddress,
uint32_t *  jaddress,
void(*)(void *)  stopproc 
)

Run SecureBoot.

Parameters
[in]taddressflash memory offset of the image
[out]jaddressentry point address of the bootable image
if jaddress == NULL, then CPU will branch into the APP automatically.
[in]stopproccallback to safely finish a boot sequence before branching APP
Return values
truefunction succeeded
falsefunction failed

◆ R_CC312_SecureDebug()

uint32_t R_CC312_SecureDebug ( void *  fhandler,
uint32_t  faddress 
)

Run SecureDebug for DCU Protection.

Parameters
[in]fhandlerSFLASH handler
[out]faddressflash memory offset of the image
Return values
truefunction succeeded
falsefunction failed
Note
This function runs internally during POR boot.
So if you run this function in your app, it won't work.

◆ R_CC312_SecureSocID()

uint32_t R_CC312_SecureSocID ( void  )

Check Soc-ID.

Return values
InSecure-Lcs, SocID is returned
otherwisecurruent Lcs is returned.

◆ R_CC312_SecureSocID_internal()

uint32_t R_CC312_SecureSocID_internal ( uint8_t *  pSocID)

Get Soc-ID.

Parameters
[in,out]pSocIDempty output buffer for storing the SocID

◆ R_CC312_SecureBoot_Fatal()

uint32_t R_CC312_SecureBoot_Fatal ( uint32_t *  rcRmaFlag)

Force the Fatal Error for Secure Boot (test only)

Parameters
[in]rcRmaFlagRMA flag
Return values
Zerofunction succeeded
Non-Zerofunction failed

◆ R_CC312_SecureBoot_RMA()

uint32_t R_CC312_SecureBoot_RMA ( void  )

Manually run the RMA process to erase the OTP secrets. (test only)

Return values
truefunction succeeded
falsefunction failed

◆ R_CC312_SecureBoot_CMPU()

uint32_t R_CC312_SecureBoot_CMPU ( uint8_t *  pCmpuData,
uint32_t  rflag 
)

Register CMPU to write HUKey & CMKeys in OTP.

Parameters
[in]pCmpuDatadata pointer of CMPU
[in]rflagTRNG test feature. Set '0' to avoid the collision of HUKey between products.
Return values
truefunction succeeded
falsefunction failed

◆ R_CC312_SecureBoot_DMPU()

uint32_t R_CC312_SecureBoot_DMPU ( uint8_t *  pDmpuData)

Register DMPU to write DMKeys in OTP.

Parameters
[in]pDmpuDatadata pointer of DMPU
Return values
truefunction succeeded
falsefunction failed

◆ R_CC312_SecureBoot_GetLock()

uint32_t R_CC312_SecureBoot_GetLock ( void  )

Get the OTP flag used to check whether to run a SecureBoot.

Return values
trueSecureBoot locked (enabled)
falseSecureBoot unlocked (disabled)

◆ R_CC312_SecureBoot_SetLock()

uint32_t R_CC312_SecureBoot_SetLock ( void  )

Set the OTP flag to lock the SecureBoot.

Return values
truefunction succeeded
falsefunction failed

◆ R_CC312_SecureBoot_OTPLock()

void R_CC312_SecureBoot_OTPLock ( uint32_t  mode)

Lock/Unlock the OTP Protection.

Parameters
[in]modelock value (1 : unlock for writing data, 0: lock)

◆ R_CC312_SecureBoot_SecureLCS()

uint32_t R_CC312_SecureBoot_SecureLCS ( void  )

Check if current state is a Secure-Lcs.

Return values
truefunction succeeded
falsefunction failed

◆ R_CC312_SecureBoot_GetLock2()

uint32_t R_CC312_SecureBoot_GetLock2 ( void  )

Get the OTP flag used to check whether to run a SecureBoot (optional).

Return values
trueSecureBoot locked (enabled)
falseSecureBoot unlocked (disabled)

◆ R_CC312_SecureBoot_SetLock2()

uint32_t R_CC312_SecureBoot_SetLock2 ( void  )

Set the OTP flag to lock the SecureBoot (optional).

Return values
truefunction succeeded
falsefunction failed

◆ R_CC312_Secure_Asset()

uint32_t R_CC312_Secure_Asset ( uint32_t  Owner,
uint32_t  AssetID,
uint32_t *  InAssetData,
uint32_t  AssetSize,
uint32_t *  OutAssetData,
uint32_t *  OutAssetSize 
)

Decrypt SecureAsset.

Parameters
[in]Ownerkey type (1: CMKey - Kpicv, 2: DMKey - Kcp)
[in]AssetIDunique id (part of nonce)
[in]InAssetDataencrypted asset data
[in]AssetSizesize of InAssetData
[out]OutAssetDatadecrypted asset data
[in,out]OutAssetSizesize of decrypted asset data
Return values
Non-Zerosize of OutAssetData
Zerofunction failed

◆ R_CC312_Secure_Asset_RuntimePack()

int32_t R_CC312_Secure_Asset_RuntimePack ( AssetKeyType_t  KeyType,
uint32_t  noncetype,
AssetUserKeyData_t KeyData,
uint32_t  AssetID,
char *  title,
uint8_t *  InAssetData,
uint32_t  AssetSize,
uint8_t *  OutAssetPkgData 
)

Encrypt RuntimeAsset.

Parameters
[in]KeyTypekey type (
See also
AssetKeyType_t)
Parameters
[in]noncetypemethod to generate a nonce (0xFFFFFFFF: PRNG, otherwise: TRNG)
[in]KeyDataUser Key data
[in]AssetIDunique id of RuntimeAsset
[in]titleunique tag of RuntimeAsset
[in]InAssetDataplaintext of RuntimeAsset
[in]AssetSizesize of the plaintext. it must be multiply of 16 bytes.
[in,out]OutAssetPkgDataempty output buffer for storing the encrypted RuntimeAsset
Return values
Non-Zerosize of OutAssetData
Zerofunction failed

◆ R_CC312_Secure_Asset_RuntimeUnpack()

int32_t R_CC312_Secure_Asset_RuntimeUnpack ( AssetKeyType_t  KeyType,
AssetUserKeyData_t KeyData,
uint32_t  AssetID,
uint8_t *  InAssetPkgData,
uint32_t  AssetPkgSize,
uint8_t *  OutAssetData 
)

Decrypt RuntimeAsset.

Parameters
[in]KeyTypekey type (
See also
AssetKeyType_t)
Parameters
[in]KeyDataUser Key data
[in]AssetIDunique id of RuntimeAsset
[in]InAssetPkgDataencrypted RuntimeAsset
[in]AssetPkgSizesize of the encrypted RuntimeAsset
[in,out]OutAssetDataempty output buffer for storing the decrypted RuntimeAsset
Return values
Non-Zerosize of OutAssetData
Zerofunction failed

◆ R_CC312_Crypto_ClkMgmt()

void R_CC312_Crypto_ClkMgmt ( uint32_t  mode)

Initialize Crypto Clock.

Parameters
[in]modepll callbak mode
TRUE is support the pll callback of Crypto Engine.

◆ R_CC312_Crypto_Init()

uint32_t R_CC312_Crypto_Init ( uint32_t  rflag)

Initialize Crypto Engine.

Parameters
[in]rflagparameter for TRNG initialization
Return values
truefunction succeeded
falsefunction failed

◆ R_CC312_SetCryptoCoreClkGating()

void R_CC312_SetCryptoCoreClkGating ( uint32_t  mode)

Enable the clock of HW Crypto.

Parameters
[in]modeif true, then the clock is enabled, othersize it is diabled.

◆ R_CC312_Crypto_TRNG()

int R_CC312_Crypto_TRNG ( uint32_t  sampleCount,
uint32_t  buffSize,
uint8_t *  pRndWorkBuff 
)

Reads requested length of random data from the TRNG. Generate buffSize of random bytes and store them in pRndWorkBuff buffer.

Parameters
[in]sampleCountset sampling ratio (rng_clocks) between consecutive bits.
[in]buffSizethe length of random bytes.
[in,out]pRndWorkBuffempty output buffer for storing the random bytes.
Return values
Zerofunction succeeded
Non-Zerofunction failed