CC13xx Driver Library
[rom_crypto] Software Crypto

Data Structures

struct  SHA256_memory_t
 A SHA256_memory_t variable of this type must be allocated before running any SHA256 functions. More...
 

Functions

void AES_ECB_EncryptData (uint8_t *text, uint16_t textLen, uint8_t *aesKey)
 Use a random 128 bit key to encrypt data with the AES. More...
 
void AES_ECB_DecryptData (uint8_t *text, uint16_t textLen, uint8_t *aesKey)
 Use a random 128 bit key to decrypt data with the AES. More...
 
int8_t AES_CCM_EncryptData (uint8_t encryptFlag, uint8_t MACLen, uint8_t *nonce, uint8_t *plainText, uint16_t textLen, uint8_t *addDataBuf, uint16_t addBufLen, uint8_t *aesKey, uint8_t *MAC, uint8_t ccmLVal)
 Authenticate and optionally encrypt message plainText. More...
 
int8_t AES_CCM_DecryptData (uint8_t decryptFlag, uint8_t MACLen, uint8_t *nonce, uint8_t *cipherText, uint16_t textLen, uint8_t *addDataBuf, uint16_t addBufLen, uint8_t *aesKey, uint8_t *MAC, uint8_t ccmLVal)
 Authenticate and optionally decrypt message cipherText. More...
 
uint8_t AES_CTR_EncryptData (uint8_t *plainText, uint16_t textLen, uint8_t *aesKey, uint8_t *nonce, uint8_t *initVector)
 Encrypt plaintext using the AES key, nonce and initialization vector. More...
 
uint8_t AES_CTR_DecryptData (uint8_t *cipherText, uint16_t textLen, uint8_t *aesKey, uint8_t *nonce, uint8_t *initVector)
 Decrypt ciphertext using the AES key, nonce and initialization vector. More...
 
void ECC_initialize (uint32_t *pWorkzone)
 Pass pointer to ECC memory allocation to ECC engine. More...
 
uint8_t ECC_generateKey (uint32_t *randString, uint32_t *privateKey, uint32_t *publicKey_x, uint32_t *publicKey_y)
 Generate a key. More...
 
uint8_t ECC_ECDSA_sign (uint32_t *secretKey, uint32_t *text, uint32_t *randString, uint32_t *sign1, uint32_t *sign2)
 Sign data. More...
 
uint8_t ECC_ECDSA_verify (uint32_t *publicKey_x, uint32_t *publicKey_y, uint32_t *text, uint32_t *sign1, uint32_t *sign2)
 Verify signature. More...
 
uint8_t ECC_ECDH_computeSharedSecret (uint32_t *privateKey, uint32_t *publicKey_x, uint32_t *publicKey_y, uint32_t *sharedSecret_x, uint32_t *sharedSecret_y)
 Compute the shared secret. More...
 
uint8_t SHA256_runFullAlgorithm (SHA256_memory_t *memory, uint8_t *pBufIn, uint32_t bufLen, uint8_t *pBufOut)
 Perform SHA256 on the the input data. More...
 
uint8_t SHA256_initialize (SHA256_memory_t *workZone)
 Intializes the SHA256 engine. More...
 
uint8_t SHA256_execute (SHA256_memory_t *config, uint8_t *pBufIn, uint32_t bufLen)
 Perform SHA256. More...
 
uint8_t SHA256_output (SHA256_memory_t *memory, uint8_t *pBufOut)
 Complete the process by passing the modified data back. More...
 

Detailed Description

Function Documentation

int8_t AES_CCM_DecryptData ( uint8_t  decryptFlag,
uint8_t  MACLen,
uint8_t *  nonce,
uint8_t *  cipherText,
uint16_t  textLen,
uint8_t *  addDataBuf,
uint16_t  addBufLen,
uint8_t *  aesKey,
uint8_t *  MAC,
uint8_t  ccmLVal 
)

Authenticate and optionally decrypt message cipherText.

Parameters
decryptFlagDecryption flag.
  • true for authentication with decryption.
  • false for authentication only.
