InPlay API
Elliptic Curve Cryptography Profile

HAL ECC. More...

Enumerations

enum  ecc_result_status {
  ECC_ERR_OK = 0, ECC_ERR_NOT_INIT = 1, ECC_ERR_RESOURCE = 2, ECC_ERR_DEV_BAD_STATE = 3,
  ECC_ERR_NON_NORMAL_STOP = 4, ECC_ERR_INVALID_POINT = 5, ECC_ERR_INVALID_PARA = 6, ECC_ERR_HW_MEM_USED_BY_AES = 7,
  ECC_ERR_PEND = 8, ECC_ERR_TMO = 9, ECC_ERR_HW_BASE = 10
}
 ECC function status return. More...
 

Functions

int hal_ecc_open (int int_priority)
 Initialize ECC driver. : All the Ecc APIs will be blocked call if "callback" function is not specified. The "callback" function will be called in the HW interrupt service routine. More...
 
int hal_ecc_close (void)
 De-Initialize ECC driver. More...
 
int hal_ecc_is_open (void)
 Ecc and Aes shared the same HW memory. This is to inform AES that Ecc currently is using the HW memory. More...
 
int hal_ecc_r_inv_mod_m_block (uint16_t size, const uint8_t *m, uint8_t *r_inv, uint32_t tmo)
 Computes the modular inverse of r. (1/(r mod m)) More...
 
