CC26xx Driver Library
[pka] Public Key Accelerator

Data Structures

union  PKA_EccParam256
 
struct  PKA_EccPoint_
 

Functions

uint32_t PKAGetOpsStatus (void)
 Gets the PKA operation status. More...
 
uint32_t PKABigNumModStart (const uint8_t *bigNum, uint32_t bigNumLength, const uint8_t *modulus, uint32_t modulusLength, uint32_t *resultPKAMemAddr)
 Starts a big number modulus operation. More...
 
uint32_t PKABigNumModGetResult (uint8_t *resultBuf, uint32_t length, uint32_t resultPKAMemAddr)
 Gets the result of the big number modulus operation. More...
 
uint32_t PKABigNumCmpStart (const uint8_t *bigNum1, const uint8_t *bigNum2, uint32_t length)
 Starts the comparison of two big numbers. More...
 
uint32_t PKABigNumCmpGetResult (void)
 Gets the result of the comparison operation of two big numbers. More...
 
uint32_t PKABigNumInvModStart (const uint8_t *bigNum, uint32_t bigNumLength, const uint8_t *modulus, uint32_t modulusLength, uint32_t *resultPKAMemAddr)
 Starts a big number inverse modulo operation. More...
 
uint32_t PKABigNumInvModGetResult (uint8_t *resultBuf, uint32_t length, uint32_t resultPKAMemAddr)
 Gets the result of the big number inverse modulo operation. More...
 
uint32_t PKABigNumMultiplyStart (const uint8_t *multiplicand, uint32_t multiplicandLength, const uint8_t *multiplier, uint32_t multiplierLength, uint32_t *resultPKAMemAddr)
 Starts the multiplication of two big numbers. More...
 
uint32_t PKABigNumMultGetResult (uint8_t *resultBuf, uint32_t *resultLength, uint32_t resultPKAMemAddr)
 Gets the result of the big number multiplication. More...
 
uint32_t PKABigNumAddStart (const uint8_t *bigNum1, uint32_t bigNum1Length, const uint8_t *bigNum2, uint32_t bigNum2Length, uint32_t *resultPKAMemAddr)
 Starts the addition of two big numbers. More...
 
uint32_t PKABigNumAddGetResult (uint8_t *resultBuf, uint32_t *resultLength, uint32_t resultPKAMemAddr)
 Gets the result of the addition operation on two big numbers. More...
 
uint32_t PKABigNumSubStart (const uint8_t *minuend, uint32_t minuendLength, const uint8_t *subtrahend, uint32_t subtrahendLength, uint32_t *resultPKAMemAddr)
 Starts the subtration of one big number from another. More...
 
uint32_t PKABigNumSubGetResult (uint8_t *resultBuf, uint32_t *resultLength, uint32_t resultPKAMemAddr)
 Gets the result of the subtration operation on two big numbers. More...
 
uint32_t PKAEccMultiplyStart (const uint8_t *scalar, const uint8_t *curvePointX, const uint8_t *curvePointY, const uint8_t *prime, const uint8_t *a, const uint8_t *b, uint32_t length, uint32_t *resultPKAMemAddr)
 Starts ECC multiplication. More...
 
uint32_t PKAEccMultiplyGetResult (uint8_t *curvePointX, uint8_t *curvePointY, uint32_t resultPKAMemAddr, uint32_t length)
 Gets the result of ECC multiplication. More...
 
uint32_t PKAEccAddStart (const uint8_t *curvePoint1X, const uint8_t *curvePoint1Y, const uint8_t *curvePoint2X, const uint8_t *curvePoint2Y, const uint8_t *prime, const uint8_t *a, uint32_t length, uint32_t *resultPKAMemAddr)
 Starts the ECC addition. More...
 
uint32_t PKAEccAddGetResult (uint8_t *curvePointX, uint8_t *curvePointY, uint32_t resultPKAMemAddr, uint32_t length)
 Gets the result of the ECC addition. More...
 

Variables

const PKA_EccPoint NISTP256_generator
 X coordinate of the generator point of the NISTP256 curve. More...
 
const PKA_EccParam256 NISTP256_prime
 Prime of the NISTP256 curve. More...
 
const PKA_EccParam256 NISTP256_a
 a constant of the NISTP256 curve when expressed in short Weierstrass form (y^3 = x^2 + a*x + b). More...
 
const PKA_EccParam256 NISTP256_b
 b constant of the NISTP256 curve when expressed in short Weierstrass form (y^3 = x^2 + a*x + b). More...
 
const PKA_EccParam256 NISTP256_order
 Order of the NISTP256 curve. More...
 

