13. Public key accelerator (PKA)

13.1 Introduction

The public key accelerator (PKA) is intended for the computation of cryptographic public key primitives, specifically those related to RSA, Diffie-Hellmann or ECC (Elliptic Curve Cryptography) over GF(p) (Galois fields). To achieve high performance at a reasonable cost, these operations are executed in the Montgomery domain. All needed computations are performed within the accelerator, so no further hardware/software elaboration is needed to process the inputs or the outputs.

13.2 PKA main features

13.3 PKA functional description

Figure 23 shows the block diagram of the public key accelerator.

Figure 23. Block diagram

Block diagram of the PKA showing its internal components and external interfaces.

The block diagram illustrates the internal architecture of the PKA. A 32-bit AHB bus connects to an AHB interface. The AHB interface is linked to a set of Banked Registers (main) containing PKA_CR, PKA_SR, and PKA_CLRFR. It also connects to a 32-bit access bus, which in turn connects to the PKA core and a 596x64-bit PKA RAM. The PKA core is 64-bit wide. Control Logic and an IRQ interface are also present, with the IRQ interface receiving pka_it and sending pka_hclk. The entire assembly is enclosed in a box labeled PKA.

Block diagram of the PKA showing its internal components and external interfaces.

PKA can be used for accelerating Rivest, Shamir and Adleman (RSA), Diffie-Hellman (DH) and Elliptic Curve Cryptography (ECC) operations over a GF(p) field for operand sizes up to 4160 bits for RSA and DH, and up to 640 bits for ECC.

A memory of 38144 bytes (596 words of 64 bits) is used for providing initial data to the PKA, and for holding the results after computation is completed. We call this memory the PKA RAM. Access is done through the PKA AHB interface.

A typical computing sequence by the PKA is composed by the following steps:

  1. 1. Calculation of R2 (mod n) parameter to enter the Montgomery domain.
  2. 2. Conversion of inputs into the Montgomery residue-system representation.
  3. 3. Computation of the requested primitive (modular exponentiation for RSA/DH and point multiplication for ECC).
  4. 4. Conversion out from Montgomery representation.

If several operations are computed sequentially using the same modulus n, the first step can be skipped, since the PKA can store the last computed R2 (mod n). User software is also able to load precomputed values of R2 (mod n) directly into the PKA.

13.3.1 Enabling/disabling PKA

Setting the EN bit (PKA_CR[0]) to '1' enables the PKA peripheral. When EN='0', the PKA peripheral is reset, no operation can be started and the PKA memory cannot be accessed.

Clearing EN bit while a calculation is in progress causes the operation to be aborted. In this case, the content of the PKA RAM (described here below) is not guaranteed.

13.3.2 PKA RAM

The PKA RAM is an internal memory block of 38144 bytes which is organized as 596 words of 64 bits. Each 64-bit word has an address associated with it, from decimal offset 0 to 595.

The offset address to access the first word of the memory block is 0x400. External masters may access this internal memory block from the PKA AHB interface.

Note: Only 32 bits access are supported.

Accesses are allowed only while there is no computation in progress (BUSY = 0). During computation the internal memory block is accessed by the PKA core itself.

13.3.3 Executing a PKA operation

PKA is able to perform 21 types of operations. Each of those PKA operation is executed using the following procedure:

  1. 1. load initial data into the PKA internal RAM.
  2. 2. load the MODE[5:0] field specifying the operation which is to be executed and assert the START bit. Both fields are in the PKA_CR register.
  3. 3. Wait until the PROCENDF bit in the PKA_SR register is set, which indicates that the computation is complete.
  4. 4. Read the result data from the PKA internal RAM, then clear PROCENDF bit by setting PROCENDFC bit in PKA_CLRFR.

The operations and their corresponding input data and results are described in Section 13.4: Operating modes. When selecting an illegal or unknown operation in step 2,

the step 3 (PROCENDF=1) never happens and BUSY is reset automatically after few clock cycles. See Section 13.3.5: PKA error management for details.

13.3.4 Security level

The operations for which a constant time version is available (SECLVL=1) (see Table 34: Operating modes) are executed in constant time. For MODE[5:0] = 000000 or MODE[5:0] = 000010 operations, to make the modular exponentiation operations constant time, the exponent size must be set equal to the size of the modulus (see Section 13.4.2: Compute modular exponentiation). For MODE[5:0] = 100000 or MODE[5:0] = 100010 operations, to make the ECC scalar multiplication operations constant time, the scalar size must be set equal to the size of the order (see Section 13.4.3: Compute the ECC scalar multiplication).

13.3.5 PKA error management

When PKA is used some errors can occur:

For each error flag above PKA generates an interrupt if the application sets the corresponding bit in PKA_CR register (see Section 13.5.1: PKA interrupts for details).

ADDRERRF, RAMERRF, errors are cleared by setting the corresponding bit in PKA_CLRFR, while FAULTFSMF and FAULTERRORCODEF are cleared by resetting EN bit in PKA_CR register.

