Contiki-NG
Files | Functions
cc2538 BigNum math function driver

Driver for the cc2538 BigNum math functions of the PKC engine. More...

Files

file  bignum-driver.c
 Implementation of the cc2538 BigNum driver.
 
file  bignum-driver.h
 Header file for the cc2538 BigNum driver.
 

Functions

uint8_t bignum_mod_start (const uint32_t *number, const uint8_t number_size, const uint32_t *modulus, const uint8_t modulus_size, uint32_t *result_vector, struct process *process)
 Starts the big number modulus operation. More...
 
uint8_t bignum_mod_get_result (uint32_t *buffer, const uint8_t buffer_size, const uint32_t result_vector)
 Gets the result of the big number modulus operation. More...
 
uint8_t bignum_cmp_start (const uint32_t *number1, const uint32_t *number2, const uint8_t size, struct process *process)
 Starts the comparison of two big numbers. More...
 
uint8_t bignum_cmp_get_result (void)
 Gets the result of the comparison operation of two big numbers. More...
 
uint8_t bignum_inv_mod_start (const uint32_t *number, const uint8_t number_size, const uint32_t *modulus, const uint8_t modulus_size, uint32_t *result_vector, struct process *process)
 Starts the big number inverse modulo operation. More...
 
uint8_t bignum_inv_mod_get_result (uint32_t *buffer, const uint8_t buffer_size, const uint32_t result_vector)
 Gets the result of the big number inverse modulo operation. More...
 
uint8_t bignum_mul_start (const uint32_t *multiplicand, const uint8_t multiplicand_size, const uint32_t *multiplier, const uint8_t multiplier_size, uint32_t *result_vector, struct process *process)
 Starts the big number multiplication. More...
 
uint8_t bignum_mul_get_result (uint32_t *buffer, uint32_t *buffer_size, const uint32_t result_vector)
 Gets the results of the big number multiplication. More...
 
uint8_t bignum_add_start (const uint32_t *number1, const uint8_t number1_size, const uint32_t *number2, const uint8_t number2_size, uint32_t *result_vector, struct process *process)
 Starts the addition of two big number. More...
 
uint8_t bignum_add_get_result (uint32_t *buffer, uint32_t *buffer_size, const uint32_t result_vector)
 Gets the result of the addition operation on two big number. More...
 
uint8_t bignum_subtract_start (const uint32_t *number1, const uint8_t number1_size, const uint32_t *number2, const uint8_t number2_size, uint32_t *result_vector, struct process *process)
 Starts the substract of two big number. More...
 
uint8_t bignum_subtract_get_result (uint32_t *buffer, uint32_t *buffer_size, const uint32_t result_vector)
 Gets the result of big number subtract. More...
 
uint8_t bignum_exp_mod_start (const uint32_t *number, const uint8_t number_size, const uint32_t *modulus, const uint8_t modulus_size, const uint32_t *base, const uint8_t base_size, uint32_t *result_vector, struct process *process)
 Starts the big number moduluar Exponentiation operation. More...
 
uint8_t bignum_exp_mod_get_result (uint32_t *buffer, const uint8_t buffer_size, const uint32_t result_vector)
 Gets the result of the big number modulus operation result. More...
 
uint8_t bignum_divide_start (const uint32_t *dividend, const uint8_t dividend_size, const uint32_t *divisor, const uint8_t divisor_size, uint32_t *result_vector, struct process *process)
 Starts the big number Divide. More...
 
uint8_t bignum_divide_get_result (uint32_t *buffer, uint32_t *buffer_size, const uint32_t result_vector)
 Gets the results of the big number Divide. More...
 

Detailed Description

Driver for the cc2538 BigNum math functions of the PKC engine.

Function Documentation

◆ bignum_add_get_result()

uint8_t bignum_add_get_result ( uint32_t *  buffer,
uint32_t *  buffer_size,
const uint32_t  result_vector 
)

Gets the result of the addition operation on two big number.

Parameters
bufferPointer to buffer where the result needs to be stored.
buffer_sizeAddress of the variable containing the length of the buffer. After the operation the actual length of the resultant is stored at this address.
result_vectorAddress of the result location which was provided by the start function
See also
PKABigNumAddStart().

This function gets the result of the addition operation on two big numbers, previously started using the function

