46 #define ASSERT(IF) if(!(IF)) { return PKA_STATUS_INVALID_PARAM; } 51 ecc_curve_info_t *curve, uint32_t *result_vector,
52 struct process *process)
60 ASSERT(NULL != scalar);
61 ASSERT(NULL != ec_point);
62 ASSERT(NULL != ec_point->x);
63 ASSERT(NULL != ec_point->y);
64 ASSERT(NULL != curve);
66 ASSERT(NULL != result_vector);
76 extraBuf = 2 + curve->size % 2;
83 for(i = 0; i < curve->size; i++) {
88 offset += 4 * (i + (curve->size % 2));
96 for(i = 0; i < curve->size; i++) {
97 REG(
PKA_RAM_BASE + offset + 4 * i) = (uint32_t)curve->prime[i];
101 offset += 4 * (i + extraBuf);
104 for(i = 0; i < curve->size; i++) {
105 REG(
PKA_RAM_BASE + offset + 4 * i) = (uint32_t)curve->a[i];
109 offset += 4 * (i + extraBuf);
112 for(i = 0; i < curve->size; i++) {
113 REG(
PKA_RAM_BASE + offset + 4 * i) = (uint32_t)curve->b[i];
117 offset += 4 * (i + extraBuf);
124 for(i = 0; i < curve->size; i++) {
129 offset += 4 * (i + extraBuf);
132 for(i = 0; i < curve->size; i++) {
137 offset += 4 * (i + extraBuf);
153 if(process != NULL) {
164 uint32_t result_vector)
172 ASSERT(NULL != ec_point);
173 ASSERT(NULL != ec_point->x);
174 ASSERT(NULL != ec_point->y);
200 addr = result_vector;
204 for(i = 0; i < len; i++) {
205 ec_point->x[i] = REG(addr + 4 * i);
208 addr += 4 * (i + 2 + len % 2);
212 for(i = 0; i < len; i++) {
213 ec_point->y[i] = REG(addr + 4 * i);
224 uint32_t *result_vector,
struct process *process)
231 ASSERT(NULL != scalar);
232 ASSERT(NULL != curve);
234 ASSERT(NULL != result_vector);
244 extraBuf = 2 + curve->size % 2;
251 for(i = 0; i < curve->size; i++) {
256 offset += 4 * (i + (curve->size % 2));
263 for(i = 0; i < curve->size; i++) {
264 REG(
PKA_RAM_BASE + offset + 4 * i) = (uint32_t)curve->prime[i];
268 offset += 4 * (i + extraBuf);
271 for(i = 0; i < curve->size; i++) {
272 REG(
PKA_RAM_BASE + offset + 4 * i) = (uint32_t)curve->a[i];
276 offset += 4 * (i + extraBuf);
279 for(i = 0; i < curve->size; i++) {
280 REG(
PKA_RAM_BASE + offset + 4 * i) = (uint32_t)curve->b[i];
284 offset += 4 * (i + extraBuf);
291 for(i = 0; i < curve->size; i++) {
292 REG(
PKA_RAM_BASE + offset + 4 * i) = (uint32_t)curve->x[i];
296 offset += 4 * (i + extraBuf);
299 for(i = 0; i < curve->size; i++) {
300 REG(
PKA_RAM_BASE + offset + 4 * i) = (uint32_t)curve->y[i];
304 offset += 4 * (i + extraBuf);
320 if(process != NULL) {
331 uint32_t result_vector)
340 ASSERT(NULL != ec_point);
341 ASSERT(NULL != ec_point->x);
342 ASSERT(NULL != ec_point->y);
368 addr = result_vector;
372 for(i = 0; i < len; i++) {
373 ec_point->x[i] = REG(addr + 4 * i);
376 addr += 4 * (i + 2 + len % 2);
380 for(i = 0; i < len; i++) {
381 ec_point->y[i] = REG(addr + 4 * i);
392 ecc_curve_info_t *curve, uint32_t *result_vector,
393 struct process *process)
401 ASSERT(NULL != ec_point1);
402 ASSERT(NULL != ec_point1->x);
403 ASSERT(NULL != ec_point1->y);
404 ASSERT(NULL != ec_point2);
405 ASSERT(NULL != ec_point2->x);
406 ASSERT(NULL != ec_point2->y);
407 ASSERT(NULL != curve);
408 ASSERT(NULL != result_vector);
418 extraBuf = 2 + curve->size % 2;
425 for(i = 0; i < curve->size; i++) {
430 offset += 4 * (i + extraBuf);
433 for(i = 0; i < curve->size; i++) {
438 offset += 4 * (i + extraBuf);
445 for(i = 0; i < curve->size; i++) {
446 REG(
PKA_RAM_BASE + offset + 4 * i) = (uint32_t)curve->prime[i];
450 offset += 4 * (i + extraBuf);
453 for(i = 0; i < curve->size; i++) {
454 REG(
PKA_RAM_BASE + offset + 4 * i) = (uint32_t)curve->a[i];
458 offset += 4 * (i + extraBuf);
465 for(i = 0; i < curve->size; i++) {
470 offset += 4 * (i + extraBuf);
473 for(i = 0; i < curve->size; i++) {
478 offset += 4 * (i + extraBuf);
493 if(process != NULL) {
511 ASSERT(NULL != ec_point);
512 ASSERT(NULL != ec_point->x);
513 ASSERT(NULL != ec_point->y);
538 addr = result_vector;
542 for(i = 0; i < len; i++) {
543 ec_point->x[i] = REG(addr + 4 * i);
546 addr += 4 * (i + 2 + len % 2);
550 for(i = 0; i < len; i++) {
551 ec_point->y[i] = REG(addr + 4 * i);
#define PKA_STATUS_SUCCESS
Success.
Header file for the ARM Nested Vectored Interrupt Controller.
uint8_t ecc_mul_get_result(ec_point_t *ec_point, uint32_t result_vector)
Gets the result of ECC Multiplication.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
uint8_t ecc_mul_gen_pt_start(uint32_t *scalar, ecc_curve_info_t *curve, uint32_t *result_vector, struct process *process)
Starts the ECC Multiplication with Generator point.
#define PKA_FUNCTION
PKA function This register contains the control bits to start basic PKCP as well as complex sequencer...
#define PKA_STATUS_FAILURE
Failure.
Header file with register manipulation macro definitions.
#define PKA_RAM_BASE
PKA Memory Address.
uint8_t ecc_add_get_result(ec_point_t *ec_point, uint32_t result_vector)
Gets the result of the ECC Addition.
#define PKA_CPTR
PKA vector C address During execution of basic PKCP operations, this register is double buffered and ...
uint8_t ecc_mul_start(uint32_t *scalar, ec_point_t *ec_point, ecc_curve_info_t *curve, uint32_t *result_vector, struct process *process)
Starts ECC Multiplication.
uint8_t ecc_mul_gen_pt_get_result(ec_point_t *ec_point, uint32_t result_vector)
Gets the result of ECC Multiplication with Generator point.
#define PKA_STATUS_RESULT_0
Result is all zeros.
#define PKA_MSW_MSW_ADDRESS_M
Address of the most-significant nonzero 32-bit word of the result vector in PKA RAM.
Header file for the cc2538 ECC driver.
#define PKA_ALENGTH
PKA vector A length During execution of basic PKCP operations, this register is double buffered and c...
#define PKA_SHIFT
PKA bit shift value For basic PKCP operations, modifying the contents of this register is made imposs...
uint8_t ecc_add_start(ec_point_t *ec_point1, ec_point_t *ec_point2, ecc_curve_info_t *curve, uint32_t *result_vector, struct process *process)
Starts the ECC Addition.
#define PKA_STATUS_OPERATION_INPRG
PKA operation is in progress.
#define PKA_BLENGTH
PKA vector B length During execution of basic PKCP operations, this register is double buffered and c...
#define PKA_APTR
PKA vector A address During execution of basic PKCP operations, this register is double buffered and ...
#define PKA_MAX_CURVE_SIZE
Define for the maximum curve size supported by the PKA module in 32 bit word.
#define PKA_FUNCTION_RUN
The host sets this bit to instruct the PKA module to begin processing the basic PKCP or complex seque...
#define PKA_MSW
PKA most-significant-word of result vector This register indicates the (word) address in the PKA RAM ...
#define PKA_DPTR
PKA vector D address During execution of basic PKCP operations, this register is double buffered and ...
void pka_register_process_notification(struct process *p)
Registers a process to be notified of the completion of a PKA operation.
#define PKA_RAM_SIZE
PKA Memory Size.
#define PKA_MSW_RESULT_IS_ZERO
The result vector is all zeroes, ignore the address returned in bits [10:0].
#define PKA_BPTR
PKA vector B address During execution of basic PKCP operations, this register is double buffered and ...