The PKA can be re-initialized at any moment by resetting the EN bit in the PKA_CR register.

13.4 Operating modes

There are 21 types of operations which the PKA can perform. Each of these operating modes has an associated code which is to be written to the MODE[5:0] field in the PKA_CR register.

Table 34. Operating modes

MODE[5:4]MODE[3:0]Operation performedSECLVL=1
000000Compute Montgomery parameter and modular exponentiationyes
000001Compute Montgomery parameterno
000010Compute modular exponentiation only (Montgomery parameter should be loaded)yes
100000Compute Montgomery parameter and compute ECC kP operationyes
100010Compute the ECC kP primitive only (Montgomery parameter should be loaded)yes
100011ECC complete additionyes
100100ECDSA signatureyes
100101ECDSA signature verificationno
100111ECC double base ladderno
101000Point Checkno
000111RSA CRT exponentiationno
001000Modular inversionno
001001Arithmetic additionno
001010Arithmetic subtractionno
001011Arithmetic multiplicationno
001100Comparisonno
001101Modular reductionno
001110Modular additionyes
001111Modular subtractionyes
010000Montgomery Multiplicationyes

The format of the input data and the results in the PKA RAM are specified for each operating mode in the following sections.

The size of the operands is configurable. For RSA operations (where MODE[5]=0), the maximum “rsa_size” is 4160 bits. For ECC operations (where MODE[5]=1), the maximum “ecc_size” is 640.

In the tables below, the acronyms ROS (RSA Operand Size) and EOS (ECC Operand Size) indicate how many words the given field includes.

\[\text{ROS} = (\text{rsa\_size} / 64) + 1\]

\[\text{EOS} = (\text{ecc\_size} / 64) + 1\]

Fractional results are rounded up to the nearest integer since the PKA's processing is based on 64-bit words. The maximum ROS is 66 (4160-bit max exponent size), while the maximum EOS is 11 (640-bit max operand size).

For example, if you want to compute RSA with an operand of 1024 bits then ROS equals to 17. If you want to compute ECC with an operand of 192 bits, then EOS = 4.

Note: For the input fields whose size is ROS, ROS/2, or EOS, an additional word which is entirely zeros must be written after the last word.

For example, to prepare for the calculation of the Montgomery parameter, ROS words are written for the modulus starting at address 0x1080 until address 0x1080+ROS-1. A word of all zeros must also be written at address 0x0180+ROS before starting the calculation.

13.4.1 Compute Montgomery parameter

During this operation the PKA computes the Montgomery parameter (R²modn).

Table 35. Montgomery parameter computation inputs

Input dataValue (note)Hexadecimal offset in PKAsize (words)
Number of bits of the modulus(In bits, 0 ≤ value < 4160)0x04081
Modulus 'n'(Odd integer only, n < 2⁴¹⁶⁰)0x1080ROS

Table 36. Montgomery parameter computation outputs

Output dataValue (Note)hexadecimal offset in PKAsize (words)
Montgomery parameter: (R²modn)-0x0620ROS

13.4.2 Compute modular exponentiation

During this operation the PKA computes the modular exponentiation (\(m^e \bmod n\)).

Table 37. Modular exponentiation computation inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Number of bits of the exponent 'e'(in bits, not null)0x04001
Number of bits of the operands 'm'(in bits, not null)0x04081
Storage area for Montgomery parameter. Must be used if MODE[5:0]="000010" (modular exponentiation only).(mandatory)0x0620ROS
Base of the exponentiation 'm'(0 ≤ m < n)0x0C50ROS
Exponent to process 'e'(0 ≤ e < n)0x0E60ROS
Modulus 'n'(Odd integer only, n < 2⁴¹⁶⁰)0x1080ROS
Result (\(m^e \bmod n\))(0 ≤ result < n)0x830ROS

The execution time, for both operations, depends on the number of bits of the modulus and

exponent. When SECLVL=0, the execution time depends also on the value of the exponent. It is possible to make the execution time independent from the value of the exponent, by setting the SECLVL=1. To make the modular exponentiation operations constant time, the exponent size must be set equal to the size of the modulus, regardless of the exponent's actual number of significant bits.

Note: The core supports only odd modulus. if modulus randomization is applied, the randomized modulus has to be an odd number.

Both exponent and operand are unsigned integers represented in binary form on 64 bits. Both must be less or equal to max_rsa_size (4160)

13.4.3 Compute the ECC scalar multiplication

During this operation the PKA computes the ECC scalar multiplication kP.