See also
PKABigNumAddStart().
Return values
PKA_STATUS_SUCCESSif the operation is successful.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy performing the operation.
PKA_STATUS_RESULT_0if the result is all zeroes.
PKA_STATUS_FAILUREif the operation is not successful.
PKA_STATUS_BUF_UNDERFLOWif the length of the provided buffer is less then the length of the result.

Definition at line 605 of file bignum-driver.c.

◆ bignum_add_start()

uint8_t bignum_add_start ( const uint32_t *  number1,
const uint8_t  number1_size,
const uint32_t *  number2,
const uint8_t  number2_size,
uint32_t *  result_vector,
struct process *  process 
)

Starts the addition of two big number.

Parameters
number1Pointer to the buffer containing the first big mumber.
number1_sizeSize of the first big number in 32-bit word.
number2Pointer to the buffer containing the second big number.
number2_sizeSize of the second big number in 32-bit word.
result_vectorPointer to the result vector location which will be set by this function.
processProcess to be polled upon completion of the operation, or NULL

This function starts the addition of the two big numbers.

Return values
PKA_STATUS_SUCCESSif successful in starting the operation.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy doing some other operation.

Definition at line 534 of file bignum-driver.c.

◆ bignum_cmp_get_result()

uint8_t bignum_cmp_get_result ( void  )

Gets the result of the comparison operation of two big numbers.

This function provides the results of the comparison of two big numbers which was started using the

See also
PKABigNumCmpStart().
Return values
PKA_STATUS_OPERATION_INPRGif the operation is in progress.
PKA_STATUS_SUCCESSif the two big numbers are equal.
PKA_STATUS_A_GR_Bif the first number is greater than the second.
PKA_STATUS_A_LT_Bif the first number is less than the second.

Definition at line 249 of file bignum-driver.c.

◆ bignum_cmp_start()

uint8_t bignum_cmp_start ( const uint32_t *  number1,
const uint32_t *  number2,
uint8_t  size,
struct process *  process 
)

Starts the comparison of two big numbers.

Parameters
number1Pointer to the first big number.
number2Pointer to the second big number.
sizeSize of the big number in 32 bit size word.
processProcess to be polled upon completion of the operation, or NULL

This function starts the comparison of two big numbers pointed by number1 and number2. Note this function expects the size of the two big numbers equal.

Return values
PKA_STATUS_SUCCESSif successful in starting the operation.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy doing some other operation.

Definition at line 190 of file bignum-driver.c.

◆ bignum_divide_get_result()

uint8_t bignum_divide_get_result ( uint32_t *  buffer,
uint32_t *  buffer_size,
const uint32_t  result_vector 
)

Gets the results of the big number Divide.

Parameters
bufferPointer to buffer where the result needs to be stored.
buffer_sizeAddress of the variable containing the length of the buffer. After the operation, the actual length of the resultant is stored at this address.
result_vectorAddress of the result location which was provided by the start function
See also
PKABigNumMultiplyStart().

This function gets the result of the Divide of two big numbers operation previously started using the function

See also
PKABigNumDivideStart().
Return values
PKA_STATUS_SUCCESSif the operation is successful.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy performing the operation.
PKA_STATUS_RESULT_0if the result is all zeroes.
PKA_STATUS_FAILUREif the operation is not successful.
PKA_STATUS_BUF_UNDERFLOWif the length of the provided buffer is less then the length of the result.

Definition at line 1011 of file bignum-driver.c.

◆ bignum_divide_start()

uint8_t bignum_divide_start ( const uint32_t *  dividend,
const uint8_t  dividend_size,
const uint32_t *  divisor,
const uint8_t  divisor_size,
uint32_t *  result_vector,
struct process *  process 
)

Starts the big number Divide.

Parameters
dividendPointer to the buffer containing the big number dividend.
dividend_sizeSize of the dividend in 32-bit word.
divisorPointer to the buffer containing the big number divisor.
divisor_sizeSize of the divisor in 32-bit word.
result_vectorPointer to the result vector location which will be set by this function.
processProcess to be polled upon completion of the operation, or NULL

This function starts the divide of the two big numbers.

Return values
PKA_STATUS_SUCCESSif successful in starting the operation.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy doing some other operation.

Definition at line 924 of file bignum-driver.c.

◆ bignum_exp_mod_get_result()

uint8_t bignum_exp_mod_get_result ( uint32_t *  buffer,
const uint8_t  buffer_size,
const uint32_t  result_vector 
)

Gets the result of the big number modulus operation result.

