Contiki-NG
|
Driver for the cc2538 PKA engine. More...
Modules | |
cc2538 BigNum math function driver | |
Driver for the cc2538 BigNum math functions of the PKC engine. | |
cc2538 ECC driver | |
Driver for the cc2538 ECC mode of the PKC engine. | |
Files | |
file | pka.c |
Implementation of the cc2538 PKA engine driver. | |
file | pka.h |
Header file for the cc2538 PKA engine 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, 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... | |
void | pka_isr (void) |
The PKA engine ISR. More... | |
PKA memory | |
#define | PKA_RAM_BASE 0x44006000 |
PKA Memory Address. | |
#define | PKA_RAM_SIZE 0x800 |
PKA Memory Size. | |
#define | PKA_MAX_CURVE_SIZE 12 |
Define for the maximum curve size supported by the PKA module in 32 bit word. More... | |
#define | PKA_MAX_LEN 12 |
Define for the maximum length of the big number supported by the PKA module in 32 bit word. More... | |
PKA register offsets | |
#define | PKA_APTR 0x44004000 |
PKA vector A address During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact. More... | |
#define | PKA_BPTR 0x44004004 |
PKA vector B address During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact. More... | |
#define | PKA_CPTR 0x44004008 |
PKA vector C address During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact. More... | |
#define | PKA_DPTR 0x4400400C |
PKA vector D address During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact. More... | |
#define | PKA_ALENGTH 0x44004010 |
PKA vector A length During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact. More... | |
#define | PKA_BLENGTH 0x44004014 |
PKA vector B length During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact. More... | |
#define | PKA_SHIFT 0x44004018 |
PKA bit shift value For basic PKCP operations, modifying the contents of this register is made impossible while the operation is being performed. More... | |
#define | PKA_FUNCTION 0x4400401C |
PKA function This register contains the control bits to start basic PKCP as well as complex sequencer operations. More... | |
#define | PKA_COMPARE 0x44004020 |
PKA compare result This register provides the result of a basic PKCP compare operation. More... | |
#define | PKA_MSW 0x44004024 |
PKA most-significant-word of result vector This register indicates the (word) address in the PKA RAM where the most significant nonzero 32-bit word of the result is stored. More... | |
#define | PKA_DIVMSW 0x44004028 |
PKA most-significant-word of divide remainder This register indicates the (32-bit word) address in the PKA RAM where the most significant nonzero 32-bit word of the remainder result for the basic divide and modulo operations is stored. More... | |
#define | PKA_SEQ_CTRL 0x440040C8 |
PKA sequencer control and status register The sequencer is interfaced with the outside world through a single control and status register. More... | |
#define | PKA_OPTIONS 0x440040F4 |
PKA hardware options register This register provides the host with a means to determine the hardware configuration implemented in this PKA engine, focused on options that have an effect on software interacting with the module. More... | |
#define | PKA_SW_REV 0x440040F8 |
PKA firmware revision and capabilities register This register allows the host access to the internal firmware revision number of the PKA Engine for software driver matching and diagnostic purposes. More... | |
#define | PKA_REVISION 0x440040FC |
PKA hardware revision register This register allows the host access to the hardware revision number of the PKA engine for software driver matching and diagnostic purposes. More... | |
PKA_APTR register registers bit fields | |
#define | PKA_APTR_APTR_M 0x000007FF |
This register specifies the location of vector A within the PKA RAM. More... | |
#define | PKA_APTR_APTR_S 0 |
PKA_BPTR register registers bit fields | |
#define | PKA_BPTR_BPTR_M 0x000007FF |
This register specifies the location of vector B within the PKA RAM. More... | |
#define | PKA_BPTR_BPTR_S 0 |
PKA_CPTR register registers bit fields | |
#define | PKA_CPTR_CPTR_M 0x000007FF |
This register specifies the location of vector C within the PKA RAM. More... | |
#define | PKA_CPTR_CPTR_S 0 |
PKA_DPTR register registers bit fields | |
#define | PKA_DPTR_DPTR_M 0x000007FF |
This register specifies the location of vector D within the PKA RAM. More... | |
#define | PKA_DPTR_DPTR_S 0 |
PKA_ALENGTH register registers bit fields | |
#define | PKA_ALENGTH_ALENGTH_M 0x000001FF |
This register specifies the length (in 32-bit words) of Vector A. More... | |
#define | PKA_ALENGTH_ALENGTH_S 0 |
PKA_BLENGTH register registers bit fields | |
#define | PKA_BLENGTH_BLENGTH_M 0x000001FF |
This register specifies the length (in 32-bit words) of Vector B. More... | |
#define | PKA_BLENGTH_BLENGTH_S 0 |
PKA_SHIFT register registers bit fields | |
#define | PKA_SHIFT_NUM_BITS_TO_SHIFT_M 0x0000001F |
This register specifies the number of bits to shift the input vector (in the range 0-31) during a Rshift or Lshift operation. More... | |
#define | PKA_SHIFT_NUM_BITS_TO_SHIFT_S 0 |
PKA_FUNCTION register registers bit fields | |
#define | PKA_FUNCTION_STALL_RESULT 0x01000000 |
When written with a 1b, updating of the PKA_COMPARE, PKA_MSW and PKA_DIVMSW registers, as well as resetting the run bit is stalled beyond the point that a running operation is actually finished. More... | |
#define | PKA_FUNCTION_STALL_RESULT_M 0x01000000 |
#define | PKA_FUNCTION_STALL_RESULT_S 24 |
#define | PKA_FUNCTION_RUN 0x00008000 |
The host sets this bit to instruct the PKA module to begin processing the basic PKCP or complex sequencer operation. More... | |
#define | PKA_FUNCTION_RUN_M 0x00008000 |
#define | PKA_FUNCTION_RUN_S 15 |
#define | PKA_FUNCTION_SEQUENCER_OPERATIONS_M 0x00007000 |
These bits select the complex sequencer operation to perform: 000b: None 001b: ExpMod-CRT 010b: ExpMod-ACT4 (compatible with EIP2315) 011b: ECC-ADD (if available in firmware, otherwise reserved) 100b: ExpMod-ACT2 (compatible with EIP2316) 101b: ECC-MUL (if available in firmware, otherwise reserved) 110b: ExpMod-variable 111b: ModInv (if available in firmware, otherwise reserved) The encoding of these operations is determined by sequencer firmware. More... | |
#define | PKA_FUNCTION_SEQUENCER_OPERATIONS_S 12 |
#define | PKA_FUNCTION_COPY 0x00000800 |
Perform copy operation. | |
#define | PKA_FUNCTION_COPY_M 0x00000800 |
#define | PKA_FUNCTION_COPY_S 11 |
#define | PKA_FUNCTION_COMPARE 0x00000400 |
Perform compare operation. | |
#define | PKA_FUNCTION_COMPARE_M 0x00000400 |
#define | PKA_FUNCTION_COMPARE_S 10 |
#define | PKA_FUNCTION_MODULO 0x00000200 |
Perform modulo operation. | |
#define | PKA_FUNCTION_MODULO_M 0x00000200 |
#define | PKA_FUNCTION_MODULO_S 9 |
#define | PKA_FUNCTION_DIVIDE 0x00000100 |
Perform divide operation. | |
#define | PKA_FUNCTION_DIVIDE_M 0x00000100 |
#define | PKA_FUNCTION_DIVIDE_S 8 |
#define | PKA_FUNCTION_LSHIFT 0x00000080 |
Perform left shift operation. | |
#define | PKA_FUNCTION_LSHIFT_M 0x00000080 |
#define | PKA_FUNCTION_LSHIFT_S 7 |
#define | PKA_FUNCTION_RSHIFT 0x00000040 |
Perform right shift operation. | |
#define | PKA_FUNCTION_RSHIFT_M 0x00000040 |
#define | PKA_FUNCTION_RSHIFT_S 6 |
#define | PKA_FUNCTION_SUBTRACT 0x00000020 |
Perform subtract operation. | |
#define | PKA_FUNCTION_SUBTRACT_M 0x00000020 |
#define | PKA_FUNCTION_SUBTRACT_S 5 |
#define | PKA_FUNCTION_ADD 0x00000010 |
Perform add operation. | |
#define | PKA_FUNCTION_ADD_M 0x00000010 |
#define | PKA_FUNCTION_ADD_S 4 |
#define | PKA_FUNCTION_MS_ONE 0x00000008 |
Loads the location of the Most Significant one bit within the result word indicated in the PKA_MSW register into bits [4:0] of the PKA_DIVMSW register - can only be used with basic PKCP operations, except for Divide, Modulo and Compare. More... | |
#define | PKA_FUNCTION_MS_ONE_M 0x00000008 |
#define | PKA_FUNCTION_MS_ONE_S 3 |
#define | PKA_FUNCTION_ADDSUB 0x00000002 |
Perform combined add/subtract operation. | |
#define | PKA_FUNCTION_ADDSUB_M 0x00000002 |
#define | PKA_FUNCTION_ADDSUB_S 1 |
#define | PKA_FUNCTION_MULTIPLY 0x00000001 |
Perform multiply operation. | |
#define | PKA_FUNCTION_MULTIPLY_M 0x00000001 |
#define | PKA_FUNCTION_MULTIPLY_S 0 |
PKA_COMPARE register registers bit fields | |
#define | PKA_COMPARE_A_GREATER_THAN_B 0x00000004 |
Vector_A is greater than Vector_B. | |
#define | PKA_COMPARE_A_GREATER_THAN_B_M 0x00000004 |
#define | PKA_COMPARE_A_GREATER_THAN_B_S 2 |
#define | PKA_COMPARE_A_LESS_THAN_B 0x00000002 |
Vector_A is less than Vector_B. | |
#define | PKA_COMPARE_A_LESS_THAN_B_M 0x00000002 |
#define | PKA_COMPARE_A_LESS_THAN_B_S 1 |
#define | PKA_COMPARE_A_EQUALS_B 0x00000001 |
Vector_A is equal to Vector_B. | |
#define | PKA_COMPARE_A_EQUALS_B_M 0x00000001 |
#define | PKA_COMPARE_A_EQUALS_B_S 0 |
PKA_MSW register registers bit fields | |
#define | PKA_MSW_RESULT_IS_ZERO 0x00008000 |
The result vector is all zeroes, ignore the address returned in bits [10:0]. | |
#define | PKA_MSW_RESULT_IS_ZERO_M 0x00008000 |
#define | PKA_MSW_RESULT_IS_ZERO_S 15 |
#define | PKA_MSW_MSW_ADDRESS_M 0x000007FF |
Address of the most-significant nonzero 32-bit word of the result vector in PKA RAM. | |
#define | PKA_MSW_MSW_ADDRESS_S 0 |
PKA_DIVMSW register registers bit fields | |
#define | PKA_DIVMSW_RESULT_IS_ZERO 0x00008000 |
The result vector is all zeroes, ignore the address returned in bits [10:0]. | |
#define | PKA_DIVMSW_RESULT_IS_ZERO_M 0x00008000 |
#define | PKA_DIVMSW_RESULT_IS_ZERO_S 15 |
#define | PKA_DIVMSW_MSW_ADDRESS_M 0x000007FF |
Address of the most significant nonzero 32-bit word of the remainder result vector in PKA RAM. | |
#define | PKA_DIVMSW_MSW_ADDRESS_S 0 |
PKA_SEQ_CTRL register registers bit fields | |
#define | PKA_SEQ_CTRL_RESET 0x80000000 |
Option program ROM: Reset value = 0. More... | |
#define | PKA_SEQ_CTRL_RESET_M 0x80000000 |
#define | PKA_SEQ_CTRL_RESET_S 31 |
#define | PKA_SEQ_CTRL_SEQUENCER_STATUS_M 0x0000FF00 |
These read-only bits can be used by the sequencer to communicate status to the outside world. More... | |
#define | PKA_SEQ_CTRL_SEQUENCER_STATUS_S 8 |
#define | PKA_SEQ_CTRL_SW_CONTROL_STATUS_M 0x000000FF |
These bits can be used by software to trigger sequencer operations. More... | |
#define | PKA_SEQ_CTRL_SW_CONTROL_STATUS_S 0 |
PKA_OPTIONS register registers bit fields | |
#define | PKA_OPTIONS_FIRST_LNME_FIFO_DEPTH_M 0xFF000000 |
Number of words in the first LNME's FIFO RAM Should be ignored if LNME configuration is 0. More... | |
#define | PKA_OPTIONS_FIRST_LNME_FIFO_DEPTH_S 24 |
#define | PKA_OPTIONS_FIRST_LNME_NR_OF_PES_M 0x003F0000 |
Number of processing elements in the pipeline of the first LNME Should be ignored if LNME configuration is 0. More... | |
#define | PKA_OPTIONS_FIRST_LNME_NR_OF_PES_S 16 |
#define | PKA_OPTIONS_MMM3A 0x00001000 |
Reserved for a future functional extension to the LNME Always 0b. | |
#define | PKA_OPTIONS_MMM3A_M 0x00001000 |
#define | PKA_OPTIONS_MMM3A_S 12 |
#define | PKA_OPTIONS_INT_MASKING 0x00000800 |
Value 0b indicates that the main interrupt output (bit [1] of the interrupts output bus) is the direct complement of the run bit in the PKA_CONTROL register, value 1b indicates that interrupt masking logic is present for this output. More... | |
#define | PKA_OPTIONS_INT_MASKING_M 0x00000800 |
#define | PKA_OPTIONS_INT_MASKING_S 11 |
#define | PKA_OPTIONS_PROTECTION_OPTION_M 0x00000700 |
Value 0 indicates no additional protection against side channel attacks, value 1 indicates the SCAP option, value 3 indicates the PROT option; other values are reserved. More... | |
#define | PKA_OPTIONS_PROTECTION_OPTION_S 8 |
#define | PKA_OPTIONS_PROGRAM_RAM 0x00000080 |
Value 1b indicates sequencer program storage in RAM, value 0b in ROM. More... | |
#define | PKA_OPTIONS_PROGRAM_RAM_M 0x00000080 |
#define | PKA_OPTIONS_PROGRAM_RAM_S 7 |
#define | PKA_OPTIONS_SEQUENCER_CONFIGURATION_M 0x00000060 |
Value 1 indicates a standard sequencer; other values are reserved. More... | |
#define | PKA_OPTIONS_SEQUENCER_CONFIGURATION_S 5 |
#define | PKA_OPTIONS_LNME_CONFIGURATION_M 0x0000001C |
Value 0 indicates NO LNME, value 1 indicates one standard LNME (with alpha = 32, beta = 8); other values reserved. More... | |
#define | PKA_OPTIONS_LNME_CONFIGURATION_S 2 |
#define | PKA_OPTIONS_PKCP_CONFIGURATION_M 0x00000003 |
Value 1 indicates a PKCP with a 16x16 multiplier, value 2 indicates a PKCP with a 32x32 multiplier, other values reserved. More... | |
#define | PKA_OPTIONS_PKCP_CONFIGURATION_S 0 |
PKA_SW_REV register registers bit fields | |
#define | PKA_SW_REV_FW_CAPABILITIES_M 0xF0000000 |
4-bit binary encoding for the functionality implemented in the firmware. More... | |
#define | PKA_SW_REV_FW_CAPABILITIES_S 28 |
#define | PKA_SW_REV_MAJOR_FW_REVISION_M 0x0F000000 |
4-bit binary encoding of the major firmware revision number | |
#define | PKA_SW_REV_MAJOR_FW_REVISION_S 24 |
#define | PKA_SW_REV_MINOR_FW_REVISION_M 0x00F00000 |
4-bit binary encoding of the minor firmware revision number | |
#define | PKA_SW_REV_MINOR_FW_REVISION_S 20 |
#define | PKA_SW_REV_FW_PATCH_LEVEL_M 0x000F0000 |
4-bit binary encoding of the firmware patch level, initial release will carry value zero Patches are used to remove bugs without changing the functionality or interface of a module. More... | |
#define | PKA_SW_REV_FW_PATCH_LEVEL_S 16 |
PKA_REVISION register registers bit fields | |
#define | PKA_REVISION_MAJOR_HW_REVISION_M 0x0F000000 |
4-bit binary encoding of the major hardware revision number | |
#define | PKA_REVISION_MAJOR_HW_REVISION_S 24 |
#define | PKA_REVISION_MINOR_HW_REVISION_M 0x00F00000 |
4-bit binary encoding of the minor hardware revision number | |
#define | PKA_REVISION_MINOR_HW_REVISION_S 20 |
#define | PKA_REVISION_HW_PATCH_LEVEL_M 0x000F0000 |
4-bit binary encoding of the hardware patch level, initial release will carry value zero Patches are used to remove bugs without changing the functionality or interface of a module. More... | |
#define | PKA_REVISION_HW_PATCH_LEVEL_S 16 |
#define | PKA_REVISION_COMPLEMENT_OF_BASIC_EIP_NUMBER_M 0x0000FF00 |
Bit-by-bit logic complement of bits [7:0], EIP-28 gives 0xE3. | |
#define | PKA_REVISION_COMPLEMENT_OF_BASIC_EIP_NUMBER_S 8 |
#define | PKA_REVISION_BASIC_EIP_NUMBER_M 0x000000FF |
8-bit binary encoding of the EIP number, EIP-28 gives 0x1C | |
#define | PKA_REVISION_BASIC_EIP_NUMBER_S 0 |
PKA driver return codes | |
#define | PKA_STATUS_SUCCESS 0 |
Success. | |
#define | PKA_STATUS_FAILURE 1 |
Failure. | |
#define | PKA_STATUS_INVALID_PARAM 2 |
Invalid parameter. | |
#define | PKA_STATUS_BUF_UNDERFLOW 3 |
Buffer underflow. | |
#define | PKA_STATUS_RESULT_0 4 |
Result is all zeros. | |
#define | PKA_STATUS_A_GR_B 5 |
Big number compare return status if the first big num is greater than the second. More... | |
#define | PKA_STATUS_A_LT_B 6 |
Big number compare return status if the first big num is less than the second. More... | |
#define | PKA_STATUS_OPERATION_INPRG 7 |
PKA operation is in progress. More... | |
#define | PKA_STATUS_OPERATION_NOT_INPRG 8 |
No PKA operation is in progress. More... | |
#define | PKA_STATUS_SIGNATURE_INVALID 9 |
Signature is invalid. More... | |
PKA functions | |
void | pka_init (void) |
Enables and resets the PKA engine. | |
void | pka_enable (void) |
Enables the PKA engine. | |
void | pka_disable (void) |
Disables the PKA engine. More... | |
uint8_t | pka_check_status (void) |
Checks the status of the PKA engine operation. More... | |
void | pka_register_process_notification (struct process *p) |
Registers a process to be notified of the completion of a PKA operation. More... | |
Driver for the cc2538 PKA engine.
#define PKA_ALENGTH 0x44004010 |
PKA vector A length During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact.
During the execution of sequencer-controlled complex operations, this register may not be written and its value is undefined at the conclusion of the operation. The driver software cannot rely on the written value to remain intact.
#define PKA_ALENGTH_ALENGTH_M 0x000001FF |
#define PKA_APTR 0x44004000 |
PKA vector A address During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact.
During the execution of sequencer-controlled complex operations, this register may not be written and its value is undefined at the conclusion of the operation. The driver software cannot rely on the written value to remain intact.
#define PKA_APTR_APTR_M 0x000007FF |
#define PKA_BLENGTH 0x44004014 |
PKA vector B length During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact.
During the execution of sequencer-controlled complex operations, this register may not be written and its value is undefined at the conclusion of the operation. The driver software cannot rely on the written value to remain intact.
#define PKA_BLENGTH_BLENGTH_M 0x000001FF |
#define PKA_BPTR 0x44004004 |
PKA vector B address During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact.
During the execution of sequencer-controlled complex operations, this register may not be written and its value is undefined at the conclusion of the operation. The driver software cannot rely on the written value to remain intact.
#define PKA_BPTR_BPTR_M 0x000007FF |
#define PKA_COMPARE 0x44004020 |
#define PKA_CPTR 0x44004008 |
PKA vector C address During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact.
During the execution of sequencer-controlled complex operations, this register may not be written and its value is undefined at the conclusion of the operation. The driver software cannot rely on the written value to remain intact.
#define PKA_CPTR_CPTR_M 0x000007FF |
#define PKA_DIVMSW 0x44004028 |
PKA most-significant-word of divide remainder This register indicates the (32-bit word) address in the PKA RAM where the most significant nonzero 32-bit word of the remainder result for the basic divide and modulo operations is stored.
Bits [4:0] are loaded with the bit number of the most-significant nonzero bit in the most-significant nonzero word when MS one control bit is set. For divide, modulo, and MS one reporting, this register is updated when the RUN bit in the PKA_FUNCTION register is reset at the end of the operation. For the complex sequencer controlled operations, updating of bits [4:0] of this register with the most-significant bit location of the actual result is done near the end of the operation. The result is meaningful only if no errors were detected and that for ECC operations; the PKA_DIVMSW register provides information for the x-coordinate of the result point only.
#define PKA_DPTR 0x4400400C |
PKA vector D address During execution of basic PKCP operations, this register is double buffered and can be written with a new value for the next operation; when not written, the value remains intact.
During the execution of sequencer-controlled complex operations, this register may not be written and its value is undefined at the conclusion of the operation. The driver software cannot rely on the written value to remain intact.
#define PKA_DPTR_DPTR_M 0x000007FF |
#define PKA_FUNCTION 0x4400401C |
PKA function This register contains the control bits to start basic PKCP as well as complex sequencer operations.
The run bit can be used to poll for the completion of the operation. Modifying bits [11:0] is made impossible during the execution of a basic PKCP operation. During the execution of sequencer-controlled complex operations, this register is modified; the run and stall result bits are set to zero at the conclusion, but other bits are undefined. Attention: Continuously reading this register to poll the run bit is not allowed when executing complex sequencer operations (the sequencer cannot access the PKCP when this is done). Leave at least one sysclk cycle between poll operations.
#define PKA_FUNCTION_MS_ONE 0x00000008 |
#define PKA_FUNCTION_RUN 0x00008000 |
The host sets this bit to instruct the PKA module to begin processing the basic PKCP or complex sequencer operation.
This bit is reset low automatically when the operation is complete. The complement of this bit is output as interrupts[1]. After a reset, the run bit is always set to 1b. Depending on the option, program ROM or program RAM, the following applies: Program ROM - The first sequencer instruction sets the bit to 0b. This is done immediately after the hardware reset is released. Program RAM - The sequencer must set the bit to 0b. As a valid firmware may not have been loaded, the sequencer is held in software reset after the hardware reset is released (the reset bit in PKA_SEQ_CRTL is set to 1b). After the FW image is loaded and the Reset bit is cleared, the sequencer starts to execute the FW. The first instruction clears the run bit. In both cases a few clock cycles are needed before the first instruction is executed and the run bit state has been propagated.
#define PKA_FUNCTION_SEQUENCER_OPERATIONS_M 0x00007000 |
These bits select the complex sequencer operation to perform: 000b: None 001b: ExpMod-CRT 010b: ExpMod-ACT4 (compatible with EIP2315) 011b: ECC-ADD (if available in firmware, otherwise reserved) 100b: ExpMod-ACT2 (compatible with EIP2316) 101b: ECC-MUL (if available in firmware, otherwise reserved) 110b: ExpMod-variable 111b: ModInv (if available in firmware, otherwise reserved) The encoding of these operations is determined by sequencer firmware.
#define PKA_FUNCTION_STALL_RESULT 0x01000000 |
When written with a 1b, updating of the PKA_COMPARE, PKA_MSW and PKA_DIVMSW registers, as well as resetting the run bit is stalled beyond the point that a running operation is actually finished.
Use this to allow software enough time to read results from a previous operation when the newly started operation is known to take only a short amount of time. If a result is waiting, the result registers is updated and the run bit is reset in the clock cycle following writing the stall result bit back to 0b. The Stall result function may only be used for basic PKCP operations.
#define PKA_MAX_CURVE_SIZE 12 |
#define PKA_MAX_LEN 12 |
#define PKA_MSW 0x44004024 |
PKA most-significant-word of result vector This register indicates the (word) address in the PKA RAM where the most significant nonzero 32-bit word of the result is stored.
Should be ignored for modulo operations. For basic PKCP operations, this register is updated when the run bit in the PKA_FUNCTION register is reset at the end of the operation. For the complex-sequencer controlled operations, updating of the final value matching the actual result is done near the end of the operation; note that the result is only meaningful if no errors were detected and that for ECC operations, the PKA_MSW register will provide information for the x-coordinate of the result point only.
#define PKA_OPTIONS 0x440040F4 |
PKA hardware options register This register provides the host with a means to determine the hardware configuration implemented in this PKA engine, focused on options that have an effect on software interacting with the module.
Note: (32 x (1st LNME nr. of PEs + 1st LNME FIFO RAM depth - 10)) equals the maximum modulus vector length (in bits) that can be handled by the modular exponentiation and ECC operations executed on a PKA engine that includes an LNME.
#define PKA_OPTIONS_FIRST_LNME_FIFO_DEPTH_M 0xFF000000 |
#define PKA_OPTIONS_FIRST_LNME_NR_OF_PES_M 0x003F0000 |
#define PKA_OPTIONS_INT_MASKING 0x00000800 |
Value 0b indicates that the main interrupt output (bit [1] of the interrupts output bus) is the direct complement of the run bit in the PKA_CONTROL register, value 1b indicates that interrupt masking logic is present for this output.
Note: Reset value is undefined
#define PKA_OPTIONS_LNME_CONFIGURATION_M 0x0000001C |
#define PKA_OPTIONS_PKCP_CONFIGURATION_M 0x00000003 |
#define PKA_OPTIONS_PROGRAM_RAM 0x00000080 |
#define PKA_OPTIONS_PROTECTION_OPTION_M 0x00000700 |
#define PKA_OPTIONS_SEQUENCER_CONFIGURATION_M 0x00000060 |
#define PKA_REVISION 0x440040FC |
PKA hardware revision register This register allows the host access to the hardware revision number of the PKA engine for software driver matching and diagnostic purposes.
It is always located at the highest address in the access space of the module and contains an encoding of the EIP number (with its complement as signature) for recognition of the hardware module.
#define PKA_REVISION_HW_PATCH_LEVEL_M 0x000F0000 |
#define PKA_SEQ_CTRL 0x440040C8 |
PKA sequencer control and status register The sequencer is interfaced with the outside world through a single control and status register.
With the exception of bit [31], the actual use of bits in the separate sub-fields of this register is determined by the sequencer firmware. This register need only be accessed when the sequencer program is stored in RAM. The reset value of the RESTE bit depends upon the option chosen for sequencer program storage.
#define PKA_SEQ_CTRL_RESET 0x80000000 |
Option program ROM: Reset value = 0.
Read/Write, reset value 0b (ZERO). Writing 1b resets the sequencer, write to 0b to restart operations again. As the reset value is 0b, the sequencer will automatically start operations executing from program ROM. This bit should always be written with zero and ignored when reading this register. Option Program RAM: Reset value =1. Read/Write, reset value 1b (ONE). When 1b, the sequencer is held in a reset state and the PKA_PROGRAM area is accessible for loading the sequencer program (while the PKA_DATA_RAM is inaccessible), write to 0b to (re)start sequencer operations and disable PKA_PROGRAM area accessibility (also enables the PKA_DATA_RAM accesses). Resetting the sequencer (in order to load other firmware) should only be done when the PKA Engine is not performing any operations (i.e. the run bit in the PKA_FUNCTION register should be zero).
#define PKA_SEQ_CTRL_SEQUENCER_STATUS_M 0x0000FF00 |
These read-only bits can be used by the sequencer to communicate status to the outside world.
Bit [8] is also used as sequencer interrupt, with the complement of this bit ORed into the run bit in PKA_FUNCTION. This field should always be written with zeroes and ignored when reading this register.
#define PKA_SEQ_CTRL_SW_CONTROL_STATUS_M 0x000000FF |
These bits can be used by software to trigger sequencer operations.
External logic can set these bits by writing 1b, cannot reset them by writing 0b. The sequencer can reset these bits by writing 0b, cannot set them by writing 1b. Setting the run bit in PKA_FUNCTION together with a nonzero sequencer operations field automatically sets bit [0] here. This field should always be written with zeroes and ignored when reading this register.
#define PKA_SHIFT 0x44004018 |
PKA bit shift value For basic PKCP operations, modifying the contents of this register is made impossible while the operation is being performed.
For the ExpMod-variable and ExpMod-CRT operations, this register is used to indicate the number of odd powers to use (directly as a value in the range 1-16). For the ModInv and ECC operations, this register is used to hold a completion code.
#define PKA_SHIFT_NUM_BITS_TO_SHIFT_M 0x0000001F |
#define PKA_STATUS_A_GR_B 5 |
#define PKA_STATUS_A_LT_B 6 |
#define PKA_STATUS_OPERATION_INPRG 7 |
#define PKA_STATUS_OPERATION_NOT_INPRG 8 |
#define PKA_SW_REV 0x440040F8 |
PKA firmware revision and capabilities register This register allows the host access to the internal firmware revision number of the PKA Engine for software driver matching and diagnostic purposes.
This register also contains a field that encodes the capabilities of the embedded firmware. The PKA_SW_REV register is written by the firmware within a few clock cycles after starting up that firmware. The hardware reset value is zero, indicating that the information has not been written yet.
#define PKA_SW_REV_FW_CAPABILITIES_M 0xF0000000 |
#define PKA_SW_REV_FW_PATCH_LEVEL_M 0x000F0000 |
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.
buffer | Pointer to buffer where the result needs to be stored. |
buffer_size | Address of the variable containing the length of the buffer. After the operation the actual length of the resultant is stored at this address. |
result_vector | Address of the result location which was provided by the start function |
This function gets the result of the addition operation on two big numbers, previously started using the function
PKA_STATUS_SUCCESS | if the operation is successful. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy performing the operation. |
PKA_STATUS_RESULT_0 | if the result is all zeroes. |
PKA_STATUS_FAILURE | if the operation is not successful. |
PKA_STATUS_BUF_UNDERFLOW | if the length of the provided buffer is less then the length of the result. |
Definition at line 605 of file bignum-driver.c.
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.
number1 | Pointer to the buffer containing the first big mumber. |
number1_size | Size of the first big number in 32-bit word. |
number2 | Pointer to the buffer containing the second big number. |
number2_size | Size of the second big number in 32-bit word. |
result_vector | Pointer to the result vector location which will be set by this function. |
process | Process to be polled upon completion of the operation, or NULL |
This function starts the addition of the two big numbers.
PKA_STATUS_SUCCESS | if successful in starting the operation. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy doing some other operation. |
Definition at line 534 of file bignum-driver.c.
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
PKA_STATUS_OPERATION_INPRG | if the operation is in progress. |
PKA_STATUS_SUCCESS | if the two big numbers are equal. |
PKA_STATUS_A_GR_B | if the first number is greater than the second. |
PKA_STATUS_A_LT_B | if the first number is less than the second. |
Definition at line 249 of file bignum-driver.c.
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.
number1 | Pointer to the first big number. |
number2 | Pointer to the second big number. |
size | Size of the big number in 32 bit size word. |
process | Process 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.
PKA_STATUS_SUCCESS | if successful in starting the operation. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy doing some other operation. |
Definition at line 190 of file bignum-driver.c.
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.
buffer | Pointer to buffer where the result needs to be stored. |
buffer_size | Address of the variable containing the length of the buffer. After the operation, the actual length of the resultant is stored at this address. |
result_vector | Address of the result location which was provided by the start function |
This function gets the result of the Divide of two big numbers operation previously started using the function
PKA_STATUS_SUCCESS | if the operation is successful. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy performing the operation. |
PKA_STATUS_RESULT_0 | if the result is all zeroes. |
PKA_STATUS_FAILURE | if the operation is not successful. |
PKA_STATUS_BUF_UNDERFLOW | if the length of the provided buffer is less then the length of the result. |
Definition at line 1011 of file bignum-driver.c.
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.
dividend | Pointer to the buffer containing the big number dividend. |
dividend_size | Size of the dividend in 32-bit word. |
divisor | Pointer to the buffer containing the big number divisor. |
divisor_size | Size of the divisor in 32-bit word. |
result_vector | Pointer to the result vector location which will be set by this function. |
process | Process to be polled upon completion of the operation, or NULL |
This function starts the divide of the two big numbers.
PKA_STATUS_SUCCESS | if successful in starting the operation. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy doing some other operation. |
Definition at line 924 of file bignum-driver.c.
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.
buffer | Pointer to buffer where the result needs to be stored. |
buffer_size | Size of the provided buffer in 32 bit size word. |
result_vector | Address of the result location which was provided by the start function |
This function gets the result of the big number modulus operation which was previously started using the function
PKA_STATUS_SUCCESS | if successful. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy doing the operation. |
PKA_STATUS_RESULT_0 | if the result is all zeroes. |
PKA_STATUS_BUF_UNDERFLOW | if the size is less than the length of the result. |
Definition at line 875 of file bignum-driver.c.
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.
number | Pointer to the Exponent on which moduluar Exponentiation operation needs to be carried out. |
number_size | Size of the the Exponent number number in 32-bit word. |
modulus | Pointer to the divisor. |
modulus_size | Size of the divisor modulus. |
base | Pointer to the Base. |
base_size | Size of the divisor base. |
result_vector | Pointer to the result vector location which will be set by this function. |
process | Process 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
PKA_STATUS_SUCCESS | if successful in starting the operation. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy doing some other operation. |
Definition at line 785 of file bignum-driver.c.
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.
buffer | Pointer to buffer where the result needs to be stored. |
buffer_size | Size of the provided buffer in 32 bit size word. |
result_vector | Address of the result location which was provided by the start function |
This function gets the result of the big number inverse modulo operation previously started using the function
PKA_STATUS_SUCCESS | if the operation is successful. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy performing the operation. |
PKA_STATUS_RESULT_0 | if the result is all zeroes. |
PKA_STATUS_BUF_UNDERFLOW | if the length of the provided buffer is less then the result. |
Definition at line 357 of file bignum-driver.c.
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.
number | Pointer to the buffer containing the big number (dividend). |
number_size | Size of the number in 32 bit word. |
modulus | Pointer to the buffer containing the modulus. |
modulus_size | Size of the modulus in 32 bit word. |
result_vector | Pointer to the result vector location which will be set by this function. |
process | Process to be polled upon completion of the operation, or NULL |
This function starts the the inverse modulo operation on number using the divisor modulus.
PKA_STATUS_SUCCESS | if successful in starting the operation. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy doing some other operation. |
Definition at line 286 of file bignum-driver.c.
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.
buffer | Pointer to buffer where the result needs to be stored. |
buffer_size | Size of the provided buffer in 32 bit size word. |
result_vector | Address of the result location which was provided by the start function |
This function gets the result of the big number modulus operation which was previously started using the function
PKA_STATUS_SUCCESS | if successful. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy doing the operation. |
PKA_STATUS_RESULT_0 | if the result is all zeroes. |
PKA_STATUS_BUF_UNDERFLOW | if the size is less than the length of the result. |
Definition at line 141 of file bignum-driver.c.
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.
number | Pointer to the big number on which modulo operation needs to be carried out. |
number_size | Size of the big number |
modulus | Pointer to the divisor. |
modulus_size | Size of the divisor |
result_vector | Pointer to the result vector location which will be set by this function. |
process | Process to be polled upon completion of the operation, or NULL |
This function starts the modulo operation on the big num
PKA_STATUS_SUCCESS | if successful in starting the operation. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy doing some other operation. |
Definition at line 64 of file bignum-driver.c.
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.
buffer | Pointer to buffer where the result needs to be stored. |
buffer_size | Address of the variable containing the length of the buffer. After the operation, the actual length of the resultant is stored at this address. |
result_vector | Address of the result location which was provided by the start function |
This function gets the result of the multiplication of two big numbers operation previously started using the function
PKA_STATUS_SUCCESS | if the operation is successful. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy performing the operation. |
PKA_STATUS_RESULT_0 | if the result is all zeroes. |
PKA_STATUS_FAILURE | if the operation is not successful. |
PKA_STATUS_BUF_UNDERFLOW | if the length of the provided buffer is less then the length of the result. |
Definition at line 480 of file bignum-driver.c.
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.
multiplicand | Pointer to the buffer containing the big number multiplicand. |
multiplicand_size | Size of the multiplicand in 32-bit word. |
multiplier | Pointer to the buffer containing the big number multiplier. |
multiplier_size | Size of the multiplier in 32-bit word. |
result_vector | Pointer to the result vector location which will be set by this function. |
process | Process to be polled upon completion of the operation, or NULL |
This function starts the multiplication of the two big numbers.
PKA_STATUS_SUCCESS | if successful in starting the operation. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy doing some other operation. |
Definition at line 407 of file bignum-driver.c.
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.
buffer | Pointer to store the result of subtraction. |
buffer_size | Address of the variable containing the length of the buffer. After the operation, the actual length of the resultant is stored at this address. |
result_vector | Address of the result location which was provided by the start function PKABigNumSubtractStart(). |
This function gets the result of PKABigNumSubtractStart().
PKA_STATUS_SUCCESS | if the operation is successful. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy performing the operation. |
PKA_STATUS_RESULT_0 | if the result is all zeroes. |
PKA_STATUS_FAILURE | if the operation is not successful. |
Definition at line 731 of file bignum-driver.c.
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.
number1 | Pointer to the buffer containing the first big mumber. |
number1_size | Size of the first big number in 32-bit word. |
number2 | Pointer to the buffer containing the second big number. |
number2_size | Size of the second big number in 32-bit word. |
result_vector | Pointer to the result vector location which will be set by this function. |
process | Process to be polled upon completion of the operation, or NULL |
This function starts the substraction of the two big numbers.
PKA_STATUS_SUCCESS | if successful in starting the operation. |
PKA_STATUS_OPERATION_INPRG | if the PKA hw module is busy doing some other operation. |
Definition at line 660 of file bignum-driver.c.
uint8_t pka_check_status | ( | void | ) |
void pka_disable | ( | void | ) |
void pka_isr | ( | void | ) |
The PKA engine ISR.
This is the interrupt service routine for the PKA engine.
This ISR is called at worst from PM0, so lpm_exit() does not need to be called.
Definition at line 62 of file pka.c.
References NVIC_ClearPendingIRQ(), NVIC_DisableIRQ(), and PKA_IRQn.