Table 38. ECC scalar multiplication computation inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Number of bits of 'k'(In bits, not null)0x04001
Number of bits of the modulus GF(p).
For NIST P-256 value is 256.
(In bits, not null, 8 < value < 640)0x04081
ECC curve 'a' coefficient sign.
0x0: positive; 0x1: negative
For NIST curves over prime fields value is 0x1.
– 0x0: positive
– 0x1: negative
0x04101
ECC curve 'a' coefficient absolute value.
For NIST curves over prime fields value is 0x3.
(absolute value, |a| < p)0x0418EOS
ECC curve prime modulus 'p'(odd integer prime, 0 < p < 2640)0x0470EOS
Storage area for Montgomery Parameter.
Must be used if MODE[5:0]="100010" (scalar multiplication only).
450x04C8EOS
The 'k' of kP(0 ≤ k < 2640)0x0520EOS
initial point 'P' coordinates
X
Y
(x < p)
(y < p)
0x0578
0x05D0
EOS
EOS
Coordinates of the result
X
Y
(result < p)
(result < p)
0x0578
0x05D0
EOS
EOS

The execution time, for both operations, depends on the size of the scalar. When SECLVL = 0, the execution time also depends on the value of the scalar.

It is possible to make the execution time independent from the value of the scalar, by setting the SECLVL equal to 01. To make the ECC scalar multiplication operations constant time, the size of the scalar must be set equal to the size of the order, regardless of the scalar's actual number of significant bits.

Note: The core supports only prime modulus; it is not possible to apply modulus randomization. The input value k is required to be greater than zero.

If the user wants to execute the side channel protection known as scalar blinding (where the scalar 'k' is randomized via the addition of a multiple of the order of the curve n), the PKA core is not able to deal with the case where the internal temporary result falls in the point at infinity. It is very unlikely to fall in the point at infinity, but it is possible to check that this inconvenience has happened by checking the final result. I.e. if the temporary result is equal to the point at infinity, the final result has both coordinates x and y equal to zero, that is not a point on the curve. When the scalar 'k' is smaller than the order, it is not possible to reach the point at infinity.

13.4.4 Point check

During this operation the PKA computes a boolean that tell whether the given point P satisfies the curve over prime fields equation or not. If output error is equal to zero the point is on the curve.

Table 39. Point check computation inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Number of bits of the modulus GF(p). For NIST P-256 value is 256.(In bits, not null, 8 < value < 640)0x04081
ECC curve 'a' coefficient sign.
0x0: positive; 0x1: negative
For NIST curves over prime fields value is 0x1.
0x0:positive
0x1:negative
0x04101
ECC curve 'a' coefficient absolute value.(Absolute value, |a| < p)0x0418EOS
ECC curve 'b' coefficient absolute value.(|b| < p)0x0520EOS
ECC curve prime modulus 'p'(Odd integer prime, 0 < p < 2⁶⁴⁰)0x0470EOS
The point 'P' Coordinates
X
Y
(x < p)
(y < p)
0x0578
0x05D0
2*EOS
Storage area for Montgomery parameter.-0x4C8EOS

Table 40. Point check computation outputs

Output dataValue (note)Hexadecimal offset in PKASize (words)
Error output result. If it is different from zero the point 'P' is not on the curve.
  • – 0xD60D: point on curve
  • – 0xA3B7: point not on curve
  • – 0xF946: x or y coordinate is not smaller than modulus p
  • - 0xF09C: A fault has altered the result of operation
  • - 0x0000: A fault has altered the execution of operation
0x0F801

If the error code does not correspond to any of the possible expected values, something wrong has happened during the execution flow.

The location storing the Error code is set equal to 0x400 at the beginning of the computation. If it is equal to 0x400 at the end of the computation, then it means that the fault check procedure has failed. This scenario should be treated as an attempt to skip the fault check procedure and thus as a fault itself.

Furthermore, the detection of faults is also signaled using dedicated flags (see Section 13.3.5: PKA error management).

Note: Coordinates X and Y of the point P must be smaller than the modulus.

13.4.5 ECDSA sign

During this operation the PKA computes a signed message using elliptic curves over prime fields.

Table 41. ECDSA sign computation inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Number of bits of the order
For SHA-256 value is 256.
(in bits, not null)0x04001
Number of bits of the modulus GF(p). For
NIST P-256 value is 256.
(in bits, 8 < value < 640)0x04081
ECC curve 'a' coefficient sign.
0x0: positive; 0x1: negative
For NIST curves over prime fields value is 0x1.
0x0:positive
0x1:negative
0x04101
ECC curve 'a' coefficient absolute value.
For NIST curves over prime fields value is 0x3.
(absolute value, |a| < p)0x0418EOS
ECC curve prime modulus 'p'(Odd integer prime, 0 < p < 2⁶⁴⁰)0x0470EOS
Random integer 'k' generated outside the PKA
for this ECDSA signature
(0 ≤ k < 2⁶⁴⁰)0x0520EOS
The initial point 'P' Coordinates
X
Y
(x < p)
(y < p)
0x0578
0x05D0
EOS
EOS
Hash of the message 'e'(\(e < 2^M\))0x0E70EOS
Private key 'd'(Positive integer)0x0EC8EOS
Integer prime order of the curve 'n'(Integer prime)0x0F20EOS