Parameters
bufferPointer to buffer where the result needs to be stored.
buffer_sizeSize of the provided buffer in 32 bit size word.
result_vectorAddress of the result location which was provided by the start function
See also
PKABigNumExpModStart().

This function gets the result of the big number modulus operation which was previously started using the function

See also
PKABigNumExpModStart().
Return values
PKA_STATUS_SUCCESSif successful.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy doing the operation.
PKA_STATUS_RESULT_0if the result is all zeroes.
PKA_STATUS_BUF_UNDERFLOWif the size is less than the length of the result.
Note
  • 0 < number_size <= Max_Len
  • 1 < modulus_size <=Max_Len
  • modulus must be odd and modulus > 232
  • base < modulus

Definition at line 875 of file bignum-driver.c.

◆ bignum_exp_mod_start()

uint8_t bignum_exp_mod_start ( const uint32_t *  number,
const uint8_t  number_size,
const uint32_t *  modulus,
const uint8_t  modulus_size,
const uint32_t *  base,
const uint8_t  base_size,
uint32_t *  result_vector,
struct process *  process 
)

Starts the big number moduluar Exponentiation operation.

Parameters
numberPointer to the Exponent on which moduluar Exponentiation operation needs to be carried out.
number_sizeSize of the the Exponent number number in 32-bit word.
modulusPointer to the divisor.
modulus_sizeSize of the divisor modulus.
basePointer to the Base.
base_sizeSize of the divisor base.
result_vectorPointer to the result vector location which will be set by this function.
processProcess to be polled upon completion of the operation, or NULL

This function starts the moduluar Exponentiation operation on the base num base using the Exponent number and the Modulus num modulus. The PKA RAM location where the result will be available is stored in

See also
result_vector. IMPORTANT = Modulus and Based should have buffers of the same length!
Return values
PKA_STATUS_SUCCESSif successful in starting the operation.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy doing some other operation.

Definition at line 785 of file bignum-driver.c.

◆ bignum_inv_mod_get_result()

uint8_t bignum_inv_mod_get_result ( uint32_t *  buffer,
const uint8_t  buffer_size,
const uint32_t  result_vector 
)

Gets the result of the big number inverse modulo operation.

Parameters
bufferPointer to buffer where the result needs to be stored.
buffer_sizeSize of the provided buffer in 32 bit size word.
result_vectorAddress of the result location which was provided by the start function
See also
PKABigNumInvModStart().

This function gets the result of the big number inverse modulo operation previously started using the function

See also
PKABigNumInvModStart().
Return values
PKA_STATUS_SUCCESSif the operation is successful.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy performing the operation.
PKA_STATUS_RESULT_0if the result is all zeroes.
PKA_STATUS_BUF_UNDERFLOWif the length of the provided buffer is less then the result.

Definition at line 357 of file bignum-driver.c.

◆ bignum_inv_mod_start()

uint8_t bignum_inv_mod_start ( const uint32_t *  number,
const uint8_t  number_size,
const uint32_t *  modulus,
const uint8_t  modulus_size,
uint32_t *  result_vector,
struct process *  process 
)

Starts the big number inverse modulo operation.

Parameters
numberPointer to the buffer containing the big number (dividend).
number_sizeSize of the number in 32 bit word.
modulusPointer to the buffer containing the modulus.
modulus_sizeSize of the modulus in 32 bit word.
result_vectorPointer to the result vector location which will be set by this function.
processProcess to be polled upon completion of the operation, or NULL

This function starts the the inverse modulo operation on number using the divisor modulus.

Return values
PKA_STATUS_SUCCESSif successful in starting the operation.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy doing some other operation.

Definition at line 286 of file bignum-driver.c.

◆ bignum_mod_get_result()

uint8_t bignum_mod_get_result ( uint32_t *  buffer,
const uint8_t  buffer_size,
const uint32_t  result_vector 
)

Gets the result of the big number modulus operation.

Parameters
bufferPointer to buffer where the result needs to be stored.
buffer_sizeSize of the provided buffer in 32 bit size word.
result_vectorAddress of the result location which was provided by the start function
See also
PKABigNumModStart().

This function gets the result of the big number modulus operation which was previously started using the function

See also
PKABigNumModStart().
Return values
PKA_STATUS_SUCCESSif successful.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy doing the operation.
PKA_STATUS_RESULT_0if the result is all zeroes.
PKA_STATUS_BUF_UNDERFLOWif the size is less than the length of the result.

Definition at line 141 of file bignum-driver.c.

◆ bignum_mod_start()

