CC26xx Driver Library
Low-Level functions from ECC library in ROM.

Functions

uint32_t * INVERT (ECC_State *state, uint32_t *in1)
 Perform a modular inversion of the element at address in in1. More...
 
uint32_t IMPORTMODULUS (uint32_t *out, const uint32_t *in1)
 Imports the integer in LV format found at address in1 into address out in modulus format [0, 0, LSW, ..., MSW]. Returns the wordsize of the imported modulus. More...
 
uint32_t IMPORTOPERAND (ECC_State *state, uint32_t *out, const uint32_t *in1)
 Imports the integer in LV format found at address in1 into address out in operand format [LSW, ..., MSW, 0, ..., 0], making sure that the obtained array has LEN+1 words, thus truncating or right-padding with zeroes as needed. Returns the wordsize of the imported integer. More...
 
uint32_t EXPORTOPERAND (ECC_State *state, uint32_t *out, const uint32_t *in1)
 Exports the integer found at address in1 to address out in LV format [LEN, LSW, ..., MSW]. Returns LEN. More...
 
void SETOPERAND (ECC_State *state, uint32_t *out, uint32_t inValue)
 Writes the 32-bit integer in aux at address out in operand format. More...
 
void mSET (ECC_State *state, uint32_t *in1, uint32_t size)
 Initializes the modulus at address in1 for later modular operations. Completes the modulus with the modulus-specific constant alpha = -1/m mod 2^64. More...
 
void mMULT (uint32_t *out, const uint32_t *in1, const uint32_t *in2, uint32_t *mod, uint32_t len)
 Montgomery modular multiplication out = in1 * in2 * K mod MOD where K is the Montgomery factor K = 2^-(32*LEN) mod MOD. More...
 
void mSUB (uint32_t *out, const uint32_t *in1, const uint32_t *in2, uint32_t *mod, uint32_t len)
 Computes out = in1 - in2 mod MOD. More...
 
void mADD (uint32_t *out, const uint32_t *in1, const uint32_t *in2, uint32_t *mod, uint32_t len)
 Computes out = in1 + in2 mod MOD. More...
 
void mOUT (uint32_t *out, const uint32_t *in1, uint32_t *mod, uint32_t len)
 Computes the scrict modular remainder out = in1 mod MOD < MOD. More...
 
void COPY (uint32_t *out, uint32_t *in1, uint32_t size)
 Copies aux words from address in1 to address out. More...
 
uint8_t GETBIT (uint32_t *in1, uint32_t *in2)
 Extract the bit of given index. More...
 
uint8_t SCALARMUL_init (ECC_State *state)
 Initialization for scalar multiplication. More...
 

Detailed Description

Function Documentation

§ COPY()

void COPY ( uint32_t *  out,
uint32_t *  in1,
uint32_t  size 
)

Copies aux words from address in1 to address out.

Parameters
outpoints anywhere in memory
in1points anywhere in memory
sizenumber of words to be copied
169 {
170  copy(out, in1, size);
171 }
static const copy_t copy
Definition: rom_bignum.c:80

§ EXPORTOPERAND()

uint32_t EXPORTOPERAND ( ECC_State state,
uint32_t *  out,
const uint32_t *  in1 
)

Exports the integer found at address in1 to address out in LV format [LEN, LSW, ..., MSW]. Returns LEN.

Parameters
statepointer to ECC state object
in1pointer to integer
outpoints where the LV format integer is to be written
Returns
LEN (wordsize length) from ECC state object
113 {
114  return exportoperand(state, out, in1);
115 }
static const exportoperand_t exportoperand
Definition: rom_bignum.c:59

§ GETBIT()

uint8_t GETBIT ( uint32_t *  in1,
uint32_t *  in2 
)

Extract the bit of given index.

Parameters
in1pointer to input
in2pointer to index of bit
Returns
The bit of the given index
177 {
178  return getbit(in1, in2);
179 }
static const getbit_t getbit
Definition: rom_bignum.c:83

§ IMPORTMODULUS()

uint32_t IMPORTMODULUS ( uint32_t *  out,
const uint32_t *  in1 
)

Imports the integer in LV format found at address in1 into address out in modulus format [0, 0, LSW, ..., MSW]. Returns the wordsize of the imported modulus.

Parameters
outpoints where the modulus is to be written
in1pointer to integer in LV format [L, LSW, ..., MSW]
Returns
wordsize of the imported modulus
97 {
98  return importmodulus(out, in1);
99 }
static const importmodulus_t importmodulus
Definition: rom_bignum.c:53

§ IMPORTOPERAND()

uint32_t IMPORTOPERAND ( ECC_State state,
uint32_t *  out,
const uint32_t *  in1 
)

Imports the integer in LV format found at address in1 into address out in operand format [LSW, ..., MSW, 0, ..., 0], making sure that the obtained array has LEN+1 words, thus truncating or right-padding with zeroes as needed. Returns the wordsize of the imported integer.