MACLenLength of MAC in bytes.
noncePointer to random nonce. Nonce length = 15 - ccmLVal.
cipherTextPointer to text to decrypt, input and output.
textLenLength of text to decrypt.
addDataBufPointer to additional data for authentication
addBufLenAdditional authentication buffer length.
aesKeyPointer to the AES key or key expansion buffer.
MACPointer to 16 byte Message Authentication Code output buffer.
ccmLValCCM L value to be used. Values {2,3}.
Returns
Zero when Successful.

Definition at line 98 of file rom_crypto.c.

int8_t AES_CCM_EncryptData ( uint8_t  encryptFlag,
uint8_t  MACLen,
uint8_t *  nonce,
uint8_t *  plainText,
uint16_t  textLen,
uint8_t *  addDataBuf,
uint16_t  addBufLen,
uint8_t *  aesKey,
uint8_t *  MAC,
uint8_t  ccmLVal 
)

Authenticate and optionally encrypt message plainText.

Parameters
encryptFlagEncryption flag.
  • set to true for authentication with encryption.
  • set to false for authentication only.
MACLenLength of MAC in bytes.
noncePointer to random nonce. Nonce length = 15 - ccmLVal.
plainTextPointer to text to encrypt, input and output.
textLenLength of text to encrypt.
addDataBufPointer to additional data for authentication
addBufLenAdditional authentication buffer length.
aesKeyPointer to the AES key or key expansion buffer.
MACPointer to 16 byte Message Authentication Code output buffer.
ccmLValCCM L value to be used. Values {2,3}.
Returns
Zero when successful.

Definition at line 85 of file rom_crypto.c.

uint8_t AES_CTR_DecryptData ( uint8_t *  cipherText,
uint16_t  textLen,
uint8_t *  aesKey,
uint8_t *  nonce,
uint8_t *  initVector 
)

Decrypt ciphertext using the AES key, nonce and initialization vector.

Parameters
cipherTextPointer to text to decrypt
textLenLength of text.
aesKeyPointer to 128 bit key used to encrypt text.
noncePointer to 4 byte nonce.
initVectorPointer to 8 byte random initialization vector.
Returns
None

Definition at line 132 of file rom_crypto.c.

uint8_t AES_CTR_EncryptData ( uint8_t *  plainText,
uint16_t  textLen,
uint8_t *  aesKey,
uint8_t *  nonce,
uint8_t *  initVector 
)

Encrypt plaintext using the AES key, nonce and initialization vector.

Parameters
plainTextPointer to text to encrypt.
textLenLength of text.
aesKeyPointer to 128 bit key used to encrypt text.
noncePointer to 4 byte nonce.
initVectorPointer to 8 byte random initialization vector.
Returns
None

Definition at line 121 of file rom_crypto.c.

void AES_ECB_DecryptData ( uint8_t *  text,
uint16_t  textLen,
uint8_t *  aesKey 
)

Use a random 128 bit key to decrypt data with the AES.

Parameters
textPointer to data to decrypt.
textLenLength of text.
aesKeyPointer to 128 bit key used to decrypt. This is the same key that was used to originally encrypt this data.
Returns
None

Definition at line 65 of file rom_crypto.c.

void AES_ECB_EncryptData ( uint8_t *  text,
uint16_t  textLen,
uint8_t *  aesKey 
)

Use a random 128 bit key to encrypt data with the AES.

Parameters
textPointer to data to encrypt.
textLenLength of text.
aesKeyPointer to 128 bit key used to encrypt text.
Returns
None

Definition at line 56 of file rom_crypto.c.

uint8_t ECC_ECDH_computeSharedSecret ( uint32_t *  privateKey,
uint32_t *  publicKey_x,
uint32_t *  publicKey_y,
uint32_t *  sharedSecret_x,
uint32_t *  sharedSecret_y 
)

Compute the shared secret.

