|
SYSCALL cx_err_t | cx_bn_lock (size_t word_nbytes, uint32_t flags) |
| Locks the BN processor. More...
|
SYSCALL uint32_t | cx_bn_unlock (void) |
| Releases the BN lock. More...
|
SYSCALL bool | cx_bn_is_locked (void) |
| Checks whether the BN processor is currently locked. More...
|
cx_err_t | cx_bn_locked (void) |
| Ascertains whether the BN processor is currently locked. More...
|
SYSCALL cx_err_t | cx_bn_alloc (cx_bn_t *x, size_t nbytes) |
| Allocates memory for a new BN. More...
|
SYSCALL cx_err_t | cx_bn_alloc_init (cx_bn_t *x, size_t nbytes, const uint8_t *value, size_t value_nbytes) |
| Allocates memory for a new BN and initializes it with the specified value. More...
|
SYSCALL cx_err_t | cx_bn_destroy (cx_bn_t *x) |
| Releases a BN and gives back its attached memory to the system. More...
|
SYSCALL cx_err_t | cx_bn_nbytes (const cx_bn_t x, size_t *nbytes) |
| Gets the size in bytes of a BN. More...
|
SYSCALL cx_err_t | cx_bn_init (cx_bn_t x, const uint8_t *value, size_t value_nbytes) |
| Iinitializes a BN with an unsigned value. More...
|
SYSCALL cx_err_t | cx_bn_rand (cx_bn_t x) |
| Generates a random number and stores it in the given index. More...
|
SYSCALL cx_err_t | cx_bn_copy (cx_bn_t a, const cx_bn_t b) |
| Copies the BN value. More...
|
SYSCALL cx_err_t | cx_bn_set_u32 (cx_bn_t x, uint32_t n) |
| Sets the value of a BN with a 32-bit unsigned value. More...
|
SYSCALL cx_err_t | cx_bn_get_u32 (const cx_bn_t x, uint32_t *n) |
| Gets the 32-bit value corresponding to a BN. More...
|
SYSCALL cx_err_t | cx_bn_export (const cx_bn_t x, uint8_t *bytes, size_t nbytes) |
| Stores (serializes) a BN value as unsigned raw bytes in big-endian order. More...
|
SYSCALL cx_err_t | cx_bn_cmp (const cx_bn_t a, const cx_bn_t b, int *diff) |
| Compares two BN values. More...
|
SYSCALL cx_err_t | cx_bn_cmp_u32 (const cx_bn_t a, uint32_t b, int *diff) |
| Compares a BN value with an unsigned integer. More...
|
SYSCALL cx_err_t | cx_bn_is_odd (const cx_bn_t n, bool *odd) |
| Tests whether a BN value is odd. More...
|
SYSCALL cx_err_t | cx_bn_xor (cx_bn_t r, const cx_bn_t a, const cx_bn_t b) |
| Performs the bitwise 'exclusive-OR' of two BN values. More...
|
SYSCALL cx_err_t | cx_bn_or (cx_bn_t r, const cx_bn_t a, const cx_bn_t b) |
| Performs the bitwise 'OR' of two BN values. More...
|
SYSCALL cx_err_t | cx_bn_and (cx_bn_t r, const cx_bn_t a, const cx_bn_t b) |
| Performs the bitwise 'AND' of two BN values. More...
|
SYSCALL cx_err_t | cx_bn_tst_bit (const cx_bn_t x, uint32_t pos, bool *set) |
| Tests the bit value at the specified index. More...
|
SYSCALL cx_err_t | cx_bn_set_bit (cx_bn_t x, uint32_t pos) |
| Sets the bit value at the specified index. More...
|
SYSCALL cx_err_t | cx_bn_clr_bit (cx_bn_t x, uint32_t pos) |
| Clears the bit value at the specified index. More...
|
SYSCALL cx_err_t | cx_bn_shr (cx_bn_t x, uint32_t n) |
| Performs a right shift. More...
|
SYSCALL cx_err_t | cx_bn_shl (cx_bn_t x, uint32_t n) |
| Performs a left shift. More...
|
SYSCALL cx_err_t | cx_bn_cnt_bits (cx_bn_t n, uint32_t *nbits) |
| Counts the number of bits set to 1 of the BN value. More...
|
SYSCALL cx_err_t | cx_bn_add (cx_bn_t r, const cx_bn_t a, const cx_bn_t b) |
| Performs an addition r = a + b. More...
|
SYSCALL cx_err_t | cx_bn_sub (cx_bn_t r, const cx_bn_t a, const cx_bn_t b) |
| Performs a subtraction r = a - b. More...
|
SYSCALL cx_err_t | cx_bn_mul (cx_bn_t r, const cx_bn_t a, const cx_bn_t b) |
| Performs a multiplication r = a * b. More...
|
SYSCALL cx_err_t | cx_bn_mod_add (cx_bn_t r, const cx_bn_t a, const cx_bn_t b, const cx_bn_t n) |
| Performs a modular addition r = a + b mod n. More...
|
SYSCALL cx_err_t | cx_bn_mod_sub (cx_bn_t r, const cx_bn_t a, const cx_bn_t b, const cx_bn_t n) |
| Performs a modular subtraction r = a - b mod n. More...
|
SYSCALL cx_err_t | cx_bn_mod_mul (cx_bn_t r, const cx_bn_t a, const cx_bn_t b, const cx_bn_t n) |
| Performs a modular multiplication r = a * b mod n. More...
|
SYSCALL cx_err_t | cx_bn_reduce (cx_bn_t r, const cx_bn_t d, const cx_bn_t n) |
| Performs a reduction r = d mod n. More...
|
SYSCALL cx_err_t | cx_bn_mod_sqrt (cx_bn_t r, const cx_bn_t a, const cx_bn_t n, uint32_t sign) |
| Computes r such that r² = a mod n if a is a quadratic residue. More...
|
SYSCALL cx_err_t | cx_bn_mod_pow_bn (cx_bn_t r, const cx_bn_t a, const cx_bn_t e, const cx_bn_t n) |
| Performs a modular exponentiation r = a^e mod n. More...
|
SYSCALL cx_err_t | cx_bn_mod_pow (cx_bn_t r, const cx_bn_t a, const uint8_t *e, uint32_t e_len, const cx_bn_t n) |
| Performs a modular exponentiation r = a^e mod n. More...
|
SYSCALL cx_err_t | cx_bn_mod_pow2 (cx_bn_t r, const cx_bn_t a, const uint8_t *e, uint32_t e_len, const cx_bn_t n) |
| Performs a modular exponentiation r = a^e mod n. More...
|
SYSCALL cx_err_t | cx_bn_mod_invert_nprime (cx_bn_t r, const cx_bn_t a, const cx_bn_t n) |
| Computes the modular inverse r = a^(-1) mod n, for a prime n. More...
|
SYSCALL cx_err_t | cx_bn_mod_u32_invert (cx_bn_t r, uint32_t a, cx_bn_t n) |
| Computes the modular inverse r = a^(-1) mod n, of a 32-bit value. More...
|
SYSCALL cx_err_t | cx_mont_alloc (cx_bn_mont_ctx_t *ctx, size_t length) |
| Allocates memory for the Montgomery context. More...
|
SYSCALL cx_err_t | cx_mont_init (cx_bn_mont_ctx_t *ctx, const cx_bn_t n) |
| Initializes a Montgomery context with the modulus. More...
|
SYSCALL cx_err_t | cx_mont_init2 (cx_bn_mont_ctx_t *ctx, const cx_bn_t n, const cx_bn_t h) |
| Initializes a Montgomery context with the modulus and the second Montgomery constant. More...
|
SYSCALL cx_err_t | cx_mont_to_montgomery (cx_bn_t x, const cx_bn_t z, const cx_bn_mont_ctx_t *ctx) |
| Computes the Montgomery representation of a BN value. More...
|
SYSCALL cx_err_t | cx_mont_from_montgomery (cx_bn_t z, const cx_bn_t x, const cx_bn_mont_ctx_t *ctx) |
| Computes the normal representation of a BN value given a Montgomery representation. More...
|
SYSCALL cx_err_t | cx_mont_mul (cx_bn_t r, const cx_bn_t a, const cx_bn_t b, const cx_bn_mont_ctx_t *ctx) |
| Performs a Montgomery multiplication. More...
|
SYSCALL cx_err_t | cx_mont_pow (cx_bn_t r, const cx_bn_t a, const uint8_t *e, uint32_t e_len, const cx_bn_mont_ctx_t *ctx) |
| Performs a modular exponentiation r = a^e mod n. More...
|
SYSCALL cx_err_t | cx_mont_pow_bn (cx_bn_t r, const cx_bn_t a, const cx_bn_t e, const cx_bn_mont_ctx_t *ctx) |
| Performs a modular exponentiation r = a^e mod n. More...
|
SYSCALL cx_err_t | cx_mont_invert_nprime (cx_bn_t r, const cx_bn_t a, const cx_bn_mont_ctx_t *ctx) |
| Computes the modular inverse r = a^(-1) mod n for a prime number n. More...
|
SYSCALL cx_err_t | cx_bn_is_prime (const cx_bn_t n, bool *prime) |
| Tests whether a BN value is a probable prime. More...
|
SYSCALL cx_err_t | cx_bn_next_prime (cx_bn_t n) |
| Gets the first prime number after a given BN value. More...
|
SYSCALL cx_err_t | cx_bn_rng (cx_bn_t r, const cx_bn_t n) |
| Generates a random number r in the range ]0,n[. More...
|
Big Number syscalls.
This file contains the big numbers definitions and functions:
- Lock the memory for further computations
- Unlock the memory at the end of the operations
- Arithmetic on big numbers