Detailed Description

Introduction

The PKA (Public Key Accelerator) API provides access to the Large Number Engine (LNME). The LNME allows for efficient math operations on numbers larger than those that fit within the ALU of the system CPU. It is significantly faster to perform these operations using the LNME than implementing the same functionality in software using regular word-wise math operations. While the LNME runs in the background, the system CPU may perform other operations or be turned off.

The LNME supports both primitive math operations and serialized primitive operations (sequencer operations).

These primitives and sequencer operations can be used to implement various public key encryption schemes. It is possible to implement the following schemes using the operations mentioned above:

The DriverLib PKA functions copy the relevant parameters into the dedicated PKA RAM. The LNME requires these parameters be present and correctly formatted in the PKA RAM and not system RAM. They are copied word-wise as the PKA RAM does not support byte-wise access. The CPU handles the alignment differences during the memory copy operation. Forcing buffer alignment in system RAM results in a significant speedup of the copy operation compared to unaligned buffers.

When the operation completes, the result is copied back into a buffer in system RAM specified by the application. The PKA RAM is then cleared to prevent sensitive keying material from remaining in PKA RAM.

Function Documentation

uint32_t PKABigNumAddGetResult ( uint8_t *  resultBuf,
uint32_t *  resultLength,
uint32_t  resultPKAMemAddr 
)

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

Parameters
[out]resultBufis the pointer to buffer where the result needs to be stored.
[in,out]resultLengthis the address of the variable containing the length of the buffer. After the operation the actual length of the resultant is stored at this address.
[in]resultPKAMemAddris the address of the result location which was provided by the start function PKABigNumAddStart().
Returns
Returns a status code.
See also
PKABigNumAddStart()
736 {
737  return PKAGetBigNumResult(resultBuf, resultLength, resultPKAMemAddr);
738 }
static uint32_t PKAGetBigNumResult(uint8_t *resultBuf, uint32_t *resultLength, uint32_t resultPKAMemAddr)
Definition: pka.c:275

Here is the call graph for this function:

uint32_t PKABigNumAddStart ( const uint8_t *  bigNum1,
uint32_t  bigNum1Length,
const uint8_t *  bigNum2,
uint32_t  bigNum2Length,
uint32_t *  resultPKAMemAddr 
)

Starts the addition of two big numbers.

Parameters
[in]bigNum1is the pointer to the buffer containing the first big number.
[in]bigNum1Lengthis the size of the first big number in bytes.
[in]bigNum2is the pointer to the buffer containing the second big number.
[in]bigNum2Lengthis the size of the second big number in bytes.
[out]resultPKAMemAddris the pointer to the result vector location which will be set by this function.
Returns
Returns a status code.
See also
PKABigNumAddGetResult()
654 {
655  uint32_t offset = 0;
656 
657  // Check for arguments.
658  ASSERT(bigNum1);
659  ASSERT(bigNum2);
660  ASSERT(resultPKAMemAddr);
661 
662 
663  // Make sure no operation is in progress.
664  if (HWREG(PKA_BASE + PKA_O_FUNCTION) & PKA_FUNCTION_RUN) {
666  }
667 
668  offset = PKAWritePkaParam(bigNum1, bigNum1Length, offset, PKA_O_APTR);
669 
670  offset = PKAWritePkaParam(bigNum2, bigNum2Length, offset, PKA_O_BPTR);
671 
672  // Copy the result vector address location.
673  *resultPKAMemAddr = PKA_RAM_BASE + offset;
674 
675  // Load C pointer with the result location in PKA RAM.
676  HWREG(PKA_BASE + PKA_O_CPTR) = offset >> 2;
677 
678  // Set the function for the add operation and start the operation.
680 
681  return PKA_STATUS_SUCCESS;
682 }
static uint32_t PKAWritePkaParam(const uint8_t *param, uint32_t paramLength, uint32_t paramOffset, uint32_t ptrRegOffset)
Definition: pka.c:206
#define PKA_STATUS_OPERATION_BUSY
PKA operation is in progress.
Definition: pka.h:121
#define PKA_STATUS_SUCCESS
Success.
Definition: pka.h:113
#define ASSERT(expr)
Definition: debug.h:73

Here is the call graph for this function:

uint32_t PKABigNumCmpGetResult ( 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 PKABigNumCmpStart().

Returns
Returns a status code.
See also
PKABigNumCmpStart()
527 {
528  uint32_t status;
529 
530  // verify that the operation is complete.
531  if (HWREG(PKA_BASE + PKA_O_FUNCTION) & PKA_FUNCTION_RUN) {
533  }
534 
535  // Check the COMPARE register.
536  switch(HWREG(PKA_BASE + PKA_O_COMPARE)) {
538  status = PKA_STATUS_EQUAL;
539  break;
540 
542  status = PKA_STATUS_A_GR_B;
543  break;
544 
546  status = PKA_STATUS_A_LT_B;
547  break;
548 
549  default:
550  status = PKA_STATUS_FAILURE;
551  break;
552  }
553 
554  return status;
555 }
#define PKA_STATUS_FAILURE
Failure.
Definition: pka.h:114
#define PKA_STATUS_EQUAL
Big number compare return status if the first big number is equal to the second.
Definition: pka.h:120
#define PKA_STATUS_OPERATION_BUSY
PKA operation is in progress.
Definition: pka.h:121
#define PKA_STATUS_A_GR_B
Big number compare return status if the first big number is greater than the second.
Definition: pka.h:118
#define PKA_STATUS_A_LT_B
Big number compare return status if the first big number is less than the second. ...
Definition: pka.h:119
uint32_t PKABigNumCmpStart ( const uint8_t *  bigNum1,
const uint8_t *  bigNum2,
uint32_t  length 
)

Starts the comparison of two big numbers.

This function starts the comparison of two big numbers pointed by bigNum1 and bigNum2.

Note
bigNum1 and bigNum2 must have same size.
Parameters
[in]bigNum1is the pointer to the first big number.
[in]bigNum2is the pointer to the second big number.
[in]lengthis the size of the big numbers in bytes.
Returns
Returns a status code.
See also
PKABigNumCmpGetResult()
498 {
499  uint32_t offset = 0;
500 
501  // Check the arguments.
502  ASSERT(bigNum1);
503  ASSERT(bigNum2);
504 
505  // Make sure no operation is in progress.
506  if (HWREG(PKA_BASE + PKA_O_FUNCTION) & PKA_FUNCTION_RUN) {
508  }
509 
510  offset = PKAWritePkaParam(bigNum1, length, offset, PKA_O_APTR);
511 
512  offset = PKAWritePkaParam(bigNum2, length, offset, PKA_O_BPTR);
513 
514  // Set the PKA Function register for the Compare operation
515  // and start the operation.
517 
518  return PKA_STATUS_SUCCESS;
519 }
static uint32_t PKAWritePkaParam(const uint8_t *param, uint32_t paramLength, uint32_t paramOffset, uint32_t ptrRegOffset)
Definition: pka.c:206
#define PKA_STATUS_OPERATION_BUSY
PKA operation is in progress.
Definition: pka.h:121
#define PKA_STATUS_SUCCESS
Success.
Definition: pka.h:113
#define ASSERT(expr)
Definition: debug.h:73

Here is the call graph for this function:

uint32_t PKABigNumInvModGetResult ( uint8_t *  resultBuf,
uint32_t  length,
uint32_t  resultPKAMemAddr 
)

Gets the result of the big number inverse modulo operation.

This function gets the result of the big number inverse modulo operation previously started using the function PKABigNumInvModStart().

Parameters
[out]resultBufis the pointer to buffer where the result needs to be stored.
[in]lengthis the size of the provided buffer in bytes.
[in]resultPKAMemAddris the address of the result location which was provided by the start function PKABigNumInvModStart().
Returns
Returns a status code.
See also
PKABigNumInvModStart()
598 {
599  return PKAGetBigNumResult(resultBuf, &length, resultPKAMemAddr);
600 }
static uint32_t PKAGetBigNumResult(uint8_t *resultBuf, uint32_t *resultLength, uint32_t resultPKAMemAddr)
Definition: pka.c:275

Here is the call graph for this function:

uint32_t PKABigNumInvModStart ( const uint8_t *  bigNum,
uint32_t  bigNumLength,
const uint8_t *  modulus,
uint32_t  modulusLength,
uint32_t *  resultPKAMemAddr 
)

Starts a big number inverse modulo operation.

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

Parameters
[in]bigNumis the pointer to the buffer containing the big number (dividend).
[in]bigNumLengthis the size of the bigNum in bytes.
[in]modulusis the pointer to the buffer containing the divisor.
[in]modulusLengthis the size of the divisor in bytes.
[out]resultPKAMemAddris the pointer to the result vector location which will be set by this function.
Returns
Returns a status code.
See also
PKABigNumInvModGetResult()
563 {
564  uint32_t offset = 0;
565 
566  // Check the arguments.
567  ASSERT(bigNum);
568  ASSERT(modulus);
569  ASSERT(resultPKAMemAddr);
570 
571  // Make sure no operation is in progress.
572  if (HWREG(PKA_BASE + PKA_O_FUNCTION) & PKA_FUNCTION_RUN) {
574  }
575 
576  offset = PKAWritePkaParam(bigNum, bigNumLength, offset, PKA_O_APTR);
577 
578  offset = PKAWritePkaParam(modulus, modulusLength, offset, PKA_O_BPTR);
579 
580  // Copy the result vector address location.
581  *resultPKAMemAddr = PKA_RAM_BASE + offset;
582 
583  // Load D pointer with the result location in PKA RAM.
584  HWREG(PKA_BASE + PKA_O_DPTR) = offset >> 2;
585 
586  // set the PKA function to InvMod operation and the start the operation.
587  HWREG(PKA_BASE + PKA_O_FUNCTION) = 0x0000F000;
588 
589  return PKA_STATUS_SUCCESS;
590 }
static uint32_t PKAWritePkaParam(const uint8_t *param, uint32_t paramLength, uint32_t paramOffset, uint32_t ptrRegOffset)
Definition: pka.c:206
#define PKA_STATUS_OPERATION_BUSY
PKA operation is in progress.
Definition: pka.h:121
#define PKA_STATUS_SUCCESS
Success.
Definition: pka.h:113
#define ASSERT(expr)
Definition: debug.h:73

Here is the call graph for this function:

uint32_t PKABigNumModGetResult ( uint8_t *  resultBuf,
uint32_t  length,
uint32_t  resultPKAMemAddr 
)

Gets the result of the big number modulus operation.

This function gets the result of the big number modulus operation which was previously started using the function PKABigNumModStart().

Parameters
[out]resultBufis the pointer to buffer where the result needs to be stored.
[in]lengthis the size of the provided buffer in bytes.
[in]resultPKAMemAddris the address of the result location which was provided by the start function PKABigNumModStart().
Returns
Returns a status code.
See also
PKABigNumModStart()
486 {
487  return PKAGetBigNumResultRemainder(resultBuf, &length, resultPKAMemAddr);
488 }
static uint32_t PKAGetBigNumResultRemainder(uint8_t *resultBuf, uint32_t *resultLength, uint32_t resultPKAMemAddr)
Definition: pka.c:326

Here is the call graph for this function:

uint32_t PKABigNumModStart ( const uint8_t *  bigNum,
uint32_t  bigNumLength,
const uint8_t *  modulus,
uint32_t  modulusLength,
uint32_t *  resultPKAMemAddr 
)

Starts a big number modulus operation.

This function starts the modulo operation on the big number bigNum using the divisor modulus. The PKA RAM location where the result will be available is stored in resultPKAMemAddr.

Parameters
[in]bigNumis the pointer to the big number on which modulo operation needs to be carried out.
[in]bigNumLengthis the size of the big number bigNum in bytes.
[in]modulusis the pointer to the divisor.
[in]modulusLengthis the size of the divisor modulus in bytes.
[out]resultPKAMemAddris the pointer to the result vector location which will be set by this function.
Returns
Returns a status code.
See also
PKABigNumModGetResult()
451 {
452  uint32_t offset = 0;
453 
454  // Check the arguments.
455  ASSERT(bigNum);
456  ASSERT(modulus);
457  ASSERT(resultPKAMemAddr);
458 
459  // Make sure no operation is in progress.
460  if (HWREG(PKA_BASE + PKA_O_FUNCTION) & PKA_FUNCTION_RUN) {
462  }
463 
464  offset = PKAWritePkaParam(bigNum, bigNumLength, offset, PKA_O_APTR);
465 
466  offset = PKAWritePkaParamExtraOffset(modulus, modulusLength, offset, PKA_O_BPTR);
467 
468  // Copy the result vector address location.
469  *resultPKAMemAddr = PKA_RAM_BASE + offset;
470 
471  // Load C pointer with the result location in PKA RAM
472  HWREG(PKA_BASE + PKA_O_CPTR) = offset >> 2;
473 
474  // Start the PKCP modulo operation by setting the PKA Function register.
476 
477  return PKA_STATUS_SUCCESS;
478 }
static uint32_t PKAWritePkaParam(const uint8_t *param, uint32_t paramLength, uint32_t paramOffset, uint32_t ptrRegOffset)
Definition: pka.c:206
#define PKA_STATUS_OPERATION_BUSY
PKA operation is in progress.
Definition: pka.h:121
#define PKA_STATUS_SUCCESS
Success.
Definition: pka.h:113
static uint32_t PKAWritePkaParamExtraOffset(const uint8_t *param, uint32_t paramLength, uint32_t paramOffset, uint32_t ptrRegOffset)
Definition: pka.c:264
#define ASSERT(expr)
Definition: debug.h:73

Here is the call graph for this function:

uint32_t PKABigNumMultGetResult ( uint8_t *  resultBuf,
uint32_t *  resultLength,
uint32_t  resultPKAMemAddr 
)

Gets the result of the big number multiplication.

This function gets the result of the multiplication of two big numbers operation previously started using the function PKABigNumMultiplyStart().

Parameters
[out]resultBufis the pointer to buffer where the result needs to be stored.
[in,out]resultLengthis the address of the variable containing the length of the buffer in bytes. After the operation, the actual length of the resultant is stored at this address.
[in]resultPKAMemAddris the address of the result location which was provided by the start function PKABigNumMultiplyStart().
Returns
Returns a status code.
See also
PKABigNumMultiplyStart()
644 {
645  return PKAGetBigNumResult(resultBuf, resultLength, resultPKAMemAddr);
646 }
static uint32_t PKAGetBigNumResult(uint8_t *resultBuf, uint32_t *resultLength, uint32_t resultPKAMemAddr)
Definition: pka.c:275

Here is the call graph for this function:

uint32_t PKABigNumMultiplyStart ( const uint8_t *  multiplicand,
uint32_t  multiplicandLength,
const uint8_t *  multiplier,
uint32_t  multiplierLength,
uint32_t *  resultPKAMemAddr 
)

Starts the multiplication of two big numbers.

Parameters
[in]multiplicandis the pointer to the buffer containing the big number multiplicand.
[in]multiplicandLengthis the size of the multiplicand in bytes.
[in]multiplieris the pointer to the buffer containing the big number multiplier.
[in]multiplierLengthis the size of the multiplier in bytes.
[out]resultPKAMemAddris the pointer to the result vector location which will be set by this function.
Returns
Returns a status code.
See also
PKABigNumMultGetResult()
608 {
609  uint32_t offset = 0;
610 
611  // Check for the arguments.
612  ASSERT(multiplicand);
613  ASSERT(multiplier);
614  ASSERT(resultPKAMemAddr);
615 
616  // Make sure no operation is in progress.
617  if (HWREG(PKA_BASE + PKA_O_FUNCTION) & PKA_FUNCTION_RUN) {
619  }
620 
621  offset = PKAWritePkaParam(multiplicand, multiplicandLength, offset, PKA_O_APTR);
622 
623  offset = PKAWritePkaParam(multiplier, multiplierLength, offset, PKA_O_BPTR);
624 
625 
626  // Copy the result vector address location.
627  *resultPKAMemAddr = PKA_RAM_BASE + offset;
628 
629  // Load C pointer with the result location in PKA RAM.
630  HWREG(PKA_BASE + PKA_O_CPTR) = offset >> 2;
631 
632  // Set the PKA function to the multiplication and start it.
634 
635  return PKA_STATUS_SUCCESS;
636 }
static uint32_t PKAWritePkaParam(const uint8_t *param, uint32_t paramLength, uint32_t paramOffset, uint32_t ptrRegOffset)
Definition: pka.c:206
#define PKA_STATUS_OPERATION_BUSY
PKA operation is in progress.
Definition: pka.h:121
#define PKA_STATUS_SUCCESS
Success.
Definition: pka.h:113
#define ASSERT(expr)
Definition: debug.h:73

Here is the call graph for this function:

uint32_t PKABigNumSubGetResult ( uint8_t *  resultBuf,
uint32_t *  resultLength,
uint32_t  resultPKAMemAddr 
)

Gets the result of the subtration operation on two big numbers.

Parameters
[out]resultBufis the pointer to buffer where the result needs to be stored.
[in,out]resultLengthis the address of the variable containing the length of the buffer. After the operation the actual length of the resultant is stored at this address.
[in]resultPKAMemAddris the address of the result location which was provided by the start function PKABigNumAddStart().
Returns
Returns a status code.
See also
PKABigNumSubStart()
690 {
691  return PKAGetBigNumResult(resultBuf, resultLength, resultPKAMemAddr);
692 }
static uint32_t PKAGetBigNumResult(uint8_t *resultBuf, uint32_t *resultLength, uint32_t resultPKAMemAddr)
Definition: pka.c:275

Here is the call graph for this function:

uint32_t PKABigNumSubStart ( const uint8_t *  minuend,
uint32_t  minuendLength,
const uint8_t *  subtrahend,
uint32_t  subtrahendLength,
uint32_t *  resultPKAMemAddr 
)

Starts the subtration of one big number from another.

Parameters
[in]minuendis the pointer to the buffer containing the big number to be subtracted from.
[in]minuendLengthis the size of the minuend in bytes.
[in]subtrahendis the pointer to the buffer containing the big number to subtract from the minuend.
[in]subtrahendLengthis the size of the subtrahend in bytes.
[out]resultPKAMemAddris the pointer to the result vector location which will be set by this function.
Returns
Returns a status code.
See also
PKABigNumSubGetResult()
700 {
701  uint32_t offset = 0;
702 
703  // Check for arguments.
704  ASSERT(minuend);
705  ASSERT(subtrahend);
706  ASSERT(resultPKAMemAddr);
707 
708 
709  // Make sure no operation is in progress.
710  if (HWREG(PKA_BASE + PKA_O_FUNCTION) & PKA_FUNCTION_RUN) {
712  }
713 
714  offset = PKAWritePkaParam(minuend, minuendLength, offset, PKA_O_APTR);
715 
716  offset = PKAWritePkaParam(subtrahend, subtrahendLength, offset, PKA_O_BPTR);
717 
718  // Copy the result vector address location.
719  *resultPKAMemAddr = PKA_RAM_BASE + offset;
720 
721  // Load C pointer with the result location in PKA RAM.
722  HWREG(PKA_BASE + PKA_O_CPTR) = offset >> 2;
723 
724  // Set the function for the add operation and start the operation.
726 
727  return PKA_STATUS_SUCCESS;
728 }
static uint32_t PKAWritePkaParam(const uint8_t *param, uint32_t paramLength, uint32_t paramOffset, uint32_t ptrRegOffset)
Definition: pka.c:206
#define PKA_STATUS_OPERATION_BUSY
PKA operation is in progress.
Definition: pka.h:121
#define PKA_STATUS_SUCCESS
Success.
Definition: pka.h:113
#define ASSERT(expr)
Definition: debug.h:73

Here is the call graph for this function:

uint32_t PKAEccAddGetResult ( uint8_t *  curvePointX,
uint8_t *  curvePointY,
uint32_t  resultPKAMemAddr,
uint32_t  length 
)

Gets the result of the ECC addition.

This function gets the result of ECC point addition operation on the on the two given EC points, previously started using the function PKAEccAddStart().

Parameters
[out]curvePointXis the pointer to the structure where the X coordinate of the resultant EC point will be stored.
[out]curvePointYis the pointer to the structure where the Y coordinate of the resultant EC point will be stored.
[in]resultPKAMemAddris the address of the result location which was provided by the start function PKAEccAddGetResult().
[in]lengthis the length of the curve parameters in bytes.
Returns
Returns a status code.
See also
PKAEccAddStart()
846 {
847  return PKAGetECCResult(curvePointX, curvePointY, resultPKAMemAddr, length);
848 }
static uint32_t PKAGetECCResult(uint8_t *curvePointX, uint8_t *curvePointY, uint32_t resultPKAMemAddr, uint32_t length)
Definition: pka.c:379

Here is the call graph for this function:

uint32_t PKAEccAddStart ( const uint8_t *  curvePoint1X,
const uint8_t *  curvePoint1Y,
const uint8_t *  curvePoint2X,
const uint8_t *  curvePoint2Y,
const uint8_t *  prime,
const uint8_t *  a,
uint32_t  length,
uint32_t *  resultPKAMemAddr 
)

Starts the ECC addition.

Parameters
[in]curvePoint1Xis the pointer to the buffer containing the X coordinate of the first elliptic curve point to be added. The point must be on the given curve.
[in]curvePoint1Yis the pointer to the buffer containing the Y coordinate of the first elliptic curve point to be added. The point must be on the given curve.
[in]curvePoint2Xis the pointer to the buffer containing the X coordinate of the second elliptic curve point to be added. The point must be on the given curve.
[in]curvePoint2Yis the pointer to the buffer containing the Y coordinate of the second elliptic curve point to be added. The point must be on the given curve.
[in]primeis the prime of the curve.
[in]ais the a constant of the curve when the curve equation is expressed in short Weierstrass form (y^3 = x^2 + a*x + b).
[in]lengthis the length of the curve parameters in bytes.
[out]resultPKAMemAddris the pointer to the result vector location which will be set by this function.
Returns
Returns a status code.
See also
PKAEccAddGetResult()
801 {
802  uint32_t offset = 0;
803 
804  // Check for the arguments.
805  ASSERT(curvePoint1X);
806  ASSERT(curvePoint1Y);
807  ASSERT(curvePoint2X);
808  ASSERT(curvePoint2Y);
809  ASSERT(prime);
810  ASSERT(a);
811  ASSERT(resultPKAMemAddr);
812 
813  // Make sure no operation is in progress.
814  if (HWREG(PKA_BASE + PKA_O_FUNCTION) & PKA_FUNCTION_RUN) {
816  }
817 
818  offset = PKAWritePkaParamExtraOffset(curvePoint1X, length, offset, PKA_O_APTR);
819  offset = PKAWritePkaParamExtraOffset(curvePoint1Y, length, offset, PKA_NO_POINTER_REG);
820 
821 
822  offset = PKAWritePkaParamExtraOffset(prime, length, offset, PKA_O_BPTR);
823  offset = PKAWritePkaParamExtraOffset(a, length, offset, PKA_NO_POINTER_REG);
824 
825  offset = PKAWritePkaParamExtraOffset(curvePoint2X, length, offset, PKA_O_CPTR);
826  offset = PKAWritePkaParamExtraOffset(curvePoint2Y, length, offset, PKA_NO_POINTER_REG);
827 
828  // Copy the result vector location.
829  *resultPKAMemAddr = PKA_RAM_BASE + offset;
830 
831  // Load D pointer with the result location in PKA RAM.
832  HWREG(PKA_BASE + PKA_O_DPTR) = offset >> 2;
833 
834  // Set the PKA Function to ECC-ADD and start the operation.
836 
837  return PKA_STATUS_SUCCESS;
838 }
#define PKA_STATUS_OPERATION_BUSY
PKA operation is in progress.
Definition: pka.h:121
#define PKA_STATUS_SUCCESS
Success.
Definition: pka.h:113
static uint32_t PKAWritePkaParamExtraOffset(const uint8_t *param, uint32_t paramLength, uint32_t paramOffset, uint32_t ptrRegOffset)
Definition: pka.c:264
#define ASSERT(expr)
Definition: debug.h:73
#define PKA_NO_POINTER_REG
Definition: pka.c:153

Here is the call graph for this function:

uint32_t PKAEccMultiplyGetResult ( uint8_t *  curvePointX,
uint8_t *  curvePointY,
uint32_t  resultPKAMemAddr,
uint32_t  length 
)

Gets the result of ECC multiplication.

This function gets the result of ECC point multiplication operation on the EC point and the scalar value, previously started using the function PKAEccMultiplyStart().

Parameters
[out]curvePointXis the pointer to the structure where the X coordinate of the resultant EC point will be stored.
[out]curvePointYis the pointer to the structure where the Y coordinate of the resultant EC point will be stored.
[in]resultPKAMemAddris the address of the result location which was provided by the start function PKAEccMultiplyStart().
[in]lengthis the length of the curve parameters in bytes.
Returns
Returns a status code.
See also
PKAEccMultiplyStart()
791 {
792  return PKAGetECCResult(curvePointX, curvePointY, resultPKAMemAddr, length);
793 }
static uint32_t PKAGetECCResult(uint8_t *curvePointX, uint8_t *curvePointY, uint32_t resultPKAMemAddr, uint32_t length)
Definition: pka.c:379

Here is the call graph for this function:

uint32_t PKAEccMultiplyStart ( const uint8_t *  scalar,
const uint8_t *  curvePointX,
const uint8_t *  curvePointY,
const uint8_t *  prime,
const uint8_t *  a,
const uint8_t *  b,
uint32_t  length,
uint32_t *  resultPKAMemAddr 
)

Starts ECC multiplication.

Parameters
[in]scalaris pointer to the buffer containing the scalar value to be multiplied.
[in]curvePointXis the pointer to the buffer containing the X coordinate of the elliptic curve point to be multiplied. The point must be on the given curve.
[in]curvePointYis the pointer to the buffer containing the Y coordinate of the elliptic curve point to be multiplied. The point must be on the given curve.
[in]primeis the prime of the curve.
[in]ais the a constant of the curve when the curve equation is expressed in short Weierstrass form (y^3 = x^2 + a*x + b).
[in]bis the b constant of the curve when the curve equation is expressed in short Weierstrass form (y^3 = x^2 + a*x + b).
[in]lengthis the length of the curve parameters in bytes.
[out]resultPKAMemAddris the pointer to the result vector location which will be set by this function.
Returns
Returns a status code.
See also
PKAEccMultiplyGetResult()
747 {
748  uint32_t offset = 0;
749 
750  // Check for the arguments.
751  ASSERT(scalar);
752  ASSERT(curvePoint);
753  ASSERT(curvePointX);
754  ASSERT(curvePointY);
755  ASSERT(curve);
756  ASSERT(length <= PKA_MAX_CURVE_SIZE_32_BIT_WORD * sizeof(uint32_t));
757  ASSERT(resultPKAMemAddr);
758 
759  // Make sure no PKA operation is in progress.
760  if (HWREG(PKA_BASE + PKA_O_FUNCTION) & PKA_FUNCTION_RUN) {
762  }
763 
764  offset = PKAWritePkaParam(scalar, length, offset, PKA_O_APTR);
765 
766  offset = PKAWritePkaParamExtraOffset(prime, length, offset, PKA_O_BPTR);
767  offset = PKAWritePkaParamExtraOffset(a, length, offset, PKA_NO_POINTER_REG);
768  offset = PKAWritePkaParamExtraOffset(b, length, offset, PKA_NO_POINTER_REG);
769 
770  offset = PKAWritePkaParamExtraOffset(curvePointX, length, offset, PKA_O_CPTR);
771  offset = PKAWritePkaParamExtraOffset(curvePointY, length, offset, PKA_NO_POINTER_REG);
772 
773  // Update the result location.
774  *resultPKAMemAddr = PKA_RAM_BASE + offset;
775 
776  // Load D pointer with the result location in PKA RAM.
777  HWREG(PKA_BASE + PKA_O_DPTR) = offset >> 2;
778 
779  // Set the PKA function to ECC-MULT and start the operation.
781 
782  return PKA_STATUS_SUCCESS;
783 }
static uint32_t PKAWritePkaParam(const uint8_t *param, uint32_t paramLength, uint32_t paramOffset, uint32_t ptrRegOffset)
Definition: pka.c:206
#define PKA_STATUS_OPERATION_BUSY
PKA operation is in progress.
Definition: pka.h:121
#define PKA_STATUS_SUCCESS
Success.
Definition: pka.h:113
static uint32_t PKAWritePkaParamExtraOffset(const uint8_t *param, uint32_t paramLength, uint32_t paramOffset, uint32_t ptrRegOffset)
Definition: pka.c:264
#define ASSERT(expr)
Definition: debug.h:73
#define PKA_NO_POINTER_REG
Definition: pka.c:153
#define PKA_MAX_CURVE_SIZE_32_BIT_WORD
Definition: pka.c:137

Here is the call graph for this function:

uint32_t PKAGetOpsStatus ( void  )

Gets the PKA operation status.

This function gets information on whether any PKA operation is in progress or not. This function allows to check the PKA operation status before starting any new PKA operation.

Returns
Returns a status code.
436 {
437  if (HWREG(PKA_BASE + PKA_O_FUNCTION) & PKA_FUNCTION_RUN_M) {
439  }
440  else {
442  }
443 }
#define PKA_STATUS_OPERATION_BUSY
PKA operation is in progress.
Definition: pka.h:121
#define PKA_STATUS_OPERATION_RDY
No PKA operation is in progress.
Definition: pka.h:122

Macro Definition Documentation

#define PKA_STATUS_A_GR_B   5

Big number compare return status if the first big number is greater than the second.

Referenced by PKABigNumCmpGetResult().

#define PKA_STATUS_A_LT_B   6

Big number compare return status if the first big number is less than the second.

Referenced by PKABigNumCmpGetResult().

#define PKA_STATUS_BUF_UNDERFLOW   3

Buffer underflow.

Referenced by PKAGetBigNumResult(), and PKAGetBigNumResultRemainder().

#define PKA_STATUS_EQUAL   7

Big number compare return status if the first big number is equal to the second.

Referenced by PKABigNumCmpGetResult().

#define PKA_STATUS_FAILURE   1

Failure.

Referenced by PKABigNumCmpGetResult(), and PKAGetECCResult().

#define PKA_STATUS_INVALID_PARAM   2

Invalid parameter.

#define PKA_STATUS_OPERATION_RDY   9

No PKA operation is in progress.

Referenced by PKAGetOpsStatus().

#define PKA_STATUS_RESULT_0   4

Result is all zeros.

Referenced by PKAGetBigNumResult(), PKAGetBigNumResultRemainder(), and PKAGetECCResult().

Variable Documentation

const PKA_EccParam256 NISTP256_a

a constant of the NISTP256 curve when expressed in short Weierstrass form (y^3 = x^2 + a*x + b).

const PKA_EccParam256 NISTP256_b

b constant of the NISTP256 curve when expressed in short Weierstrass form (y^3 = x^2 + a*x + b).

const PKA_EccPoint NISTP256_generator

X coordinate of the generator point of the NISTP256 curve.

const PKA_EccParam256 NISTP256_order

Order of the NISTP256 curve.

const PKA_EccParam256 NISTP256_prime

Prime of the NISTP256 curve.