int hal_ecc_m_prime_block (uint16_t size, const uint8_t *r_inv, const uint8_t *m, uint8_t *mp, uint32_t tmo)
 Computes the Montgomery residue constant. (m') More...
 
int hal_ecc_r_sqr_mod_m_block (uint16_t size, const uint8_t *r_inv, const uint8_t *m, uint8_t *r_sqr, uint32_t tmo)
 Computes the Montgomery residue conversion constant. (r^2) mod m. More...
 
int hal_ecc_mod_mult_block (uint16_t size, const uint8_t *x, const uint8_t *y, const uint8_t *m, const uint8_t *mp, const uint8_t *r_sqr, uint8_t *c, uint32_t tmo)
 Multiplies two integers, each of a size contained in the operand size set, over the modular field m. (x * y) mod m. More...
 
int hal_ecc_mod_add_block (uint16_t size, const uint8_t *x, const uint8_t *y, const uint8_t *m, uint8_t *c, uint32_t tmo)
 Adds two integers, each of a size contained in the operand size set, over the modular (x + y) mod m. More...
 
int hal_ecc_mod_sub_block (uint16_t size, const uint8_t *x, const uint8_t *y, const uint8_t *m, uint8_t *c, uint32_t tmo)
 Subtracts two integers, each of a size contained in the operand size set, over the modular field m. (x - y) mod m. More...
 
int hal_ecc_mod_div_block (uint16_t size, const uint8_t *y, const uint8_t *x, const uint8_t *m, uint8_t *c, uint32_t tmo)
 Divides one integer by another, each of a size contained in the operand size set, over the modular field m. (y / x) mod m. More...
 
int hal_ecc_mod_inv_block (uint16_t size, const uint8_t *x, const uint8_t *m, uint8_t *c, uint32_t tmo)
 Calculates the inversion of an integer, of a size contained in the operand size set, over the modular field m. (1 / x) mod m. More...
 
int hal_ecc_pmult_block (uint16_t size, const uint8_t *Px, const uint8_t *Py, const uint8_t *a, const uint8_t *w, const uint8_t *p, const uint8_t *mp, const uint8_t *r_sqr, const uint8_t *k, uint8_t *Rx, uint8_t *Ry, uint32_t tmo)
 Computes the ECC Point Multiplication over the curve y^2 = x^3 + ax + b mod p. R = 2P. More...
 
int hal_ecc_padd_block (uint16_t size, const uint8_t *Px, const uint8_t *Py, const uint8_t *Qx, const uint8_t *Qy, const uint8_t *a, const uint8_t *p, const uint8_t *mp, const uint8_t *r_sqr, uint8_t *Rx, uint8_t *Ry, uint32_t tmo)
 Computes the ECC Point Addition over the curve y^2 = x^3 + ax + b mod p. R = P + Q. More...
 
int hal_ecc_pdbl_block (uint16_t size, const uint8_t *Px, const uint8_t *Py, const uint8_t *a, const uint8_t *p, const uint8_t *mp, const uint8_t *r_sqr, uint8_t *Rx, uint8_t *Ry, uint32_t tmo)
 Computes the EC Point Doubling over the curve y2 = x3 + ax + b mod p. R = 2P. More...
 
int hal_ecc_pver_block (uint16_t size, const uint8_t *Px, const uint8_t *Py, const uint8_t *a, const uint8_t *b, const uint8_t *p, const uint8_t *mp, const uint8_t *r_sqr, uint32_t tmo)
 Computes y2 == x3 + ax + b mod p and verified LHS == RHS. More...
 
int hal_ecc_shamir_block (uint16_t size, const uint8_t *Px, const uint8_t *Py, const uint8_t *Qx, const uint8_t *Qy, const uint8_t *a, const uint8_t *k, const uint8_t *l, const uint8_t *p, const uint8_t *mp, const uint8_t *r_sqr, uint8_t *Rx, uint8_t *Ry, uint32_t tmo)
 Calculate R = kP + lQ using Shamir's Trick. More...
 

Detailed Description

HAL ECC.

Enumeration Type Documentation

◆ ecc_result_status

ECC function status return.

Enumerator
ECC_ERR_OK 

No errors, good status.

ECC_ERR_NOT_INIT 

Error, ECC driver not initialized.

ECC_ERR_RESOURCE 

Error, ECC driver don't have enough resource.

ECC_ERR_DEV_BAD_STATE 

Error, ECC bad state.

ECC_ERR_NON_NORMAL_STOP 

Error, ECC operation returned abnormal stop condition.

ECC_ERR_INVALID_POINT 

Error, invalid elliptic curve (EC) point. Point is not on elliptic curve.

ECC_ERR_INVALID_PARA 

Error, invalid ECC size parameter.

ECC_ERR_HW_MEM_USED_BY_AES 

Error, AES using the HW memory.

ECC_ERR_PEND 

Error, ECC return pending.

ECC_ERR_TMO 

Error, ECC return pending.

ECC_ERR_HW_BASE 

Error, return from HW.

Function Documentation

◆ hal_ecc_close()

int hal_ecc_close ( void  )

De-Initialize ECC driver.

Returns
ECC_ERR_OK if ECC uninitializes successfully, error otherwise.
See also
enum ecc_result_status.

◆ hal_ecc_is_open()

int hal_ecc_is_open ( void  )

Ecc and Aes shared the same HW memory. This is to inform AES that Ecc currently is using the HW memory.

Returns
1 if Ecc is using the HW memory, 0 otherwise.

◆ hal_ecc_m_prime_block()

int hal_ecc_m_prime_block ( uint16_t  size,
const uint8_t *  r_inv,
const uint8_t *  m,
uint8_t *  mp,
uint32_t  tmo 
)

Computes the Montgomery residue constant. (m')

Parameters
[in]sizeKey size.
[in]r_invPointer to the Montgomery precomputed value, modular inverse of r.
[in]mPointer to the modulus of the underlying field.
[out]mpPointer to the output result, Montgomery residue constant.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_mod_add_block()

int hal_ecc_mod_add_block ( uint16_t  size,
const uint8_t *  x,
const uint8_t *  y,
const uint8_t *  m,
uint8_t *  c,
uint32_t  tmo 
)

Adds two integers, each of a size contained in the operand size set, over the modular (x + y) mod m.

Parameters
[in]sizeKey size.
[in]xPointer to the first operand of this modular addition expression.
[in]yPointer to the second operand of this modular addition expression.
[in]mPointer to the modulus of the underlying field.
[out]cPointer to the output result, modular sum of input x and y.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_mod_div_block()

int hal_ecc_mod_div_block ( uint16_t  size,
const uint8_t *  y,
const uint8_t *  x,
const uint8_t *  m,
uint8_t *  c,
uint32_t  tmo 
)

Divides one integer by another, each of a size contained in the operand size set, over the modular field m. (y / x) mod m.

Parameters
[in]sizeKey size.
[in]yPointer to the first operand of this modular division expression.
[in]xPointer to the second operand of this modular division expression.
[in]mPointer to the modulus of the underlying field.
[out]cPointer to the output result, modular difference of input x and y.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_mod_inv_block()

int hal_ecc_mod_inv_block ( uint16_t  size,
const uint8_t *  x,
const uint8_t *  m,
uint8_t *  c,
uint32_t  tmo 
)

Calculates the inversion of an integer, of a size contained in the operand size set, over the modular field m. (1 / x) mod m.

Parameters
[in]sizeKey size.
[in]xPointer to the operand of this modular inversion expression.
[in]mPointer to the modulus of the underlying field.
[out]cPointer to the output result, modular inversion of input x.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_mod_mult_block()

int hal_ecc_mod_mult_block ( uint16_t  size,
const uint8_t *  x,
const uint8_t *  y,
const uint8_t *  m,
const uint8_t *  mp,
const uint8_t *  r_sqr,
uint8_t *  c,
uint32_t  tmo 
)

Multiplies two integers, each of a size contained in the operand size set, over the modular field m. (x * y) mod m.

Parameters
[in]sizeKey size.
[in]xPointer to the first operand of this modular multiplication expression.
[in]yPointer to the second operand of this modular multiplication expression.
[in]mPointer to the modulus of the underlying field.
[in]mpPointer to the Montgomery residue constant.
[in]r_sqrPointer to the Montgomery residue conversion constant.
[out]cPointer to the output result, modular product of input x and y.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_mod_sub_block()

int hal_ecc_mod_sub_block ( uint16_t  size,
const uint8_t *  x,
const uint8_t *  y,
const uint8_t *  m,
uint8_t *  c,
uint32_t  tmo 
)

Subtracts two integers, each of a size contained in the operand size set, over the modular field m. (x - y) mod m.

Parameters
[in]sizeKey size.
[in]xPointer to the first operand of this modular subtraction expression.
[in]yPointer to the second operand of this modular subtraction expression.
[in]mPointer to the modulus of the underlying field.
[out]cPointer to the output result, modular difference of input x and y.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_open()

int hal_ecc_open ( int  int_priority)

Initialize ECC driver. : All the Ecc APIs will be blocked call if "callback" function is not specified. The "callback" function will be called in the HW interrupt service routine.

Parameters
[in]int_priorityinterrupt priority (see in_irq.h file)
Returns
ECC_ERR_OK if ECC initializes successfully, error otherwise.
See also
enum ecc_result_status.

◆ hal_ecc_padd_block()

int hal_ecc_padd_block ( uint16_t  size,
const uint8_t *  Px,
const uint8_t *  Py,
const uint8_t *  Qx,
const uint8_t *  Qy,
const uint8_t *  a,
const uint8_t *  p,
const uint8_t *  mp,
const uint8_t *  r_sqr,
uint8_t *  Rx,
uint8_t *  Ry,
uint32_t  tmo 
)

Computes the ECC Point Addition over the curve y^2 = x^3 + ax + b mod p. R = P + Q.

Parameters
[in]sizeKey size.
[in]PxPointer to the x coordinate of the first operand.
[in]PyPointer to the y coordinate of the first operand.
[in]QxPointer to the x coordinate of the second operand.
[in]QyPointer to the y coordinate of the second operand.
[in]aCurve parameter, a.
[in]pCurve prime modulus, p.
[in]mpMontgomery precomputed value, p'.
[in]r_sqrMontgomery precomputed value, (r^2) mod p.
[out]RxPointer to the x coordinate of the result.
[out]RyPointer to the y coordinate of the result.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_pdbl_block()

int hal_ecc_pdbl_block ( uint16_t  size,
const uint8_t *  Px,
const uint8_t *  Py,
const uint8_t *  a,
const uint8_t *  p,
const uint8_t *  mp,
const uint8_t *  r_sqr,
uint8_t *  Rx,
uint8_t *  Ry,
uint32_t  tmo 
)

Computes the EC Point Doubling over the curve y2 = x3 + ax + b mod p. R = 2P.

Parameters
[in]sizeKey size.
[in]PxPointer to the x coordinate of the operand.
[in]PyPointer to the y coordinate of the operand.
[in]aCurve parameter, a.
[in]pCurve prime modulus, p.
[in]mpMontgomery precomputed value, p'.
[in]r_sqrMontgomery precomputed value, (r^2) mod p.
[out]RxPointer to the x coordinate of the result.
[out]RyPointer to the y coordinate of the result.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_pmult_block()

int hal_ecc_pmult_block ( uint16_t  size,
const uint8_t *  Px,
const uint8_t *  Py,
const uint8_t *  a,
const uint8_t *  w,
const uint8_t *  p,
const uint8_t *  mp,
const uint8_t *  r_sqr,
const uint8_t *  k,
uint8_t *  Rx,
uint8_t *  Ry,
uint32_t  tmo 
)

Computes the ECC Point Multiplication over the curve y^2 = x^3 + ax + b mod p. R = 2P.

Parameters
[in]sizeKey size.
[in]PxPointer to the x coordinate of the operand.
[in]PyPointer to the y coordinate of the operand.
[in]aCurve parameter, a.
[in]wRandom blinding value, w.
[in]pCurve prime modulus, p.
[in]mpMontgomery precomputed value, p'.
[in]r_sqrMontgomery precomputed value, (r^2) mod p.
[in]kKey, k.
[out]RxPointer to the x coordinate of the result.
[out]RyPointer to the y coordinate of the result.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_pver_block()

int hal_ecc_pver_block ( uint16_t  size,
const uint8_t *  Px,
const uint8_t *  Py,
const uint8_t *  a,
const uint8_t *  b,
const uint8_t *  p,
const uint8_t *  mp,
const uint8_t *  r_sqr,
uint32_t  tmo 
)

Computes y2 == x3 + ax + b mod p and verified LHS == RHS.

Parameters
[in]sizeKey size.
[in]PxPointer to the x coordinate of the operand.
[in]PyPointer to the y coordinate of the operand.
[in]aCurve parameter, a.
[in]bCurve parameter, b.
[in]pCurve prime modulus, p.
[in]mpMontgomery precomputed value, p'.
[in]r_sqrMontgomery precomputed value, (r^2) mod p.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if verified point, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_r_inv_mod_m_block()

int hal_ecc_r_inv_mod_m_block ( uint16_t  size,
const uint8_t *  m,
uint8_t *  r_inv,
uint32_t  tmo 
)

Computes the modular inverse of r. (1/(r mod m))

Parameters
[in]sizeKey size.
[in]mPointer to the modulus of the underlying field.
[out]r_invPointer to the output result, modular inverse of r.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_r_sqr_mod_m_block()

int hal_ecc_r_sqr_mod_m_block ( uint16_t  size,
const uint8_t *  r_inv,
const uint8_t *  m,
uint8_t *  r_sqr,
uint32_t  tmo 
)

Computes the Montgomery residue conversion constant. (r^2) mod m.

Parameters
[in]sizeKey size.
[in]r_invPointer to the Montgomery precomputed value, modular inverse of r.
[in]mPointer to the modulus of the underlying field.
[out]r_sqrPointer to the output result, Montgomery residue conversion constant.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status

◆ hal_ecc_shamir_block()

int hal_ecc_shamir_block ( uint16_t  size,
const uint8_t *  Px,
const uint8_t *  Py,
const uint8_t *  Qx,
const uint8_t *  Qy,
const uint8_t *  a,
const uint8_t *  k,
const uint8_t *  l,
const uint8_t *  p,
const uint8_t *  mp,
const uint8_t *  r_sqr,
uint8_t *  Rx,
uint8_t *  Ry,
uint32_t  tmo 
)

Calculate R = kP + lQ using Shamir's Trick.

Parameters
[in]sizeKey size.
[in]PxPointer to the x coordinate of the first operand.
[in]PyPointer to the y coordinate of the first operand.
[in]QxPointer to the x coordinate of the second operand.
[in]QyPointer to the y coordinate of the second operand.
[in]aCurve parameter, a.
[in]kMultiplier associated with point P.
[in]lMultiplier associated with point Q.
[in]pCurve prime modulus, p.
[in]mpMontgomery precomputed value, p'.
[in]r_sqrMontgomery precomputed value, (r^2) mod p.
[out]RxPointer to the x coordinate of the result.
[out]RyPointer to the y coordinate of the result.
[in]tmoThe time to wait before return (blocking call only).
[in]callbackThe completion call back function (non blocking call only).
Returns
ECC_ERR_OK if successful, otherwise failed.
See also
enum ecc_result_status