Table 42. ECDSA sign computation outputs

Output dataValue (note)Hexadecimal offset in PKASize (words)
Error output result. If it is different from zero, a new 'k' should be generated and ECDSA sign operation needs to be repeated.
  • – 0xD60D: successful computation, no error
  • – 0xCBC9: failed computation – 0xA3B7: signature part r is equal to 0
  • – 0xF946: signature part s is equal to 0
  • - 0x0000: A fault has altered the normal execution of the operation
0x0F801
Signature part 'r'1920x0730EOS
Signature part 's'2130x0788EOS
The final point 'kP' (OPTIONAL)
    X7830x578EOS
    Y8040x5D0EOS

If the error code does not correspond to any of the possible expected values, something wrong has happened during the execution flow.

The location storing the Error code is set equal to 0 at the beginning of the computation. If it is equal to 0 at the end of the computation, then it means that the fault check procedure has failed. This scenario should be treated as an attempt to skip the fault check procedure and thus as a fault itself.

Note: The prime modulus for P-256 curve is \(p = 2^{256} - 2^{224} + 2^{192} + 2^{96} - 1\) which correspond to hexadecimal value 0xFFFFFFFF 00000001 00000000 00000000 00000000 FFFFFFFF FFFFFFFF FFFFFFFF.

Extended ECDSA support

PKA also supports extended ECDSA signature, for which the inputs and the outputs are the same as ECDSA signature, with the addition of the coordinates of the point kG. This extra output is defined below:

Table 43. Extended ECDSA outputs

Output dataValue (note)Hexadecimal offset in PKASize (words)
Curve point kG coordinate x1(0 ≤ x₁ < p)0x05781
Curve point kG coordinate y1(0 ≤ y₁ < p)0x05D01

When SECLVL = 0, the execution time depends on the value of the scalar.

It is possible to make the execution time independent from the value of the scalar, by setting the security level equal to 1.

13.4.6 ECDSA verification

During this operation the PKA computes a boolean that tells whether given signature is valid or not. This signature shall be based on an elliptic curves over prime fields.

If output error is equal to zero the signature is valid.

Table 44. ECDSA verification computation inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Number of bits of the order.
For SHA-256 value is 256.
(In bits, not null)0x04081
Number of bits of the modulus GF(p). For NIST P-256 value is 256.64 bits (In bits, not null, 8 < value < 640)0x0F781
ECC curve 'a' coefficient sign.
0x0: positive; 0x1: negative
For NIST curves over prime fields value is 0x1.
0x0:positive
0x1:negative
0x04101
ECC curve 'a' coefficient absolute value.
For NIST curves over prime fields value is 0x3.
(Absolute value, |a| < p)0x0418EOS
ECC curve prime modulus 'p'(Odd integer prime, 0 < p < 2⁶⁴⁰)0x0F20EOS
The initial point 'P' coordinates
X
Y
(x < p)
(y < p)
0x0628
0x0680
2*EOS
Public key point 'Qa' coordinates
X
Y
(\(x_Q < p\))
(\(y_Q < p\))
0x0730
0x0788
EOS
EOS
Signature part 'r'(0 < r < n)0x0EC8EOS
Signature part 's'(0 < s < n)0x08E8EOS
Hash of the message 'e'(\(e < 2^M\))0x0E70EOS
Integer prime order of the curve 'n'(integer prime)0x0470EOS

Table 45. ECDSA verification computation outputs

Output dataValue (note)Hexadecimal offset in PKASize (words)
Error output result. If it is different from 0, the signature is not verified.– 0xD60D: valid signature
– 0xA3B7: invalid signature
0x0F801

13.4.7 RSA CRT exponentiation

During this operation the PKA computes the Chinese remainder theorem (CRT) optimization.

Table 46. RSA CRT exponentiation computation inputs

Input dataValue (Note)Hexadecimal offset in PKASize (words)
Number of bits of the operands(in bits, not null)0x04081
CRT parameter 'dp'(\(0 \leq d_p < 2^{M/2}\))0x0728ROS/2
CRT parameter 'dq'(\(0 \leq d_q < 2^{M/2}\))0x0E60ROS/2
CRT parameter 'qinv'(\(0 \leq q_{inv} < 2^{M/2}\))0x0938ROS/2
Prime 'p'(\(0 \leq p < 2^{M/2}\))0x0B48ROS/2
Prime 'q'(\(0 \leq q < 2^{M/2}\))0x1080ROS/2
Base of the exponentiation (A)(\(0 \leq A < 2^{M/2}\))0x1290ROS

Table 47. RSA CRT exponentiation computation outputs

Output dataValue (note)Hexadecimal offset in PKASize (words)
Operation result: \(A^d \bmod pq\)(0 ≤ result < pq)0x0830ROS