Parameters
statepointer to ECC state object
outpoints where the operand is to be written
in1pointer to integer in LV format [L, LSW, ..., MSW]
Returns
wordsize of the imported integer
105 {
106  return importoperand(state, out, in1);
107 }
static const importoperand_t importoperand
Definition: rom_bignum.c:56

§ INVERT()

uint32_t* INVERT ( ECC_State state,
uint32_t *  in1 
)

Perform a modular inversion of the element at address in in1.

Parameters
statepointer to ECC state object
in1pointer to value to invert
Returns
pointer to inverted value (same as in1)
89 {
90  return invert(state, in1);
91 }
static const invert_t invert
Definition: rom_bignum.c:50

§ mADD()

void mADD ( uint32_t *  out,
const uint32_t *  in1,
const uint32_t *  in2,
uint32_t *  mod,
uint32_t  len 
)

Computes out = in1 + in2 mod MOD.

Parameters
outpointer to result to be written in operand format
in1pointer to first operand in operand format
in2pointer to second operand in operand format
modpointer to modulus
lenword length of operands
Precondition
A modulus must have been initialized by the mSET routine.
153 {
154  madd(out, in1, in2, mod, len);
155 }
static const madd_t madd
Definition: rom_bignum.c:74

§ mMULT()

void mMULT ( uint32_t *  out,
const uint32_t *  in1,
const uint32_t *  in2,
uint32_t *  mod,
uint32_t  len 
)

Montgomery modular multiplication out = in1 * in2 * K mod MOD where K is the Montgomery factor K = 2^-(32*LEN) mod MOD.

Parameters
outpoints anywhere in memory except in1 or in2
in1pointer to multiplicator in operand format
in2pointer to multiplicand in operand format
modpointer to modulus
lenword length of operands
137 {
138  mmult(out, in1, in2, mod, len);
139 }
static const mmult_t mmult
Definition: rom_bignum.c:68

§ mOUT()

void mOUT ( uint32_t *  out,
const uint32_t *  in1,
uint32_t *  mod,
uint32_t  len 
)

Computes the scrict modular remainder out = in1 mod MOD < MOD.

Parameters
outpointer to result to be written in operand format
in1pointer to integer in operand format
modpointer to modulus
lenword length of operands
Precondition
A modulus must have been initialized by the mSET routine.
161 {
162  mout(out, in1, mod, len);
163 }
static const mout_t mout
Definition: rom_bignum.c:77

§ mSET()

void mSET ( ECC_State state,
uint32_t *  in1,
uint32_t  size 
)

Initializes the modulus at address in1 for later modular operations. Completes the modulus with the modulus-specific constant alpha = -1/m mod 2^64.

Parameters
statepointer to ECC state object
in1pointer to modulus in format [0, 0, LSW(m), ..., MSW(m)]
sizeindicates the wordsize of the modulus
Note
In simulation mode, only al0 = alpha mod 2^32 is computed. The routine uses the Newton-based inductive formula alpha = alpha * (m[0] * alpha + 2) mod 2^32 repeated 6 times where alpha is previously set to 1.
129 {
130  mset(state, in1, size);
131 }
static const mset_t mset
Definition: rom_bignum.c:65

§ mSUB()

void mSUB ( uint32_t *  out,
const uint32_t *  in1,
const uint32_t *  in2,
uint32_t *  mod,
uint32_t  len 
)

Computes out = in1 - in2 mod MOD.

Parameters
outpointer to result to be written in operand format
in1pointer to first operand in operand format
in2pointer to second operand in operand format
modpointer to modulus
lenword length of operands
Precondition
A modulus must have been initialized by the mSET routine.
145 {
146  msub(out, in1, in2, mod, len);
147 }
static const msub_t msub
Definition: rom_bignum.c:71

§ SCALARMUL_init()

uint8_t SCALARMUL_init ( ECC_State state)

Initialization for scalar multiplication.

Parameters
statepointer to ECC state object
Return values
STATUS_SCALAR_MUL_OK
STATUS_MODULUS_EVEN
STATUS_MODULUS_MSW_IS_ZERO
STATUS_MODULUS_LENGTH_ZERO
STATUS_MODULUS_LARGER_THAN_255_WORDS
185 {
186  return scalarmul_init(state);
187 }
static const scalarmul_init_t scalarmul_init
Definition: rom_bignum.c:47

§ SETOPERAND()

void SETOPERAND ( ECC_State state,
uint32_t *  out,
uint32_t  inValue 
)

Writes the 32-bit integer in aux at address out in operand format.

Parameters
statepointer to ECC state object
outpoints where the integer is to be written
inValueword to copy
121 {
122  setoperand(state, out, inValue);
123 }
static const setoperand_t setoperand
Definition: rom_bignum.c:62