uint8_t bignum_mod_start ( const uint32_t *  number,
const uint8_t  number_size,
const uint32_t *  modulus,
const uint8_t  modulus_size,
uint32_t *  result_vector,
struct process *  process 
)

Starts the big number modulus operation.

Parameters
numberPointer to the big number on which modulo operation needs to be carried out.
number_sizeSize of the big number
See also
number in 32-bit word.
Parameters
modulusPointer to the divisor.
modulus_sizeSize of the divisor
See also
modulus.
Parameters
result_vectorPointer to the result vector location which will be set by this function.
processProcess to be polled upon completion of the operation, or NULL

This function starts the modulo operation on the big num

See also
number using the divisor
modulus. The PKA RAM location where the result will be available is stored in
result_vector.
Return values
PKA_STATUS_SUCCESSif successful in starting the operation.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy doing some other operation.

Definition at line 64 of file bignum-driver.c.

◆ bignum_mul_get_result()

uint8_t bignum_mul_get_result ( uint32_t *  buffer,
uint32_t *  buffer_size,
const uint32_t  result_vector 
)

Gets the results of the big number multiplication.

Parameters
bufferPointer to buffer where the result needs to be stored.
buffer_sizeAddress of the variable containing the length of the buffer. After the operation, the actual length of the resultant is stored at this address.
result_vectorAddress of the result location which was provided by the start function
See also
PKABigNumMultiplyStart().

This function gets the result of the multiplication of two big numbers operation previously started using the function

See also
PKABigNumMultiplyStart().
Return values
PKA_STATUS_SUCCESSif the operation is successful.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy performing the operation.
PKA_STATUS_RESULT_0if the result is all zeroes.
PKA_STATUS_FAILUREif the operation is not successful.
PKA_STATUS_BUF_UNDERFLOWif the length of the provided buffer is less then the length of the result.

Definition at line 480 of file bignum-driver.c.

◆ bignum_mul_start()

uint8_t bignum_mul_start ( const uint32_t *  multiplicand,
const uint8_t  multiplicand_size,
const uint32_t *  multiplier,
const uint8_t  multiplier_size,
uint32_t *  result_vector,
struct process *  process 
)

Starts the big number multiplication.

Parameters
multiplicandPointer to the buffer containing the big number multiplicand.
multiplicand_sizeSize of the multiplicand in 32-bit word.
multiplierPointer to the buffer containing the big number multiplier.
multiplier_sizeSize of the multiplier in 32-bit word.
result_vectorPointer to the result vector location which will be set by this function.
processProcess to be polled upon completion of the operation, or NULL

This function starts the multiplication of the two big numbers.

Return values
PKA_STATUS_SUCCESSif successful in starting the operation.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy doing some other operation.

Definition at line 407 of file bignum-driver.c.

◆ bignum_subtract_get_result()

uint8_t bignum_subtract_get_result ( uint32_t *  buffer,
uint32_t *  buffer_size,
const uint32_t  result_vector 
)

Gets the result of big number subtract.

Parameters
bufferPointer to store the result of subtraction.
buffer_sizeAddress of the variable containing the length of the buffer. After the operation, the actual length of the resultant is stored at this address.
result_vectorAddress of the result location which was provided by the start function PKABigNumSubtractStart().

This function gets the result of PKABigNumSubtractStart().

Return values
PKA_STATUS_SUCCESSif the operation is successful.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy performing the operation.
PKA_STATUS_RESULT_0if the result is all zeroes.
PKA_STATUS_FAILUREif the operation is not successful.

Definition at line 731 of file bignum-driver.c.

◆ bignum_subtract_start()

uint8_t bignum_subtract_start ( const uint32_t *  number1,
const uint8_t  number1_size,
const uint32_t *  number2,
const uint8_t  number2_size,
uint32_t *  result_vector,
struct process *  process 
)

Starts the substract of two big number.

Parameters
number1Pointer to the buffer containing the first big mumber.
number1_sizeSize of the first big number in 32-bit word.
number2Pointer to the buffer containing the second big number.
number2_sizeSize of the second big number in 32-bit word.
result_vectorPointer to the result vector location which will be set by this function.
processProcess to be polled upon completion of the operation, or NULL

This function starts the substraction of the two big numbers.

Return values
PKA_STATUS_SUCCESSif successful in starting the operation.
PKA_STATUS_OPERATION_INPRGif the PKA hw module is busy doing some other operation.

Definition at line 660 of file bignum-driver.c.