Note: CRT is supported for modulus up to 4096 bits, with prime p and q of the same length i.e. half of the length of the modulus.

13.4.8 Modular reduction

During this operation the PKA computes a modular reduction.

Table 48. Modular reduction computation inputs
Input dataValue (note)Hexadecimal offset in PKASize (words)
Operand length(In bits, not null)0x04001
Operand A(0 ≤ A < 2n < 2⁴¹⁶⁰)0x04081
Modulus length(In bits, 8 < value < 4160)0x0A401
Modulus n(Odd integer only, n < 2⁴¹⁶⁰)0x1080ROS
Table 49. Modular reduction computation outputs
Output dataValue (note)Hexadecimal offset in PKASize (words)
Operation result A mod n(0 < result < n)0x0E60ROS

13.4.9 Arithmetic addition

During this operation the PKA computes the arithmetic addition of two inputs op1 and op2.

Table 50. Arithmetic addition inputs
Input dataValue (note)Hexadecimal offset in PKASize (words)
Operand length M(In bits, not null)0x04081
op1 A\((0 \leq A < 2^M)\)0x0A40ROS
op2 B\((0 \leq B < 2^M)\)0x0C50ROS
Table 51. Arithmetic subtraction outputs
Output dataValue (note)Hexadecimal offset in PKASize (words)
operation result:
op1 + op2
\((0 \leq \text{result} < 2^{M+1})\)0x0E60ROS+1

13.4.10 Arithmetic subtraction

During this operation the PKA computes the arithmetic subtraction of two inputs op1 and op2.

Table 52. Arithmetic subtraction inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Operand length M(In bits, not null)0x04081
op1 A\((0 \leq A < 2^M)\)0x0A40ROS
op2 B\((0 \leq B < 2^M)\)0x0C50ROS

Table 53. Arithmetic subtraction outputs

Output dataValue (note)Hexadecimal offset in PKASize (words)
Operation result:
op1 - op2
\((0 \leq \text{result} < 2^M)\)0x0E60ROS

13.4.11 Comparison

During this operation, given two inputs op1 and op2, the PKA computes comparisons as follow:

Table 54. Comparison computation inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Operand length M(In bits, not null)0x04081
op1 A(\(0 \leq A < 2^M\))0x0A40ROS
op2 B(\(0 \leq B < 2^M\))0x0C50ROS

Table 55. Comparison computation outputs

Output dataValue (note)Hexadecimal offset in PKASize (words)
Operation result:
If op1 = op2, then result = 0xED2C
If op1 > op2, then result = 0x7AF8
If op1 < op2, then result = 0x916A
Result = 0xF09C: A fault has altered the result of operation
Result = 0x0000: A fault has altered the execution of operation
0xED2C,
0x7AF8,
0x916A,
0xF09C,
0x0000
0x0E601

If the error code does not correspond to any of the possible expected values, something wrong has happened during the execution flow.

The location storing the Error code is set equal to 0x400 at the beginning of the computation. If it is equal to 0x400 at the end of the computation, then it means that the fault check procedure has failed. This scenario should be treated as an attempt to skip the fault check procedure and thus as a fault itself.

Furthermore, the detection of faults is also signaled using dedicated flags (see Section 13.3.5: PKA error management)

13.4.12 Arithmetic multiplication

During this operation the PKA computes the arithmetic multiplication of two inputs op1 and op2.

Table 56. Arithmetic multiplication inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Operand length M(In bits, not null)0x04081
op1 A\((0 \leq A < 2^M)\)0x0A40ROS
op2 B\((0 \leq B < 2^M)\)0x0C50ROS

Table 57. Arithmetic multiplication outputs

Output dataValue (note)Hexadecimal offset in PKASize (words)
Operation result:
op1 x op2
\((0 \leq \text{result} < 2^M)\)0x0E602*ROS

13.4.13 Modular addition

During this operation the PKA computes the addition of op1 by op2 modulus op3.

Table 58. Modular addition inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Operand length(In bits, not null)0x04081
op1 A(0 ≤ A < n)0x0A40ROS
op2 B(0 ≤ B < n)0x0C50ROS
op3 (modulus n)(n < 2⁴¹⁶⁰)0x1080ROS

Table 59. Modular addition outputs

Output dataValue (note)Hexadecimal offset in PKASize (words)
Operation result:
(op1 + op2) mod op3
(0 ≤ result < n)0x0E60ROS

With SECLVL=0, the execution time depends both on the size of the modulus and on whether the reduction after the addition is executed or not. To make the execution constant time (i.e., independent from the final reduction), security level shall be set to 1.

13.4.14 Modular inversion

During this operation the PKA computes the inversion of op1 modulus op2.

Note: op1 must be smaller than the modulus op2.

