TI BLE-Stack for Bluetooth 4.2 API Documentation  3.01.00.07
Modules | Files | Data Structures | Macros | Typedefs | Functions
ECC Driver

Elliptic Curve Cryptography driver. More...

Modules

 ECC_STATUS
 

Files

file  ECCROMCC26XX.h
 ECC ROM driver implementation for a CC26XX device.
 

Data Structures

struct  ECCROMCC26XX_CurveParams
 ECCROMCC26XX Curve Parameters. More...
 
struct  ECCROMCC26XX_Params
 ECCROMCC26XX Parameters. More...
 

Macros

#define ECCROMCC26XX_NIST_P256_KEY_LEN_IN_BYTES   32
 
#define ECCROMCC26XX_NIST_P256_WORKZONE_LEN_IN_BYTES   684
 
#define ECCROMCC26XX_NIST_P256_WORKZONE_SIGN_VERIFY_LEN_IN_BYTES   1100
 
#define ECCROMCC26XX_WORKZONE_LEN_IN_BYTES(len, win)   (4 * ((13 * (len)) + 13 + (3 * (len) * (1 << ((win) - 2)))))
 Compute ECC workzone length in bytes for a generic key length and window size. More...
 

Typedefs

typedef struct ECCROMCC26XX_CurveParams ECCROMCC26XX_CurveParams
 ECCROMCC26XX Curve Parameters. More...
 
typedef void(* ECCROMCC26XX_FreeCB) (uint8_t *pBuf)
 ECCROMCC26XX Free Callback. More...
 
typedef uint8_t *(* ECCROMCC26XX_MallocCB) (uint16_t len)
 ECCROMCC26XX Malloc Callback. More...
 
typedef struct ECCROMCC26XX_Params ECCROMCC26XX_Params
 ECCROMCC26XX Parameters. More...
 

Functions

int8_t ECCROMCC26XX_genDHKey (uint8_t *privateKey, uint8_t *publicKeyX, uint8_t *publicKeyY, uint8_t *dHKeyX, uint8_t *dHKeyY, ECCROMCC26XX_Params *params)
 Generate Diffie-Hellman Shared Secret Key X and Y Coordinates. More...
 
int8_t ECCROMCC26XX_genKeys (uint8_t *privateKey, uint8_t *publicKeyX, uint8_t *publicKeyY, ECCROMCC26XX_Params *params)
 Generate Public Key X and Y Coordinates. More...
 
void ECCROMCC26XX_init (void)
 Initializes module's synchronization resources. Only needs to be called once, but safe to call multiple times. More...
 
void ECCROMCC26XX_Params_init (ECCROMCC26XX_Params *params)
 Function to initialize the ECCROMCC26XX_Params struct to its defaults. params should not be modified until after this function is called. Default parameters use the NIST P-256 curve, timeout is set to wait indefinitely, malloc and free are NULL and status is set to ECCROMCC26XX_STATUS_SUCCESS. A client may call this function with the same params instance any number of times. More...
 
int8_t ECCROMCC26XX_signHash (uint8_t *privateKey, const uint8_t *hash, uint32_t hashLen, uint8_t *sign1, uint8_t *sign2, ECCROMCC26XX_Params *params)
 Compute the signature of a previously hashed message. More...
 
int8_t ECCROMCC26XX_verifyHash (uint8_t *publicKeyX, uint8_t *publicKeyY, uint8_t *sign1, uint8_t *sign2, uint8_t *hash, uint32_t hashLen, ECCROMCC26XX_Params *params)
 Verify the signature of a previously hashed message. More...
 

Detailed Description

Elliptic Curve Cryptography driver.

To use the ECC driver in your application you need to:

Macro Definition Documentation

§ ECCROMCC26XX_NIST_P256_KEY_LEN_IN_BYTES

#define ECCROMCC26XX_NIST_P256_KEY_LEN_IN_BYTES   32

ECC key length in bytes for NIST P-256 keys.

§ ECCROMCC26XX_NIST_P256_WORKZONE_LEN_IN_BYTES

#define ECCROMCC26XX_NIST_P256_WORKZONE_LEN_IN_BYTES   684

