InPlay API
|
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... | |
HAL ECC.
enum ecc_result_status |
ECC function status return.
int hal_ecc_close | ( | void | ) |
De-Initialize ECC driver.
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.
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')
[in] | size | Key size. |
[in] | r_inv | Pointer to the Montgomery precomputed value, modular inverse of r. |
[in] | m | Pointer to the modulus of the underlying field. |
[out] | mp | Pointer to the output result, Montgomery residue constant. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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.
[in] | size | Key size. |
[in] | x | Pointer to the first operand of this modular addition expression. |
[in] | y | Pointer to the second operand of this modular addition expression. |
[in] | m | Pointer to the modulus of the underlying field. |
[out] | c | Pointer to the output result, modular sum of input x and y. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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.
[in] | size | Key size. |
[in] | y | Pointer to the first operand of this modular division expression. |
[in] | x | Pointer to the second operand of this modular division expression. |
[in] | m | Pointer to the modulus of the underlying field. |
[out] | c | Pointer to the output result, modular difference of input x and y. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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.
[in] | size | Key size. |
[in] | x | Pointer to the operand of this modular inversion expression. |
[in] | m | Pointer to the modulus of the underlying field. |
[out] | c | Pointer to the output result, modular inversion of input x. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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.
[in] | size | Key size. |
[in] | x | Pointer to the first operand of this modular multiplication expression. |
[in] | y | Pointer to the second operand of this modular multiplication expression. |
[in] | m | Pointer to the modulus of the underlying field. |
[in] | mp | Pointer to the Montgomery residue constant. |
[in] | r_sqr | Pointer to the Montgomery residue conversion constant. |
[out] | c | Pointer to the output result, modular product of input x and y. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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.
[in] | size | Key size. |
[in] | x | Pointer to the first operand of this modular subtraction expression. |
[in] | y | Pointer to the second operand of this modular subtraction expression. |
[in] | m | Pointer to the modulus of the underlying field. |
[out] | c | Pointer to the output result, modular difference of input x and y. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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.
[in] | int_priority | interrupt priority (see in_irq.h file) |
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.
[in] | size | Key size. |
[in] | Px | Pointer to the x coordinate of the first operand. |
[in] | Py | Pointer to the y coordinate of the first operand. |
[in] | Qx | Pointer to the x coordinate of the second operand. |
[in] | Qy | Pointer to the y coordinate of the second operand. |
[in] | a | Curve parameter, a. |
[in] | p | Curve prime modulus, p. |
[in] | mp | Montgomery precomputed value, p'. |
[in] | r_sqr | Montgomery precomputed value, (r^2) mod p. |
[out] | Rx | Pointer to the x coordinate of the result. |
[out] | Ry | Pointer to the y coordinate of the result. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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.
[in] | size | Key size. |
[in] | Px | Pointer to the x coordinate of the operand. |
[in] | Py | Pointer to the y coordinate of the operand. |
[in] | a | Curve parameter, a. |
[in] | p | Curve prime modulus, p. |
[in] | mp | Montgomery precomputed value, p'. |
[in] | r_sqr | Montgomery precomputed value, (r^2) mod p. |
[out] | Rx | Pointer to the x coordinate of the result. |
[out] | Ry | Pointer to the y coordinate of the result. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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.
[in] | size | Key size. |
[in] | Px | Pointer to the x coordinate of the operand. |
[in] | Py | Pointer to the y coordinate of the operand. |
[in] | a | Curve parameter, a. |
[in] | w | Random blinding value, w. |
[in] | p | Curve prime modulus, p. |
[in] | mp | Montgomery precomputed value, p'. |
[in] | r_sqr | Montgomery precomputed value, (r^2) mod p. |
[in] | k | Key, k. |
[out] | Rx | Pointer to the x coordinate of the result. |
[out] | Ry | Pointer to the y coordinate of the result. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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.
[in] | size | Key size. |
[in] | Px | Pointer to the x coordinate of the operand. |
[in] | Py | Pointer to the y coordinate of the operand. |
[in] | a | Curve parameter, a. |
[in] | b | Curve parameter, b. |
[in] | p | Curve prime modulus, p. |
[in] | mp | Montgomery precomputed value, p'. |
[in] | r_sqr | Montgomery precomputed value, (r^2) mod p. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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))
[in] | size | Key size. |
[in] | m | Pointer to the modulus of the underlying field. |
[out] | r_inv | Pointer to the output result, modular inverse of r. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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.
[in] | size | Key size. |
[in] | r_inv | Pointer to the Montgomery precomputed value, modular inverse of r. |
[in] | m | Pointer to the modulus of the underlying field. |
[out] | r_sqr | Pointer to the output result, Montgomery residue conversion constant. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |
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.
[in] | size | Key size. |
[in] | Px | Pointer to the x coordinate of the first operand. |
[in] | Py | Pointer to the y coordinate of the first operand. |
[in] | Qx | Pointer to the x coordinate of the second operand. |
[in] | Qy | Pointer to the y coordinate of the second operand. |
[in] | a | Curve parameter, a. |
[in] | k | Multiplier associated with point P. |
[in] | l | Multiplier associated with point Q. |
[in] | p | Curve prime modulus, p. |
[in] | mp | Montgomery precomputed value, p'. |
[in] | r_sqr | Montgomery precomputed value, (r^2) mod p. |
[out] | Rx | Pointer to the x coordinate of the result. |
[out] | Ry | Pointer to the y coordinate of the result. |
[in] | tmo | The time to wait before return (blocking call only). |
[in] | callback | The completion call back function (non blocking call only). |