Table 60. Inverse op1 modulus op2 computation inputs
Input dataValue (note)Hexadecimal offset in PKASize (words)
Operand length(In bits, not null)0x04081
op1 A(0 ≤ A < n)0x0A40ROS
op2 (modulus n)(Odd integer only, n < 2⁴¹⁶⁰)0x0C50ROS
Table 61. Inverse op1 modulus op2 computation outputs
output dataValue (note)Hexadecimal offset in PKASize (words)
Operation result A⁻¹modn0 < result < n0x0E60ROS

Note: The operand to invert should be coprime with the modulus. In case this is not known, and the operand is a divisor of the modulus, the result is a multiple of a factor of the modulus.

13.4.15 Modular subtraction

During this operation the PKA computes the subtraction of op1 by op2 modulus op3.

Table 62. Modular subtraction inputs
Input dataValue (note)Hexadecimal offset in PKASize (words)
opErand length10x04081
op1 A(0 ≤ A < n)0x0A40ROS
op2 B(0 ≤ B < n)0x0C50ROS
op3 (modulus n)(n < 2⁴¹⁶⁰)0x1080ROS
Table 63. Modular subtraction outputs
Output dataValue (note)Hexadecimal offset in PKASize (words)
Operation result:
(op1 - op2) mod op3
(0 ≤ result < n)0x0E60ROS

With SECLVL=0, the execution time depends both on the size of the modulus and on whether the reduction after the addition is executed or not. To make the execution constant time (that is, independent from the final reduction), security level shall be set to 1.

Note: Reduction happens when op2 is larger than op1. The result is always smaller than op3 and equal or larger than zero.

13.4.16 Montgomery multiplication

During this operation the PKA computes the multiplication of op1 by op2 modulus op3 in the Montgomery space.

Before issuing this operation the PKA needs to set some internal registers, which can be done by issuing an Montgomery parameter computation, an ECC scalar multiplication or any ECC operation.

Table 64. Montgomery multiplication inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Operand length(In bits, not null)0x04081
op1 A(0 ≤ A < n)0x0A40ROS
op2 B(0 ≤ B < n)0x0C50ROS
op3 (modulus n)(Odd integer only, n < 2⁴¹⁶⁰)0x1080ROS

Table 65. Montgomery multiplication outputs

output dataValue (note)Hexadecimal offset in PKASize (words)
Operation result (A × Bmodn)-0x0E60ROS

Note: For converting a number from natural representation to Montgomery domain it is necessary to perform a Montgomery multiplication between the number and the Montgomery Parameter (called also R2modn). While for converting a number from Montgomery domain to natural domain a Montgomery multiplication between the Montgomery number and one has to be computed.

13.4.17 ECC complete addition

ECC complete addition computes the addition of two given points on an elliptic curve. Operation instructions are summarized below.

Note: The two input points and the resulting point are represented in Jacobian coordinates (X,Y,Z). To input a point in affine coordinates (x,y) conversion (X,Y,Z) = (x,y,1) can be used. To convert resulting point to Jacobian coordinates conversion (x,y) = (X/Z²,Y/Z³) can be used.

Table 66. ECC complete addition inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Curve modulus p length(In bits, not null, 8 < value < 640)0x04081
Curve coefficient a sign0x0:positive
0x1:negative
0x04101

Table 66. ECC complete addition inputs (continued)

Input dataValue (note)Hexadecimal offset in PKASize (words)
Curve modulus value p(Odd integer prime, 0 < p < 2⁶⁴⁰)0x0470EOS
Curve coefficient |a|(Absolute value, |a| < p)0x0418EOS
First point P coordinate X(x < p)0x0628EOS
First point P coordinate Y(y < p)0x0680EOS
First point P coordinate Z(z < p)0x06D8EOS
Second point Q coordinate X(x < p)0x0730EOS
Second point Q coordinate Y(y < p)0x0788EOS
Second point Q coordinate Z(z < p)0x07E0EOS

Table 67. ECC complete addition outputs

Output dataValue (note)Hexadecimal offset in PKASize (words)
Result coordinate X(x < p)0x0D60EOS
Result coordinate Y(y < p)0x0DB8EOS
Result coordinate Z(z < p)0x0E10EOS

13.4.18 ECC double base ladder

ECC double base ladder operation consists in the computation of k*P+m*Q, where (P,Q) are two points on an elliptic curve and (k,m) are two scalars. Operation instructions are summarized below. If the resulting point is the point at infinity (error code 0xA3B7), resulting coordinate equals (0,0).

Note: The two input points are represented in Jacobian coordinates (X,Y,Z). To input a point in affine coordinates (x,y) conversion (X,Y,Z) = (x,y,1) can be used. The result is represented in affine coordinates (x,y)

Table 68. ECC double base ladder operation inputs