Parameters
privateKeyPointer to private key, input.
publicKey_xPointer to public key X-coordinate, input.
publicKey_yPointer to public key Y-coordinate, input.
sharedSecret_xPointer to shared secret X-coordinate, output.
sharedSecret_yPointer to shared secret Y-coordinate, output.
Returns
Status

Definition at line 247 of file rom_crypto.c.

uint8_t ECC_ECDSA_sign ( uint32_t *  secretKey,
uint32_t *  text,
uint32_t *  randString,
uint32_t *  sign1,
uint32_t *  sign2 
)

Sign data.

Parameters
secretKeyPointer to the secret key, input.
textPointer to the message, input.
randStringPointer to random string, input.
sign1Pointer to signature part 1, output.
sign2Pointer to signature part 2, output.
Returns
Status

Definition at line 225 of file rom_crypto.c.

uint8_t ECC_ECDSA_verify ( uint32_t *  publicKey_x,
uint32_t *  publicKey_y,
uint32_t *  text,
uint32_t *  sign1,
uint32_t *  sign2 
)

Verify signature.

Parameters
publicKey_xPointer to public key X-coordinate, input.
publicKey_yPointer to public key Y-coordinate, input.
textPointer to message data, input.
sign1Pointer to signature part 1, input.
sign2Pointer to signature part 2, input.
Returns
Status

Definition at line 236 of file rom_crypto.c.

uint8_t ECC_generateKey ( uint32_t *  randString,
uint32_t *  privateKey,
uint32_t *  publicKey_x,
uint32_t *  publicKey_y 
)

Generate a key.

This is used for both ECDH and ECDSA.

Parameters
randStringPointer to random string, input.
privateKeyPointer to the private key, output.
publicKey_xPointer to public key X-coordinate, output.
publicKey_yPointer to public key Y-coordinate, output.
Returns
Status

Definition at line 213 of file rom_crypto.c.

void ECC_initialize ( uint32_t *  pWorkzone)

Pass pointer to ECC memory allocation to ECC engine.

This function can be called again to point the ECC workzone at a different memory buffer.

Parameters
pWorkzonePointer to memory allocated for computations, input. See description at beginning of ECC section for memory requirements.
Returns
None

Definition at line 167 of file rom_crypto.c.

uint8_t SHA256_execute ( SHA256_memory_t config,
uint8_t *  pBufIn,
uint32_t  bufLen 
)

Perform SHA256.

Must call SHA256_output() to receive output from this operation.

Parameters
configPointer to memory for operations, input.
pBufInPointer to input text, input.
bufLenLength of input, input.
Returns
Status

Definition at line 294 of file rom_crypto.c.

uint8_t SHA256_initialize ( SHA256_memory_t workZone)

Intializes the SHA256 engine.

This function must be called once before all other SHA256 functions other than SHA256_runFullAlgorithm().

Parameters
workZonePointer to memory for operations, input.
Returns
Status

Definition at line 285 of file rom_crypto.c.

uint8_t SHA256_output ( SHA256_memory_t memory,
uint8_t *  pBufOut 
)

Complete the process by passing the modified data back.

Parameters
memoryPointer to memory for operations, input.
pBufOutPointer to output buffer, output. Buffer must be at least 32 bytes long.
Returns
Status

Definition at line 303 of file rom_crypto.c.

uint8_t SHA256_runFullAlgorithm ( SHA256_memory_t memory,
uint8_t *  pBufIn,
uint32_t  bufLen,
uint8_t *  pBufOut 
)

Perform SHA256 on the the input data.

The input and output buffer can point to the same memory. This is the equivalent of calling SHA256_initialize(), SHA256_execute() and SHA256_output() sequentially.

Parameters
memoryPointer to memory for operations, input.
pBufInPointer to input buffer, input.
bufLenLength of input.
pBufOutPointer to output buffer, output.
Returns
Status

Definition at line 275 of file rom_crypto.c.

Macro Definition Documentation

#define ECC_A_COEF_LENGTH_ZERO   0xC5

Definition at line 204 of file rom_crypto.h.

#define ECC_A_COEF_TOO_LONG   0x5C