ECC Workzone length in bytes for NIST P-256 key and shared secret generation. For use with ECC Window Size 3 only. Used to store intermediary values in ECC calculations.

§ ECCROMCC26XX_NIST_P256_WORKZONE_SIGN_VERIFY_LEN_IN_BYTES

#define ECCROMCC26XX_NIST_P256_WORKZONE_SIGN_VERIFY_LEN_IN_BYTES   1100

ECC Workzone length in bytes for NIST P-256 key and shared secret generation. For use with ECC Window Size 3 only. Used to store intermediary values in ECC calculations. This value needs to be adjusted while the sign and verify functions

§ ECCROMCC26XX_WORKZONE_LEN_IN_BYTES

#define ECCROMCC26XX_WORKZONE_LEN_IN_BYTES (   len,
  win 
)    (4 * ((13 * (len)) + 13 + (3 * (len) * (1 << ((win) - 2)))))

Compute ECC workzone length in bytes for a generic key length and window size.

len is the length of the key in uint32_t blocks. it must not exceed 255 blocks in length. win is the window size, such that 1 < win < 6. Recommended setting is 3.

This workzone length is only valid for key and shared secret and signature generation. A different workzone length would be used for verification.

Typedef Documentation

§ ECCROMCC26XX_CurveParams

ECCROMCC26XX Curve Parameters.

This holds the ECC Curve information to be used. Offset 0 of each param_* buffer contains the length of each parameter in uint32_t blocks, not including the first offset.

§ ECCROMCC26XX_FreeCB

typedef void(* ECCROMCC26XX_FreeCB) (uint8_t *pBuf)

ECCROMCC26XX Free Callback.

Required to free temporary key buffers during operation.

Parameters
pBuf- pointer to buffer to free.
Returns
none

§ ECCROMCC26XX_MallocCB

typedef uint8_t*(* ECCROMCC26XX_MallocCB) (uint16_t len)

ECCROMCC26XX Malloc Callback.

Required to malloc temporary key buffers during operation.

Parameters
len- length in bytes of buffer to malloc.
Returns
pointer to allocated buffer

§ ECCROMCC26XX_Params

ECCROMCC26XX Parameters.

Holds a client's parameters for performing an ECC operation.

Function Documentation

§ ECCROMCC26XX_genDHKey()

int8_t ECCROMCC26XX_genDHKey ( uint8_t *  privateKey,
uint8_t *  publicKeyX,
uint8_t *  publicKeyY,
uint8_t *  dHKeyX,
uint8_t *  dHKeyY,
ECCROMCC26XX_Params params 
)

Generate Diffie-Hellman Shared Secret Key X and Y Coordinates.

Precondition
ECCROMCC26XX_init must be called prior to this and params must be intiliazed with ECCROMCC26XX_Params_init(). Calling context: Task. Swi or Hwi should call only when timeout is set to 0.
Parameters
privateKey32 byte input buffer of randomly generated bits. This key needs to contain the length (4 bytes) and the private key in a byte-wise little endian format.
publicKeyX32 byte input buffer provided by client to store Public Key X Coordinate. This key needs to contain the length (4 bytes) and the private key in a byte-wise little endian format.
publicKeyY32 byte input buffer provided by client to store Public Key Y Coordinate. This key needs to contain the length (4 bytes) and the private key in a byte-wise little endian format.
dHKeyX32 byte output buffer provided by client to store Diffie-Hellman Key X Coordinate. This key needs to contain the length (4 bytes) and the private key in a byte-wise little endian format.
dHKeyY32 byte output buffer provided by client to store Diffie-Hellman Key Y Coordinate. This key needs to contain the length (4 bytes) and the private key in a byte-wise little endian format.
paramsPointer to a parameter block, if NULL operation will fail
Returns
status

§ ECCROMCC26XX_genKeys()

int8_t ECCROMCC26XX_genKeys ( uint8_t *  privateKey,
uint8_t *  publicKeyX,
uint8_t *  publicKeyY,
ECCROMCC26XX_Params params 
)

Generate Public Key X and Y Coordinates.