Input dataValue (note)Hexadecimal offset in PKASize (words)
Curve prime order n length(In bits, not null)0x04001
Curve modulus p length(In bits, not null, 8 < value < 640)0x04081
Curve coefficient a sign0x0:positive
0x1:negative
0x0410EOS
Curve coefficient |a|(Absolute value, |a| < p)0x0418EOS
Curve modulus value p(odd integer prime, 0 < p < 2⁶⁴⁰)0x0470EOS
Integer k(odd integer prime, 0 < k < 2⁶⁴⁰)0x0520EOS
Integer m(odd integer prime, 0 < m < 2⁶⁴⁰)0x0578EOS
First point P coordinate X(x < p)0x0628EOS
First point P coordinate Y(y < p)0x0680EOS
Second point Q coordinate X(x < p)0x0730EOS
Second point Q coordinate Y(y < p)0x0788EOS

Table 69. ECC double base ladder operation outputs

Output dataValue (note)Hexadecimal offset in PKASize (words)
Result coordinate X(x < p)0x0578EOS
Result coordinate Y(y < p)0x05D0EOS
Error code– Point not at infinity: 0xD60D
– Point at infinity: 0xA3B7
0x0F80EOS

13.5 Processing time

The following tables summarize the PKA computation times, expressed in clock cycles.

Table 70. Modular exponentiation(1)

Exponent length
(in bits)
ModeOperand length (in bits)
1024204830724096
3Normal1246004910006840001133200
Fast2270082000178000311000
17Normal1357005314007724001288000
Fast33800122500266500465800
2¹⁶+1Normal18000069370011262001907200
Fast782002847006204001085000
1024Normal5850000---
Fast5748000---
SECLVL=17579385---
2048Normal-42240000--
Fast-41832000--
SECLVL=1-55409889--
3072Normal--136830000-
Fast--136325000-
SECLVL=1--181240525-
4096Normal---316000000
Fast---315226000
SECLVL=1---422820009
  1. 1. To make the modular exponentiation operations constant time, the exponent size must be set equal to the size of the modulus, regardless of the exponent's actual number of significant bits.

Table 71. ECC scalar multiplication(1)

ModeModulus length (in bits)
160192256320384512521640
Normal-1590000308300053390008518000178180002105300031826000
  1. 1. These times depend on the number of "1"s included in the scalar parameter.
Table 72. ECDSA signature average computation time(1)(2)
Modulus length (in bits)
SECLVL160192256320384512521640
0-1500000274400045790007184000144550001668500024965000
1-19027003709700631160010088100209479002399750037177500
  1. 1. These values are average execution times of random moduli of given length, as they depend upon the length and the value of the modulus.
  2. 2. The execution time for the moduli that define the finite field of NIST elliptic curves is shorter than that needed for the moduli used for Brainpool elliptic curves or for random moduli of the same size.
Table 73. ECDSA verification average computation times
Modulus length (in bits)
160192256320384512521640
10110001495000293800050140007979000168040001925400029582000
Table 74. Montgomery parameters average computation times
Modulus length (in bits)
160192256320384512521102420483072
225939235924745110841175063200059768233073552321
  1. 1. The computation times depend upon the length and the value of the modulus, hence these values are average execution times of random moduli of given length.

13.5.1 PKA interrupts

There are three individual maskable interrupt sources generated by the public key accelerator when enabled by EN bit, signaling the following events:

  1. 1. Access to unmapped address (ADDRERRF), see Section 13.3.5: PKA error management
  2. 2. PKA RAM access while PKA operation is in progress (RAMERRF), see Section 13.3.5: PKA error management
  3. 3. PKA end of operation (PROCENDF), see Section 13.3.5: PKA error management
  4. 4. PKA FSM fault (FAULTFSMF), see Section 13.3.5: PKA error management
  5. 5. PKA ERRORCODE fault (FAULTERRORCODEF), see Section 13.3.5: PKA error management

The three interrupt sources are connected to the same global interrupt request signal pka_it. The user can enable or disable above interrupt sources individually by changing the mask bits in the Section 13.6.1: PKA control register (PKA_CR). Setting the appropriate mask bit to 1 enables the interrupt. The status of the individual interrupt events can be read from the PKA status register (PKA_SR), and it is cleared in PKA_CLRFR register, except for fault flags which can be cleared only putting low EN bit in PKA_CR.

Table 75 gives a summary of the available features.

Table 75. PKA interrupt requests

Interrupt eventEvent flagEnable control bit
Access to unmapped address errorADDRERRFADDRERRIE
PKA RAM access errorRAMERRFRAMERRIE
PKA end of operationPROCENDFPROCENDIE
PKA FSM faultFAULTFSMFFAULTFSMIE
PKA ERROR code faultFAULTERRORCODEFFAULTERRORCODIE

13.6 PKA registers

13.6.1 PKA control register (PKA_CR)

Address offset: 0x00

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.FAULT
ERROR
CODEI
E
FAUL
TFSMI
E
Res.ADDR
ERRIE
RAM
ERRIE
Res.PROC
ENDIE
Res.
rwrwrwrwrw
1514131211109876543210
Res.Res.MODEResResResResRes.SECLVLSTARTEN
rwrwrwrwrwrwrwrwrw