Definition at line 203 of file rom_crypto.h.

#define ECC_BAD_WINDOW_SIZE   0x66

Definition at line 205 of file rom_crypto.h.

#define ECC_DIGEST_LENGTH_ZERO   0x72

Definition at line 215 of file rom_crypto.h.

#define ECC_DIGEST_TOO_LONG   0x27

Definition at line 214 of file rom_crypto.h.

#define ECC_ECC_KEY_LENGTH_ZERO   0x52

Definition at line 213 of file rom_crypto.h.

#define ECC_ECC_KEY_TOO_LONG   0x25

Definition at line 212 of file rom_crypto.h.

#define ECC_ECDH_COMMON_KEY_OK   ECC_SCALAR_MUL_OK

Definition at line 226 of file rom_crypto.h.

#define ECC_ECDH_KEYGEN_OK   ECC_SCALAR_MUL_OK

Definition at line 225 of file rom_crypto.h.

#define ECC_ECDSA_INVALID_SIGNATURE   0x5A

Definition at line 217 of file rom_crypto.h.

#define ECC_ECDSA_KEYGEN_OK   ECC_SCALAR_MUL_OK

Definition at line 224 of file rom_crypto.h.

#define ECC_ECDSA_SIGN_OK   0x32

Definition at line 216 of file rom_crypto.h.

#define ECC_ECDSA_VALID_SIGNATURE   0xA5

Definition at line 218 of file rom_crypto.h.

#define ECC_MODULUS_EVEN   0xDC

Definition at line 191 of file rom_crypto.h.

#define ECC_MODULUS_LARGER_THAN_255_WORDS   0xD2

Definition at line 192 of file rom_crypto.h.

#define ECC_MODULUS_LENGTH_ZERO   0x08

Definition at line 193 of file rom_crypto.h.

#define ECC_MODULUS_MSW_IS_ZERO   0x30

Definition at line 194 of file rom_crypto.h.

#define ECC_ORDER_EVEN   0x82

Definition at line 210 of file rom_crypto.h.

#define ECC_ORDER_LARGER_THAN_255_WORDS   0x28

Definition at line 209 of file rom_crypto.h.

#define ECC_ORDER_LENGTH_ZERO   0x6C

Definition at line 198 of file rom_crypto.h.

#define ECC_ORDER_MSW_IS_ZERO   0x23

Definition at line 211 of file rom_crypto.h.

#define ECC_ORDER_TOO_LONG   0xC6

Definition at line 197 of file rom_crypto.h.

#define ECC_PRIME_NIST256_CURVE

Definition at line 185 of file rom_crypto.h.

#define ECC_SCALAR_LENGTH_ZERO   0x53

Definition at line 196 of file rom_crypto.h.

#define ECC_SCALAR_MUL_OK   0x99

Definition at line 206 of file rom_crypto.h.

#define ECC_SCALAR_TOO_LONG   0x35

Definition at line 195 of file rom_crypto.h.

#define ECC_SIG_P1_LENGTH_ZERO   0x12

Definition at line 220 of file rom_crypto.h.

#define ECC_SIG_P1_TOO_LONG   0x11

Definition at line 219 of file rom_crypto.h.

#define ECC_SIG_P2_LENGTH_ZERO   0x21

Definition at line 222 of file rom_crypto.h.

#define ECC_SIG_P2_TOO_LONG   0x22

Definition at line 221 of file rom_crypto.h.

#define ECC_WINDOW_SIZE   3

Definition at line 179 of file rom_crypto.h.

Referenced by ECC_initialize().

#define ECC_X_COORD_LENGTH_ZERO   0xC3

Definition at line 200 of file rom_crypto.h.

#define ECC_X_COORD_TOO_LONG   0x3C

Definition at line 199 of file rom_crypto.h.

#define ECC_Y_COORD_LENGTH_ZERO   0x56

Definition at line 202 of file rom_crypto.h.

#define ECC_Y_COORD_TOO_LONG   0x65

Definition at line 201 of file rom_crypto.h.