Precondition
ECCROMCC26XX_init must be called prior to this and params must be intiliazed with ECCROMCC26XX_Params_init(). Calling context: Task. Swi or Hwi should call only when timeout is set to 0.
Parameters
privateKey32 byte input buffer of randomly generated bits. This key needs to contain the length (4 bytes) and the private key in a byte-wise little endian format.
publicKeyX32 byte output buffer provided by client to store Public Key X Coordinate. This key needs to contain the length (4 bytes) and the private key in a byte-wise little endian format.
publicKeyY32 byte output buffer provided by client to store Public Key Y Coordinate. This key needs to contain the length (4 bytes) and the private key in a byte-wise little endian format.
paramsPointer to a parameter block, if NULL operation will fail.
Returns
status

§ ECCROMCC26XX_init()

void ECCROMCC26XX_init ( void  )

Initializes module's synchronization resources. Only needs to be called once, but safe to call multiple times.

Precondition
This function must be called before any other ECCROMCC26XX driver APIs. Calling context: Task.

§ ECCROMCC26XX_Params_init()

void ECCROMCC26XX_Params_init ( ECCROMCC26XX_Params params)

Function to initialize the ECCROMCC26XX_Params struct to its defaults. params should not be modified until after this function is called. Default parameters use the NIST P-256 curve, timeout is set to wait indefinitely, malloc and free are NULL and status is set to ECCROMCC26XX_STATUS_SUCCESS. A client may call this function with the same params instance any number of times.

Precondition
Calling context: Hwi, Swi and Task.
Parameters
paramsParameter structure to initialize.

§ ECCROMCC26XX_signHash()

int8_t ECCROMCC26XX_signHash ( uint8_t *  privateKey,
const uint8_t *  hash,
uint32_t  hashLen,
uint8_t *  sign1,
uint8_t *  sign2,
ECCROMCC26XX_Params params 
)

Compute the signature of a previously hashed message.

Parameters
privateKey32 byte input buffer of randomly generated bits. This key needs to contain the length (4 bytes) and the private key in a byte-wise little endian format.
hash32 byte input buffer of message digest( hashed using SHA-256) This hash needs to contain the length (4 bytes) and the hash in a byte-wise little endian format.
hashLenlength of message digest
sign132 byte output buffer provided by client to store first part of computed signature. This sign needs to contain the length (4 bytes) and the sign in a byte-wise little endian format.
sign232 byte output buffer provided by client to store second part of computed signature . This sign needs to contain the length (4 bytes) and the sign in a byte-wise little endian format.
paramsPointer to a parameter block, if NULL operation will fail
Returns
status

§ ECCROMCC26XX_verifyHash()

int8_t ECCROMCC26XX_verifyHash ( uint8_t *  publicKeyX,
uint8_t *  publicKeyY,
uint8_t *  sign1,
uint8_t *  sign2,
uint8_t *  hash,
uint32_t  hashLen,
ECCROMCC26XX_Params params 
)

Verify the signature of a previously hashed message.

Precondition
ECCROMCC26XX_init must be called prior to this and params must be intiliazed with ECCROMCC26XX_Params_init(). Calling context: Task. Swi or Hwi should call only when timeout is set to 0.
Parameters
publicKeyX32 byte input buffer provided by client to store Public Key X Coordinate. This key needs to contain the length (4 bytes) and the private key in a byte-wise little endian format.
publicKeyY32 byte input buffer provided by client to store Public Key Y Coordinate. This key needs to contain the length (4 bytes) and the private key in a byte-wise little endian format.
sign132 byte output buffer provided by client to store first part of computed signature part. This sign needs to contain the length (4 bytes) and the sign in a byte-wise little endian format.
sign232 byte output buffer provided by client to store second part of computed signature part. This sign needs to contain the length (4 bytes) and the sign in a byte-wise little endian format.
hash32 byte input buffer of message digest This hash needs to contain the length (4 bytes) and the hash in a byte-wise little endian format.
hashLenlength of message digest
paramsPointer to a parameter block, if NULL operation will fail
Returns
status
Copyright 2017, Texas Instruments Incorporated