Bits 31:24 Reserved, must be kept at zero

Bits 23 FAULTERRORCODEIE : Fault Error code interrupt enable

0: Interrupt is disabled.

1: An interrupt is generated when FAULTERRORCODEF (PKA_SR[23] is set.

Bits 22 FAULTFSMIE : Fault FSM interrupt enable

0: Interrupt is disabled.

1: An interrupt is generated when FAULTFSMF (PKA_SR[22] is set.

Bit 21 Reserved, must be kept at zero

Bit 20 ADDRERRIE : Address error interrupt enable

0: Interrupt is disabled.

1: An interrupt is generated when ADDRERRF (PKA_SR[20] is set.

Bit 19 RAMERRIE : RAM error interrupt enable

0: Interrupt is disabled.

1: An interrupt is generated when RAMERRF (PKA_SR[19] is set.

Bit 18 Reserved, must be kept at zero

Bit 17 PROCENDIE : End of operation interrupt enable

0: Interrupt is disabled.

1: An interrupt is generated when PROCENDF (PKA_SR[17] is set.

Bits 16:14 Reserved, must be kept at zero

Bits 13: 8 MODE[5:0]: PKA operation code

Bit 7:3 Reserved, must be kept at zero

Bit 2 SECLVL : Security enable.

Bit 1 START : start the operation

Writing '1' to this bit starts the operation which is selected by MODE[5:0], using the operands and data already written to the PKA RAM. This bit is always read as '0'.

Nota: START is ignored if PKA is busy.

Bit 0 EN : Peripheral enable.

13.6.2 PKA status register (PKA_SR)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.FAULTERRORCODEFFAULTFSMFRes.ADDRERRFRAMERRFRes.PROCENDFBUSY
rwrwrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.

Bits 31:24 Reserved, must be kept at zero

Bits 23 FAULTERRORCODEF : Fault Error code flag

0: No Fault error code

1: Fault error code has been generated

Bits 22 FAULTFSMF : Fault FSM flag

0: No Fault FSM error

1: Fault FSM error has been generated

Bit 21 Reserved, must be kept at zero

Bit 20 ADDRERRF: Address error flag

0: No Address error

1: Address access is out of range (unmapped address)

Bit 19 RAMERRF: PKA RAM error flag

0: No PKA RAM access error

1: An AHB access to the PKA RAM occurred while the PKA core was computing and using its internal RAM (AHB PKA_RAM access are not allowed while PKA operation is in progress).

Bits 18 Reserved, must be kept at zero

Bit 17 PROCENDF: PKA End of Operation flag

0: Operation in progress

1: PKA operation is completed. This flag is set when the BUSY bit is de-asserted.

Bit 16 BUSY: PKA operation is in progress

This bit is set to '1' whenever START bit in the PKA_CR is set. It is automatically cleared when the computation is complete, meaning that PKA RAM can be safely accessed and a new operation can be started.

0: No operation is in progress (default)

1: An operation is in progress

Note: if PKA is started with a wrong opcode the IP is busy for a couple of cycles then it aborts automatically the operation and go back to ready (BUSY bit is set to '0').

Bits 15:0 Reserved, must be kept at zero

13.6.3 PKA clear flag register (PKA_CLRFR)

Address offset: 0x08

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ADDR
ERRFC
RAM
ERRFC
Res.PROC
ENDFC
Res.
w_r0w_r0w_r0
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.

Bits 31 : 21 Reserved, must be kept at zero

Bit 20 ADDRERRFC: Clear Address error flag

0: No action

1: Clear the ADDRERRF flag

Bit 19 RAMERRFC: Clear PKA RAM error flag

0: No action

1: Clear the RAMERRF flag

Bits 18 Reserved, must be kept at zero

Bit 17 PROCENDFC: Clear PKA End of Operation flag

0: No action

1: Clear the PROCENDF flag

Bits 16 : 0 Reserved, must be kept at zero

Note: Reading PKA_CLRFR returns all zeros.

13.6.4 PKA RAM memory

Address offset: 0x400

The PKA_RAM is memory mapped at the offset address of 0x0400 compared to the PKA base address. Only word access (64 bits) are supported.

RAM size is 4768 bytes (max word offset: 0x1698)

13.6.5 PKA register map

Table 76. PKA register map

OffsetRegister313029282726252423222120191817161514131211109876543210
0x0000PKA_CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ADDRERRIERAMERRIERes.PROCENDIERes.Res.Res.Res.Res.MODE[5 : 0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0000000000000000000000000000000
0x0004PKA_SRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ADDRERRFRAMERRFRes.PROCENDFBUSYRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0000000000000000000000000000000
0x0008PKA_CLRFRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ADDRERRFCRAMERRFCRes.PROCENDFCRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0000000000000000000000000000000