63. Public key accelerator (PKA)

63.1 Introduction

PKA (public key accelerator) 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.

For a given operation, all needed computations are performed within the accelerator, so no further hardware/software elaboration is needed to process the inputs or the outputs.

When manipulating secrets, the PKA incorporates a protection against side-channel attacks (SCA), including differential power analysis (DPA), certified SESIP and PSA security assurance level 3.

63.2 PKA main features

63.3 PKA functional description

63.3.1 PKA block diagram

Figure 572. PKA block diagram

PKA block diagram showing connections between 32-bit AHB bus, AHB interface, Banked registers (main: PKA_CR, PKA_SR, PKA_CLRFR), 32-bit access, 64-bit PKA core, Control logic, IRQ interface, 667x64-bit PKA RAM, and signals pka_hclk, pka_it, pka_itamp_out.

PKA block diagram showing the 32-bit AHB bus connected via the AHB interface to Banked registers (PKA_CR, PKA_SR, PKA_CLRFR) and 32-bit access routing. The 64-bit PKA core interfaces via 64-bit bus to a 667x64-bit PKA RAM. Control logic connects to the IRQ interface which outputs pka_it and pka_itamp_out, with pka_hclk driving the block.

PKA block diagram showing connections between 32-bit AHB bus, AHB interface, Banked registers (main: PKA_CR, PKA_SR, PKA_CLRFR), 32-bit access, 64-bit PKA core, Control logic, IRQ interface, 667x64-bit PKA RAM, and signals pka_hclk, pka_it, pka_itamp_out.

63.3.2 PKA internal signals

Table 568 lists the internal signals available at the PKA level, not necessarily available on product bonding pads.

Table 568. Internal input/output signals

Signal nameSignal typeDescription
pka_hclkDigital inputAHB bus clock
pka_itDigital outputPublic key accelerator IP global interrupt request
pka_itamp_outDigital output

PKA internal tamper event signal to TAMP (XOR-ed), triggered when an unexpected fault occurs while PKA manipulates secrets, or when the programmed input point is not found on the input curve (ECDSA signature and ECC scalar multiplication only).

This signal is asserted as soon as a fault is detected. When asserted, read access to PKA registers are reset to 0 and writes are ignored.

The signal is de-asserted when PKA memory is cleared.

63.3.3 PKA reset and clocks

PKA is clocked on the AHB bus clock. When the PKA peripheral reset signal is released PKA_RAM is cleared automatically, taking 667 clock cycles. During this time the setting of bit EN in PKA_CR register is ignored. Once EN bit is set, refer to Section 63.3.6 for details about PKA initialization sequence.

According to the security policy applied to the device, PKA RAM can also be reset following a tamper event. Refer to Tamper detection and response in the System security section (if applicable to this product).

Public key accelerator (PKA) RM0457

3486/5881 RM0457 Rev 5

63.3.4 PKA public key acceleration

Overview

Public key accelerator (PKA) is used to accelerate Rivest, Shamir and Adleman (RSA), Diffie-Hellman (DH) as well as ECC over prime field operations. Supported operand sizes is up to 4160 bits for RSA and DH, and up to 640 bits for ECC.

The PKA supports all non-singular elliptic curves defined over prime fields, that can be described with a short Weierstrass equation y² = x³+ax+b (mod p). More information can be found in Section 63.5.1.

Note: Binary curves, Edwards curves and Curve25519 are not supported by the PKA.

A memory of 5336 bytes (667 words of 64 bits) called PKA RAM is used to provide initial data to the PKA, and to hold the results after computation is completed. Access is done through the PKA AHB interface.

PKA operating modes

The list of operations the PKA can perform is detailed in Table 569 and Table 570, respectively, for integer arithmetic functions and prime field (\(F_p\)) elliptic curve functions.

Table 569. PKA integer arithmetic functions list

PKA_CR.MODE[5:0]Performed operationReference
HexBinary
0x01000001Montgomery parameter computation R2modnSection 63.4.2
0x0E001110Modular addition (A+B)modnSection 63.4.3
0x0F001111Modular subtraction (A-B)modnSection 63.4.4
0x10010000Montgomery multiplication (AxB)modnSection 63.4.5
0x00000000Modular exponentiation \(A^e \bmod n\)Section 63.4.6
0x02000010Modular exponentiation \(A^e \bmod n\) (fast mode)
0x03000011Modular exponentiation \(A^e \bmod n\) (protected)Section 63.4.6
0x08001000Modular inversion A⁻¹modnSection 63.4.7
0x0D001101Modular reduction AmodnSection 63.4.8
0x09001001Arithmetic addition A+BSection 63.4.9
0x0A001010Arithmetic subtraction A-BSection 63.4.10
0x0B001011Arithmetic multiplication AxBSection 63.4.11
0x0C001100Arithmetic comparison (A = B, A > B, A < B)Section 63.4.12
0x07000111RSA CRT exponentiationSection 63.4.13

Table 570. PKA prime field (Fp) elliptic curve functions list

PKA_CR.MODE[5:0]Performed operationReference
HexBinary
0x28101000Point on elliptic curve Fp checkSection 63.4.14
0x20100000ECC scalar multiplication kP (protected)Section 63.4.15
0x23100011ECC complete additionSection 63.4.18
0x24100100ECDSA sign (protected)Section 63.4.16
0x26100110ECDSA verificationSection 63.4.17
0x27100111ECC double base ladderSection 63.4.19
0x2F101111ECC projective to affineSection 63.4.20

Each of these operating modes has an associated code that has to be written to the MODE field in the PKA_CR register. If the application selects any value that is not documented below the write to MODE bitfield is ignored, and an operation error (OPERRF) is triggered. When this happens, a new operation must be selected after the error is cleared.

Some operations in Table 569 and Table 570 are indicated as protected. Those operations are used when manipulating secret keys (modular exponentiation for RSA decryption, scalar multiplication and signature for ECC). Those secrets (protected against side channel attacks) and any intermediate values are automatically erased when PKA RAM is cleared at the end of the protected operations (BUSY goes low). They are also protected against side channel attacks.

Caution: For security reason it is very important to select protected modular exponentiation (MODE = 0x3) when performing RSA decryption.

Montgomery space and fast mode operations

For efficiency reason the PKA internally performs modular multiply operations in the Montgomery domain, automatically performing inward and outward transformations.

As Montgomery parameter computation is time consuming the application can decide to use a faster mode of operation, during which the precomputed Montgomery parameter is supplied before starting the operation. Performance improvement is detailed in Section 63.5.2: Computation times.

The only operation using fast mode is modular exponentiation (MODE = 0x02).

63.3.5 Typical applications for PKA

Introduction

The PKA can be used to accelerate a number of public key cryptographic functions. In particular:

Specifications of the above functions are given in following publications:

The principles of the main functions are described in this section, for a more detailed description refer to the above cited documents.

RSA key pair

For the following RSA operations a public key and a private key information are defined as below:

For more information on the above representations refer to the RSA specification.

RSA encryption/decryption principle

As recommended by the PKCS#1 specification, Bob, to encrypt message M using Alice's public key (n,e) must go through the following steps:

  1. 1. Compute the encoded message EM = ENCODE(M), where ENCODE is an encoding method.
  2. 2. Turn EM into an integer m, with 0 ≤ m < n and (m,n) being coprimes.
  3. 3. Compute ciphertext \(c = m^e \bmod n\).
  4. 4. Convert the integer c into a string ciphertext C.

Alice, to decrypt ciphertext c using her private key d, follows the steps indicated below:

  1. 1. Convert the ciphertext C to an integer ciphertext representative c.
  2. 2. If necessary, retrieve the prime factors (p,q) using (n,e,d) information, then compute ϕ = (p-1)*(q-1). Refer to NIST SP800-56B Appendix C for details.
  3. 3. Recover plaintext \(m = c^d \bmod n = (m^e)^d \bmod n\). If the private key is the quintuple (p,q,dp,dq,qInv), then plaintext m is obtained by performing the operations:
    1. a) \(m_1 = c^{dp} \bmod p\)
    2. b) \(m_2 = c^{dq} \bmod q\)
    3. c) h = qInv(m₁-m₂)modp
    4. d) m = m₂+hq
  4. 4. Convert the integer message representative m to an encoded message EM.
  5. 5. Recover message M = DECODE(EM), where DECODE is a decoding method.

Above operations can be accelerated by PKA using Modular exponentiation \(A^e \bmod n\) if the private key is d, or RSA CRT exponentiation if the private key is the quintuple (p,q,dp,dq,qInv).

Note: The decoding operation and the conversion operations between message and integers are specified in PKCS#1 standard.

For the decryption process protected version of modular exponentiation (MODE = 0x3) is strongly recommended for security reason. For encryption process MODE = 0x3 cannot be used, as it requires the knowledge of the private key.

Elliptic curve selection

For following ECC operations curve parameters are defined as below:

ECDSA message signature generation

ECDSA (elliptic curve digital signature algorithm) signature generation function principle is the following: Alice, to sign a message m using her private key integer \(d_A\), goes through the following steps.

  1. 1. Calculate e = HASH(m), where HASH is a cryptographic hash function.
  2. 2. Let z be the \(L_n\) leftmost bits of e, where \(L_n\) is the bit length of the group order n.
  3. 3. Select a cryptographically secure random integer k where 0 < k < n.
  4. 4. Calculate the curve point (x₁,y₁) = k × G.
  5. 5. Calculate r = x₁modn. If r = 0 go back to step 3.
  6. 6. Calculate \(s = k^{-1} (z + r d_A) \bmod n\). If s = 0 go back to step 3.
  7. 7. The signature is the pair (r,s).

Steps 4 to 7 are accelerated by PKA using:

ECDSA signature verification

ECDSA (elliptic curve digital signature algorithm) signature verification function principle is the following: Bob, to authenticate Alice's signature, must have a copy of her public key curve point \(Q_A\).

Bob can verify that \(Q_A\) is a valid curve point going through the following steps:

  1. 1. check that \(Q_A\) is not equal to the identity element O
  2. 2. check that \(Q_A\) is on the agreed curve
  3. 3. check that \(n \times Q_A = O\).

Then Bob follows the procedure detailed below:

  1. 1. verify that r and s are integer in [1,n-1]
  2. 2. calculate e = HASH(m), where HASH is the agreed cryptographic hash function
  3. 3. let z be the \(L_n\) leftmost bits of e
  4. 4. calculate w = s⁻¹modn
  5. 5. calculate u₁ = zwmodn and u₂ = rwmodn
  6. 6. calculate the curve point \((x_1, y_1) = u_1 \times G + u_2 \times Q_A\)
  7. 7. the signature is valid if r = x₁ (mod n), it is invalid otherwise.

Steps 4 to 7 are accelerated by PKA using ECDSA verification.

63.3.6 PKA procedure to perform an operation

Enabling/disabling PKA

Setting the EN bit to 1 in PKA_CR register enables the PKA peripheral. The PKA becomes available when INITOK bit is set in PKA_SR. When EN = 0, the PKA peripheral is kept under reset, with PKA memory still accessible by the application through the AHB interface.

Note: When PKA is in the process of clearing its memory EN bit cannot be set.

When setting EN bit in PKA_CR make sure that the value of MODE bitfield corresponds to an authorized PKA operation (see OPERRF in Section 63.3.7).

Clearing EN bit to 0 while a calculation is in progress causes the operation to be aborted. In this case, the content of the PKA memory is not guaranteed, with the exception of the PKA modes 0x03, 0x20 and 0x24. For these operations, the PKA memory is cleared after abort, making the memory unavailable for 667 cycles. During this clearing time only PKA registers can be accessed, with writes to EN bits ignored.

If INITOK bit stays at 0, make sure that the RNG peripheral is clocked and properly initialized, then try to enable PKA again.

Data formats

The format of the input data and the results in the PKA RAM are specified, for each operation, in Section 63.4.

Executing a PKA operation

Each of the supported PKA operation is executed using the following procedure:

  1. 1. Load initial data into the PKA internal RAM, which is located at address offset 0x400.
  2. 2. Write in the MODE field of PKA_CR register, specifying the operation which is to be executed and then assert the START bit, also in PKA_CR register.
  3. 3. Wait until the PROCENDF bit in the PKA_SR register is set to 1, indicating 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.

Note: When PKA is busy (BUSY = 1) any access by the application to PKA RAM is ignored, and the flag RAMERRF is set in PKA_SR.

Selecting an illegal or unknown operation in step 2 triggers an OPERRF error, and step 3 (PROCENDF = 1) never happens. See Section 63.3.7 for details.

Using precomputed Montgomery parameters (PKA Fast mode)

As explained in Section 63.3.4, when computing many operations with the same modulus it can be beneficial for the application to compute only once the corresponding Montgomery parameter (see, for example, Section 63.4.5). This is known as “Fast mode”.

To manage the usage of Fast mode it is recommended to follow the procedure described below:

  1. 1. Load in PKA RAM the modulus size and value information. Such information is compiled in Section 63.5.1.
  2. 2. Program in PKA_CR register the PKA in Montgomery parameter computation mode (MODE="0x1") then assert the START bit.
  3. 3. Wait until the PROCENDF bit in the PKA_SR register is set to 1, then read back from PKA memory the corresponding Montgomery parameter, and then clear PROCENDF bit by setting PROCENDFC bit in PKA_CLRFR.
  4. 4. Proceed with the required PKA operation, loading on top of regular input data the Montgomery information R2 mod m. All addresses are indicated in Section 63.4.

63.3.7 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 63.6 for details).

ADDRERRF, OPERRF and RAMERRF errors are cleared by setting the corresponding bit in PKA_CLRFR.

OPERRF error must be cleared using OPERRFC bit in PKA_CLRFR before a new operation is written in PKA_CR register.

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

63.4 PKA operating modes

63.4.1 Introduction

The various operations supported by PKA are described in the following subsections, defining the format of the input data and of the results, both stored in the PKA RAM.


Warning: The validity of all input parameters to the PKA must be checked before starting any operation, as PKA assumes that all of them are valid and consistent with each other. Input parameters must not exceed the operand size specified in the operation tables.


The following information applies to all PKA operations.

Note: Fractional results for above formulas must be rounded up to the nearest integer since PKA core processes 64-bit words.

Note: The maximum ROS is 66 words (4160-bit max exponent size), while the maximum EOS is 11 words (640-bit max operand size).

As a first example (and to better understand the endianness in PKA memory), to prepare the operation ECC Fp scalar multiplication, when the application writes the x coordinate of point

P for an ECC P256 curve (EOS = 5 words), the least significant bit must be placed in bit 0 at address offset 0x578, and the most significant bit in bit 63 at address offset 0x590. Then, as mentioned above, the application must write the empty word 0x0000000000000000 at address offset 0x598.

As a second example, still to prepare the operation ECC Fp scalar multiplication, when the application need to write the information a = -3, on a curve with a modulus length of 224 bits (that is, four 64-bit words, rounded up, plus one) following data must be written in PKA memory:

@RAM+410  0x0000000000000001  /* curve coefficient 'a' sign without extra word */
@RAM+418  0x0000000000000011  /* value of |a| LSB
@RAM+420  0x0000000000000000  ...
@RAM+428  0x0000000000000000  ...
@RAM+430  0x0000000000000000  value of |a| MSB */
@RAM+438  0x0000000000000000  /* additional all 0 word */

63.4.2 Montgomery parameter computation

This function is used to compute the Montgomery parameter (R²modn) used by PKA to convert operands into the Montgomery residue system representation. This operation can be very useful when fast mode operation is used, because in this case the Montgomery parameter is passed as input, saving the time for its computation.

Note: This operation can also be used with ECC curves. In this case prime modulus length and EOS size must be used.

Operation instructions for Montgomery parameter computation are summarized in Table 571.

Table 571. Montgomery parameter computation

Parameters with directionValue (note)StorageSize
INMODE0x01PKA_CR6 bits
Modulus length(in bits, 0 ≤ value < 4160)RAM@0x40864 bits
Modulus value n(odd integer only, n < 2⁴¹⁶⁰)RAM@0x1088ROS
OUTResult: R²modn-RAM@0x620

63.4.3 Modular addition

Modular addition operation consists in the computation of A+Bmodn. Operation instructions are summarized in Table 572.

Table 572. Modular addition

Parameters with directionValue (note)StorageSize
INMODE0x0EPKA_CR6 bits
Operand length(in bits, not null)RAM@0x40864 bits
Operand A(0 ≤ A < n)RAM@0xA50ROS
Operand B(0 ≤ B < n)RAM@0xC68
Modulus value n(n < 2⁴¹⁶⁰)RAM@0x1088
OUTResult: A+B mod n(0 ≤ result < n)RAM@0xE78

63.4.4 Modular subtraction

Modular subtraction operation consists in the following computations:

Operation instructions are summarized in Table 573.

Table 573. Modular subtraction

Parameters with directionValue (note)StorageSize
INMODE0x0FPKA_CR6 bits
Operand length(in bits, not null)RAM@0x40864 bits
Operand A(0 ≤ A < n)RAM@0xA50ROS
Operand B(0 ≤ B < n)RAM@0xC68
Modulus value n(n < 2⁴¹⁶⁰)RAM@0x1088
OUTResult: A-B mod n(0 ≤ result < n)RAM@0xE78

63.4.5 Modular and Montgomery multiplication

To be more efficient when performing a sequence of multiplications the PKA accelerates multiplication which has at least one input in the Montgomery domain. The two main uses of this operation are:

The method to perform above operations are described below. Note that “x” function is this operation, and A, B, C operands are in the natural domain.

  1. 1. Inward (or outward) conversion into (or from) Montgomery domain
    1. a) Assuming that A is an integer in the natural domain:
    2. b) Assuming that BR is an integer in the Montgomery domain:
      • – Result B = BR × 1modn is B in the natural domain.
      • – Similarly, above value AR computed in a) can be converted into the natural domain by computing A = AR × 1modn.
  2. 2. Simple modular multiplication A × Bmodn
    1. a) Compute r2modn using Montgomery parameter computation.
    2. b) Compute AR = A × r2modnmodn. Output is in the Montgomery domain.
    3. c) Compute AB = AR × Bmodn. Output is in natural domain.
  3. 3. Multiple modular multiplication A × B × Cmodn
    1. a) Compute r2modn using Montgomery parameter computation.
    2. b) Compute AR = A × r2modnmodn. Output is in the Montgomery domain.
    3. c) Compute BR = B × r2modnmodn. Output is in the Montgomery domain.
    4. d) Compute ABR = AR × BRmodn. Output is in the Montgomery domain.
    5. e) Compute CR = C × r2modnmodn. Output is in the Montgomery domain.
    6. f) Compute ABCR = ABR × CRmodn. Output is in the Montgomery domain.
    7. g) (optional) Repeat the two steps above if more operands need to be multiplied.
    8. h) Compute ABC = ABCR × 1modn to retrieve the result in natural domain.

Operation instructions for Montgomery multiplication are summarized in Table 574.

Table 574. Montgomery multiplication

Parameters with directionValue (note)StorageSize
INMODE0x10PKA_CR6 bits
Operand length(in bits, not null)RAM@0x40864 bits
Operand A(0 ≤ A < n)RAM@0xA50ROS
Operand B(0 ≤ B < n)RAM@0xC68
Modulus value n(odd integer only, n < 2⁴¹⁶⁰)RAM@0x1088
OUTResult: \(A \times B \bmod n^{(1)}\)-RAM@0xE78
  1. 1. Result in Montgomery domain or in natural domain, depending upon the inputs nature (see examples 2 and 3).

63.4.6 Modular exponentiation

Modular exponentiation operation is commonly used to perform a single-step RSA operation. It consists in the computation of \(A^e \bmod n\).

RSA operation involving public information (RSA encryption) can use the normal or fast mode detailed on Table 575 and Table 576. RSA operation involving secret information (RSA decryption) must use the protected mode detailed on Table 577, for security reason.

Note: Once this operation is started PKA control register and PKA memory is no more available. Access is restored once BUSY bit is set to 0 by the PKA.

When this operation completes with errors due to unexpected hardware events a PKA tamper event is triggered to TAMP peripheral, and access to PKA RAM becomes blocked until erased by hardware.

Note: When MODE = 0x03, the error code is not affected when PKA automatically clears the PKA RAM at the end of this protected operation. When the error output equals 0xD60D, the result output is not affected either.

Operation instructions for modular exponentiation are summarized in Table 575 (normal mode), Table 576 (fast mode) and in Table 577 (protected mode). Fast mode usage is explained in Section 63.3.6.

Table 575. Modular exponentiation (normal mode)

Parameters with directionValue (note)StorageSize
INMODE0x00PKA_CR6 bits
INExponent length(in bits, not null)RAM@0x40064 bits
Operand length(in bits, not null)RAM@0x408
IN/OUTOperand A (base of exponentiation)(0 ≤ A < n)RAM@0xC68ROS
INExponent e(0 ≤ e < n)RAM@0xE78
Modulus value n(odd integer only, n < 2⁴¹⁶⁰)RAM@0x1088
OUTResult: \(A^e \bmod n\)(0 ≤ result < n)RAM@0x838

Table 576. Modular exponentiation (fast mode)

Parameters with directionValue (note)StorageSize
INMODE0x02PKA_CR6 bits
INExponent length(in bits, not null)RAM@0x40064 bits
Operand length(in bits, not null)RAM@0x408
IN/OUTOperand A (base of exponentiation)(0 ≤ A < n)RAM@0xC68ROS
INExponent e(0 ≤ e < n)RAM@0xE78
Modulus value n(odd integer only, n < 2⁴¹⁶⁰)RAM@0x1088
IN/OUTMontgomery parameter R2modn(mandatory)RAM@0x620
OUTResult: \(A^e \bmod n\)(0 ≤ result < n)RAM@0x838
Table 577. Modular exponentiation (protected mode)
Parameters with directionValue (note)StorageSize
INMODE0x03PKA_CR6 bits
Exponent e length(in bits, not null)RAM@0x40064 bits
Modulus or operand length(in bits, not null)RAM@0x408
Operand A (base of exponentiation)(0 ≤ A < n)RAM@0x16C8ROS
Exponent e(0 ≤ e < n)RAM@0x14B8
Modulus value n(odd integer only, n < 2⁴⁰⁹⁶)RAM@0x0838
Phi value(1)-RAM@0x0C68
OUTResult: \(A^e \bmod n\)(0 ≤ result < n)RAM@0x838
ERRORError \(A^e \bmod n\)No errors: 0xD60D
Errors: 0xCBC9
RAM@0x129864 bits

63.4.7 Modular inversion

Modular inversion operation consists in the computation of multiplicative inverse A⁻¹modn. If the modulus n is prime, for all values of A (1 ≤ A < n) modular inversion output is valid. If the modulus n is not prime, A has an inverse only if the greatest common divisor between A and n is 1.

If the operand A is a divisor of the modulus n the result is a multiple of a factor of n.

Operation instructions for modular inversion are summarized in Table 578.

Table 578. Modular inversion
Parameters with directionValue (note)StorageSize
INMODE0x08PKA_CR6 bits
Operand length(in bits, not null)RAM@0x40864 bits
Operand A(0 ≤ A < n)RAM@0xA50ROS
Modulus value n(odd integer only, n < 2⁴¹⁶⁰)RAM@0xC68
OUTResult: A⁻¹modn0 < result < nRAM@0xE78

63.4.8 Modular reduction

Modular reduction operation consists in the computation of the remainder of A divided by n. Operation instructions are summarized in Table 579.

Table 579. Modular reduction

Parameters with directionValue (note)StorageSize
INMODE0x0DPKA_CR6 bits
Operand length(in bits, not null)RAM@0x40064 bits
Modulus length(in bits, 8 < value < 4160)RAM@0x408
Operand A(0 ≤ A < 2n < 2⁴¹⁶⁰)RAM@0xA50ROS
Modulus value n(odd integer only, n < 2⁴¹⁶⁰)RAM@0xC68
OUTResult A mod n(0 < result < n)RAM@0xE78

63.4.9 Arithmetic addition

Arithmetic addition operation consists in the computation of A+B. Operation instructions are summarized in Table 580.

Table 580. Arithmetic addition

Parameters with directionValue (note)StorageSize
INMODE0x09PKA_CR6 bits
Operand length M(in bits, not null)RAM@0x40864 bits
Operand A\((0 \leq A < 2^M)\)RAM@0xA50
Operand B\((0 \leq B < 2^M)\)RAM@0xC68ROS
OUTResult: A+B\((0 \leq \text{result} < 2^{M+1})\)RAM@0xE78

63.4.10 Arithmetic subtraction

Arithmetic subtraction operation consists in the following computations:

For the last two bullets the 64-bit word following the most significant word of the output equals 0xFFFF FFFF FFFF FFFF, as result is negative.

Operation instructions are summarized in Table 581.

Table 581. Arithmetic subtraction

Parameters with directionValue (note)StorageSize
INMODE0x0APKA_CR6 bits
Operand length M(in bits, not null)RAM@0x40864 bits
Operand A\((0 \leq A < 2^M)\)RAM@0xA50
Operand B\((0 \leq B < 2^M)\)RAM@0xC68ROS
OUTResult: A-B\((0 \leq \text{result} < 2^M)\)RAM@0xE78

63.4.11 Arithmetic multiplication

Arithmetic multiplication operation consists in the computation of A × B. Operation instructions are summarized in Table 582.

Table 582. Arithmetic multiplication

Parameters with directionValue (note)StorageSize
INMODE0x0BPKA_CR6 bits
Operand length M(in bits, not null)RAM@0x40864 bits
Operand A\((0 \leq A < 2^M)\)RAM@0xA50ROS
Operand B\((0 \leq B < 2^M)\)RAM@0xC68
OUTResult: A × B\((0 \leq \text{result} < 2^{2M})\)RAM@0xE782xROS

63.4.12 Arithmetic comparison

Arithmetic comparison operation consists in the following computation:

Operation instructions for arithmetic comparison are summarized in Table 583.

Table 583. Arithmetic comparison

Parameters with directionValue (note)StorageSize
INMODE0x0CPKA_CR6 bits
Operand length M(in bits, not null)RAM@0x40864 bits
Operand A\((0 \leq A < 2^M)\)RAM@0xA50ROS
Operand B\((0 \leq B < 2^M)\)RAM@0xC68
OUTResult A?B0xED2C, 0x7AF8 or 0x916ARAM@0xE7864 bits

63.4.13 RSA CRT exponentiation

For efficiency many popular crypto libraries such as OpenSSL RSA use the following optimization for decryption and signing based on the chinese remainder theorem (CRT):

These values allow the recipient to compute the exponentiation \(m = A^d \pmod{pq}\) more efficiently as follows:

Operation instructions for computing CRT exponentiation \(A^d \pmod{pq}\) are summarized in Table 584.

Table 584. CRT exponentiation

Parameters with directionValue (note)StorageSize
INMODE0x07PKA_CR6 bits
INOperand length(in bits, not null)RAM@0x40864 bits
INOperand \(d_P\)\((0 < d_P < 2^{M/2})\)RAM@0x730ROS / 2
Operand \(d_Q\)\((0 < d_Q < 2^{M/2})\)RAM@0xE78
Operand \(q_{\text{inv}}\)\((0 < q_{\text{inv}} < 2^{M/2})\)RAM@0x948
Prime \(p^{(1)}\)\((0 < p < 2^{M/2})\)RAM@0xB60
Prime \(q^{(1)}\)\((0 < q < 2^{M/2})\)RAM@0x1088
INOperand A\((0 < A < 2^M)\)RAM@0x12A0ROS
OUTResult: \(A^d \pmod{pq}\)(0 ≤ result < pq)RAM@0x838

1. Must be different from 2.

63.4.14 Point on elliptic curve Fp check

This operation consists in checking whether a given point P (x, y) satisfies or not the curves over prime fields equation y² = (x³+ax+b) (mod p), where a and b are elements of the curve.

Operation instructions for point on elliptic curve Fp check are summarized in Table 585.

Table 585. Point on elliptic curve Fp check

Parameters with directionValue (note)StorageSize
INMODE0x28PKA_CR6 bits
Modulus length(in bits, not null,
8 < value < 640)
RAM@0x40864 bits
Curve coefficient a sign0x0: positive
0x1: negative
RAM@0x410
Curve coefficient |a|(absolute value, |a| < p)RAM@0x418EOS
Curve coefficient b(|b| < p)RAM@0x520
Curve modulus value p(odd integer prime,
0 < p < 2640)
RAM@0x470
Point P coordinate x(x < p)RAM@0x578
Point P coordinate y(y < p)RAM@0x5D0
Montgomery parameter
R2 mod n
-RAM@0x4C8
OUTResult: point P on curve0xD60D: point on curve
0xA3B7: point not on curve
0xF946: x or y coordinate is not
smaller than modulus p
RAM@0x68064 bits

63.4.15 ECC Fp scalar multiplication

This operation consists in the computation of \(k \times P (x_P, y_P)\), where P is a point on a curve over prime fields and “x” is the elliptic curve scalar point multiplication. Result of the computation is a point that belongs to the same curve or a point at infinity.

Operation instructions for ECC Fp scalar multiplication are summarized in Table 586.

Note: Once this operation is started PKA control register and PKA memory is no more available. Access is restored once BUSY bit is set to 0 by the PKA.

When this operation completes with errors due to unexpected hardware events, a PKA tamper event is triggered to TAMP peripheral, and access to PKA RAM becomes blocked until erased by hardware. PKA tamper is also triggered when the programmed input point is not found on the input ECC curve. PKA operation "Point on elliptic curve" can be used to avoid this.

Table 586. ECC Fp scalar multiplication

Parameters with directionValue (note)StorageSize
INMODE0x20PKA_CR6 bits
INCurve prime order n length(in bits, not null,)RAM@0x40064 bits
Curve modulus p length(in bits, not null,
8 < value < 640)
RAM@0x408
Curve coefficient a sign0x0: positive
0x1: negative
RAM@0x410

Table 586. ECC Fp scalar multiplication (continued)

Parameters with directionValue (note)StorageSize
INCurve coefficient |a|(absolute value, |a| < p)RAM@0x418EOS
Curve coefficient b(positive integer)RAM@0x520
Curve modulus value p(odd integer prime, 0 < p < 2⁶⁴⁰)RAM@0x1088
Scalar multiplier k(0 ≤ k < 2⁶⁴⁰)RAM@0x12A0
Point P coordinate \(x_P\)(x < p)RAM@0x578
Point P coordinate \(y_P\)(y < p)RAM@0x470
Curve prime order n(integer prime)RAM@0xF88
OUTResult: k × P coordinate \(x'\)(result < p)RAM@0x578
Result: k × P coordinate \(y'\)(result < p)RAM@0x5D0
ERRORError k × PNo errors: 0xD60D
Errors: 0xCBC9
RAM@0x68064 bits

When performing this operation the following special cases must be noted:

Note: The error code is not affected when PKA automatically clears the PKA RAM at the end of this protected operation. When the error output equals 0xD60D, the result output is not affected either.

63.4.16 ECDSA sign

ECDSA signing operation (outlined in Section 63.3.5) is summarized in Table 587 (input parameters) and in Table 588 (output parameters).

The application has to check if the output error is equal to 0xD60D, if it is different a new k must be generated and the ECDSA sign operation must be repeated.

Note: Once this operation is started PKA control register and PKA memory is no more available. Access is restored once BUSY bit is set to 0 by the PKA.

When this operation completes with errors due to unexpected hardware events a PKA tamper event is triggered to TAMP peripheral, and access to PKA RAM becomes blocked until erased by hardware. PKA tamper is also triggered when the programmed input point is not found on the input ECC curve. PKA operation "Point on elliptic curve" can be used to avoid this.

Table 587. ECDSA sign - Inputs

Parameters with directionValue (note)StorageSize
INMODE0x24PKA_CR6 bits
Curve prime order n length (n/len)(in bits, not null)RAM@0x40064 bits
Curve modulus p length(in bits, 8 < value < 640)RAM@0x408
Curve coefficient a sign0x0: positive
0x1: negative
RAM@0x410
Curve coefficient |a|(absolute value, |a| < p)RAM@0x418EOS
Curve coefficient b(positive integer)RAM@0x520
Curve modulus value p(odd integer prime, 0 < p < 2⁶⁴⁰)RAM@0x1088
Integer \(k^{(1)}\)(0 ≤ k < 2⁶⁴⁰)RAM@0x12A0
Curve base point G coordinate x(x < p)RAM@0x578
Curve base point G coordinate y(y < p)RAM@0x470
Hash of message z(hash size equal to n/len)(2)RAM@0xFE8
Private key d(0 < d)RAM@0xF28
Curve prime order n(integer prime)RAM@0xF88
  1. 1. This integer is usually a cryptographically secure random number, but in some cases k can be deterministically generated.
  2. 2. Padding with zeroes or hash truncation must be used to have the hash parameter size equal to the curve prime order n length.

Table 588. ECDSA sign - Outputs

Parameters with directionValue (note)StorageSize
OUTSignature part r(0 < r < n)RAM@0x730EOS
Signature part s(0 < s < n)RAM@0x788
ERRORResult of signature0xD60D: successful computation, no error
0xCBC9: failed computation
0xA3B7: signature part r is equal to 0
0xF946: signature part s is equal to 0
RAM@0xFE064 bits

Note: The error code is not affected when PKA automatically clears the PKA RAM at the end of this protected operation. When the error output equals 0xD60D, the result output is not affected either.

Extended ECDSA support

PKA also supports extended ECDSA signature, for which the inputs and the outputs are the same as ECDSA signature (Table 587 and Table 588, respectively), with the addition of the coordinates of the point kG. This extra output is defined in Table 589.

Table 589. Extended ECDSA sign - Extra outputs

Parameters with directionValue (note)StorageSize
OUTCurve point kG coordinate x₁(0 ≤ x₁ < p)RAM@0x1400EOS
Curve point kG coordinate y₁(0 ≤ y₁ < p)RAM@0x1458

63.4.17 ECDSA verification

ECDSA verification operation (outlined in Section 63.3.5) is summarized in Table 590 (input parameters) and Table 591 (output parameters).

The application has to check if the output error is equal to 0xD60D, if different the signature is not verified.

Table 590. ECDSA verification - Inputs

Parameters with directionValue (note)StorageSize
INMODE0x26PKA_CR6 bits
Curve prime order n length (n/len)(in bits, not null)RAM@0x40864 bits
Curve modulus p length(in bits, not null, 8 < value < 640)RAM@0x4C8
Curve coefficient a sign0x0: positive
0x1: negative
RAM@0x468
Curve coefficient |a|(absolute value, |a| < p)RAM@0x470EOS
Curve modulus value p(odd integer prime, 0 < p < 2⁶⁴⁰)RAM@0x4D0
Curve base point G coordinate x(x < p)RAM@0x678
Curve base point G coordinate y(y < p)RAM@0x6D0
Public-key curve point Q coordinate \(x_Q\)\((x_Q < p)\)RAM@0x12F8
Public-key curve point Q coordinate \(y_Q\)\((y_Q < p)\)RAM@0x1350
Signature part r(0 < r < n)RAM@0x10E0
Signature part s(0 < s < n)RAM@0xC68
Hash of message z(hash size equal to n/len)(1)RAM@0x13A8
Curve prime order n(integer prime)RAM@0x1088

1. Padding with zeroes or hash truncation must be used to have the hash parameter size equal to the curve prime order n length.

Table 591. ECDSA verification - Outputs

Parameters with directionValue (note)StorageSize
OUTResult: ECDSA verify– 0xD60D: valid signature
– 0xA3B7: invalid signature
RAM@0x5D064 bits
Computed signature part r– (0 < r < n)RAM@0x578EOS

63.4.18 ECC complete addition

ECC complete addition computes the addition of two given points on an elliptic curve.

Operation instructions are summarized in Table 592.

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 592. ECC complete addition

Parameters with directionValue (note)StorageSize
INMODE0x23PKA_CR6 bits
Curve modulus p length(in bits, not null,
8 < value < 640)
RAM@0x40864 bits
Curve coefficient a sign– 0x0: positive
0x1: negative
RAM@0x410
Curve modulus value p(odd integer prime,
0 < p < 2⁶⁴⁰)
RAM@0x470EOS
Curve coefficient |a|(absolute value, |a| < p)RAM@0x418
First point P coordinate X(x < p)RAM@0x628
First point P coordinate Y(y < p)RAM@0x680
First point P coordinate Z(z < p)RAM@0x6D8
Second point Q coordinate X(x < p)RAM@0x730
Second point Q coordinate Y(y < p)RAM@0x788
OUTResult coordinate X(x < p)RAM@0xD60
Result coordinate Y(y < p)RAM@0xDB8
Result coordinate Z(z < p)RAM@0xE10

63.4.19 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 in Table 593.

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).

This operation requires the input point Z coordinate to be equal to 1 (input point represented in affine coordinates).

Table 593. ECC double base ladder
Parameters with directionValue (note)StorageSize
INMODE0x27PKA_CR6 bits
Curve prime order n length(in bits, not null)RAM@0x40064 bits
Curve modulus p length(in bits, not null, 8 < value < 640)RAM@0x408
Curve coefficient a sign– 0x0: positive
– 0x1: negative
RAM@0x410EOS
Curve coefficient |a|(absolute value, |a| < p)RAM@0x418
Curve modulus value p(odd integer prime, 0 < p < 2⁶⁴⁰)RAM@0x470
Integer k(0 < k < 2⁶⁴⁰)RAM@0x520
Integer m(0 < m < 2⁶⁴⁰)RAM@0x578
First point P coordinate X(x < p)RAM@0x628
First point P coordinate Y(y < p)RAM@0x680
First point P coordinate Z(z < p)RAM@0x6D8
Second point Q coordinate X(x < p)RAM@0x730
Second point Q coordinate Y(y < p)RAM@0x788
Second point Q coordinate Z(z < p)RAM@0x7E0
OUTResult coordinate x(x < p)RAM@0x578EOS
Result coordinate y(y < p)RAM@0x5D0
Error code– Point not at infinity: 0xD60D
– Point at infinity: 0xA3B7
RAM@0x52064 bits

63.4.20 ECC projective to affine

ECC projective to affine operation computes the conversion between the representation of a point P in homogeneous projective coordinates and the representation of the point P in affine coordinates. Namely, if the point is represented by the triple (X, Y, Z), it computes the affine coordinates (x, y) = (X/Z, Y/Z).

All the operations are performed modulo the modulus p of the curve, which the point belongs to. If the resulting point is the point at infinity (error code 0xA3B7), resulting coordinate equals (0,0).

Operation instructions are summarized in Table 594.

Table 594. ECC projective to affine

Parameters with directionValue (note)StorageSize
MODE0x2FPKA_CR6 bits
INCurve modulus p length(in bits, 8 < value < 640)RAM@0x40864 bits
Curve modulus value p(odd integer prime,
0 < p < 2640)
RAM@0x470EOS
Point P coordinate X (projective)(x < p)RAM@0xD60
Point P coordinate Y (projective)(y < p)RAM@0xDB8
Point P coordinate Z (projective)(z < p)RAM@0xE10
Montgomery parameter R2 mod n-RAM@0x4C8
OUTPoint P coordinate x (affine)(x < p)RAM@0x578
Point P coordinate y (affine)(y < p)RAM@0x5D0
ERRORError codePoint not at infinity: 0xD60D
Point at infinity: 0xA3B7
RAM@0x68064 bits

63.5 Example of configurations and processing times

63.5.1 Supported elliptic curves

The PKA supports all non-singular elliptic curves defined over prime fields. Those curves can be described with a short Weierstrass equation, y2 = x3 + ax + b (mod p).

Note: Binary curves, Edwards curves and Curve25519 are not supported by the PKA.
The maximum supported operand size for ECC operations is 640 bits.

When publishing the ECC domain parameters of those elliptic curves, standard bodies define the following parameters:

For the last bullet, when standard bodies define a as negative, PKA supports two representations:

  1. 1. a defined as p-|a| in the finite field GF(p), for example p-3:
    Curve coefficient p = 0xFFFFFFFE FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF 00000000 FFFFFFFF FFFFFFFF
    Curve coefficient a sign= 0x0 (positive)
    Curve coefficient a = 0xFFFFFFFE FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF 00000000 FFFFFFFF FFFFFFFC
  2. 2. a defined as negative, for example -3:
    Curve coefficient p = 0xFFFFFFFE FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF 00000000 FFFFFFFF FFFFFFFF
    Curve coefficient a sign= 0x1 (negative)
    Curve coefficient a = 0x00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000003

Table 595 summarizes the family of curves supported by PKA for ECC operations.

Table 595. Family of supported curves for ECC operations

Curve nameStandardReference
P-192NISTDigital Signature Standard (DSS), NIST FIPS 186-4
P-224
P-256
P-384
P-521
brainpoolP224r1,
brainpoolP224t1
IETF
  • – Brainpool Elliptic Curves, IETF RFC 5639
  • – Brainpool Elliptic Curves for the Internet Key Exchange (IKE) Group Description Registry, IETF RFC 6932
https://tools.ietf.org
brainpoolP256r1,
brainpoolP256t1
brainpoolP320r1,
brainpoolP320t1
brainpoolP384r1,
brainpoolP384t1
brainpoolP512r1,
brainpoolP512t1
secp192k1, secp192r1SECStandards for Efficient Cryptography SEC 2 curveshttps://www.secg.org
secp224k1, secp224r1
secp256k1, secp256r1
secp384r1
secp521r1
Recommended curve parameters for public key cryptographic algorithm SM2OSCCA
  • – Public key cryptographic algorithm SM2 based on elliptic curves, Organization of State Commercial Administration of China OSCCA SM2, December 2010
  • – Digital signatures - Part 3 Discrete logarithm based mechanisms, ISO/IEC 14888-3, November 2018

63.5.2 Computation times

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

Table 596. Modular exponentiation

Exponent length
(in bits)
ModeModulus length (in bits)
1024204830724096
3Normal66000242000310000503000
Fast7000230004800082000
17Normal69000253000333000543000
Fast240003400072000123000
2¹⁶+1Normal82000296000427000705000
Fast2300078000165000284000
1024Protected2960000---
Normal1725000---
Fast1666000---
CRT(1)595000---
2048Protected-17643000--
Normal-11553000--
Fast-11334000--
CRT(1)-3454000--
3072Protected--53390000-
Normal--36280000-
Fast--36019000-
CRT(1)--10328000-
4096Protected---119824000
Normal---82619000
Fast---82198000
CRT(1)---23061000

1. CRT stands for chinese remainder theorem optimization (MODE bitfield= 0x07).

Table 597. ECC scalar multiplication(1)

Modulus length (in bits)
160192256320384512521640
-7420001220000211600030310005981000784400010200000

1. These times depend on the number of 1s included in the scalar parameter, and include the computation of Montgomery parameter R2.

Table 598. ECDSA signature average computation time(1) (2)
Modulus length (in bits)
160192256320384512521640
-633000108700017080002548000485600059780008030000
  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 599. ECDSA verification average computation times
Modulus length (in bits)
160192256320384512521640
566000676000122100019570002967000582500070960009773000
Table 600. ECC double base ladder average computation times
Modulus length (in bits)
160192256320384512521640
541000644000115200018730002814000550600067530009350000
Table 601. ECC projective to affine average computation times
Modulus length (in bits)
160192256320384512640
24700320005600090000144000271000326000
Table 602. ECC complete addition average computation times
Modulus length (in bits)
160192256320384512640
800082001050013000194002960039000
Table 603. Point on elliptic curve Fp check average computation times
Modulus length (in bits)
160192256320384512521640
22002240287035504400626074608500
Table 604. Montgomery parameters average computation times(1)
Modulus length (in bits)
1922563205121024204830724096
4200520059001260035500126500290000420000
  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.

63.6 PKA interrupts

There are four individual maskable interrupt sources generated by the public key accelerator, signaling the following events:

  1. 1. PKA unsupported operation error (OPERRF), see Section 63.3.7
  2. 2. Access to unmapped address (ADDRERRF), see Section 63.3.7
  3. 3. PKA RAM access while PKA operation is in progress (RAMERRF), see Section 63.3.7
  4. 4. PKA end of operation (PROCENDF)

The 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 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.

Table 605 gives a summary of the available features.

Table 605. PKA interrupt requests
AcronymEventEvent flagEnable control bitClear method
PKAUnsupported operationOPERRFOPERRIESet OPERRFC bit
Access to unmapped address errorADDRERRFADDRERRIESet ADDRERRFC bit
PKA RAM access errorRAMERRFRAMERRIESet RAMERRFC bit
PKA end of operationPROCENDFPROCENDIESet PROCENDFC bit

63.7 PKA registers

63.7.1 PKA control register (PKA_CR)

Address offset: 0x00

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.OP
ERRIE
ADDR
ERRIE
RAM
ERRIE
Res.PROC
ENDIE
Res.
rwrwrwrw
1514131211109876543210
Res.Res.MODE[5:0]Res.Res.Res.Res.Res.Res.STARTEN
rwrwrwrwrwrwrwrw

Bits 31:22 Reserved, must be kept at reset value.

Bit 21 OPERRIE: Operation error interrupt enable

0: No interrupt is generated when OPERRF flag is set in PKA_SR.

1: An interrupt is generated when OPERRF flag is set in PKA_SR.

Bit 20 ADDRERRIE: Address error interrupt enable

0: No interrupt is generated when ADDRERRF flag is set in PKA_SR.

1: An interrupt is generated when ADDRERRF flag is set in PKA_SR.

Bit 19 RAMERRIE: RAM error interrupt enable

0: No interrupt is generated when RAMERRF flag is set in PKA_SR.

1: An interrupt is generated when RAMERRF flag is set in PKA_SR.

Bit 18 Reserved, must be kept at reset value.

Bit 17 PROCENDIE: End of operation interrupt enable

0: No interrupt is generated when PROCENDF flag is set in PKA_SR.

1: An interrupt is generated when PROCENDF flag is set in PKA_SR.

Bits 16:14 Reserved, must be kept at reset value.

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

When an operation not listed here is written by the application with EN bit set, OPERRF bit is set in PKA_SR register, and the write to MODE bitfield is ignored. When PKA is configured in limited mode (LMF = 1 in PKA_SR), writing a MODE different from 0x26 with EN bit to 1 triggers OPERRF bit to be set and write to MODE bit is ignored.

Bits 7:2 Reserved, must be kept at reset value.

Bit 1 START: start the operation

Set this bit to start the operation selected by the MODE[5:0] bitfield, using the operands and data already written to the PKA RAM. This bit is always read as 0.

When an illegal operation is selected while START bit is set no operation is started, and OPERRF bit is set in PKA_SR.

Note: START is ignored if PKA is busy.

Bit 0 EN: PKA enable

0: Disable PKA

1: Enable PKA. PKA becomes functional when INITOK is set by hardware in PKA_SR.

When an illegal operation is selected while EN = 1, OPERRF bit is set in PKA_SR. See PKA_CR.MODE bitfield for details.

Note: When EN = 0, PKA RAM can still be accessed by the application.

63.7.2 PKA status register (PKA_SR)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.OP
ERRF
ADDR
ERRF
RAM
ERRF
Res.PROC
ENDF
BUSY
rrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.LMFINITOK
rr

Bits 31:22 Reserved, must be kept at reset value.

Bit 21 OPERRF: Operation error flag

0: No event error

1: An illegal or unknown operation has been selected in PKA_CR register

This bit is cleared using OPERRFC bit in PKA_CLRFR.

Bit 20 ADDRERRF: Address error flag

0: No address error

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

This bit is cleared using ADDRERRFC bit in PKA_CLRFR.

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).

This bit is cleared using RAMERRFC bit in PKA_CLRFR.

Bit 18 Reserved, must be kept at reset value.

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 deasserted.

Bit 16 BUSY: Busy flag

This bit is set whenever a PKA operation is in progress (START = 1 in PKA_CR). It is automatically cleared when the computation is complete, making PKA RAM accessible again.

0: No operation is in progress (default)

1: An operation is in progress

If PKA is started with a wrong opcode, it stays busy for a couple of cycles, then it aborts automatically the operation and goes back to ready (BUSY = 0).

Bits 15:2 Reserved, must be kept at reset value.

Bit 1 LMF: Limited mode flag

This bit is updated when EN bit in PKA_CR is set

0: All values documented in MODE bitfield can be used.

1: Only ECDSA verification (MODE = 0x26) is supported by the PKA.

Bit 0 INITOK: PKA initialization OK

This bit is asserted when PKA initialization is complete.

0: PKA is not initialized correctly. START bit cannot be set.

1: PKA is initialized correctly and can be used normally.

Note: When RNG is not able to output proper random numbers or when SAES is using the RNG bus, INITOK remains at 0. If it happens, make sure the RNG peripheral is properly clocked and initialized, and the SAES peripheral is clocked with BUSY bit cleared in SAES_SR to release the RNG bus, then enable PKA again.

63.7.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.OP
ERRFC
ADDR
ERRFC
RAM
ERRFC
Res.PROC
ENDFC
Res.
wwww
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.

Bits 31:22 Reserved, must be kept at reset value.

Bit 21 OPERRFC: Clear operation error flag

0: No action

1: Clear the OPERRF flag in PKA_SR

Bit 20 ADDRERRFC: Clear address error flag

0: No action

1: Clear the ADDRERRF flag in PKA_SR

Bit 19 RAMERRFC: Clear PKA RAM error flag

0: No action

1: Clear the RAMERRF flag in PKA_SR

Bit 18 Reserved, must be kept at reset value.

Bit 17 PROCENDFC: Clear PKA end of operation flag

0: No action

1: Clear the PROCENDF flag in PKA_SR

Bits 16:0 Reserved, must be kept at reset value.

Note: Reading PKA_CLRFR returns all 0s.

63.7.4 PKA RAM

The PKA RAM is mapped at the offset address of 0x0400 compared to the PKA base address. Only 32-bit word single accesses are supported, through PKA.AHB interface.

RAM size is 5336 bytes (max word offset: 0x14D0)

Note: PKA RAM cannot be used just after a PKA reset or a product reset, as described in Section 63.3.3: PKA reset and clocks.

63.7.5 PKA hardware configuration register (PKA_HWCFGR)

Address offset: 0x1FF0

Reset value: 0x0000 0011

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.CFG2[3:0]CFG1[3:0]
rrrrrrrr

Bits 31:8 Reserved, must be kept at reset value.

Bits 7:4 CFG2[3:0]: HW Generic 2

This field returns the DPAEN generic value (0x1)

Bits 3:0 CFG1[3:0]: HW Generic 2

This field returns the PKA64_SEL generic value (0x1)

63.7.6 PKA version register (PKA_VERR)

Address offset: 0x1FF4

Reset value: 0x0000 0011

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.MAJREV[3:0]MINREV[3:0]
rrrrrrrr

Bits 31:8 Reserved, must be kept at reset value.

Bits 7:4 MAJREV[3:0]: Major revision

This field returns the PKA major version.

Bits 3:0 MINREV[3:0]: Minor revision

This field returns the PKA minor version.

63.7.7 PKA identification register (PKA_IPIDR)

Address offset: 0x1FF8

Reset value: 0x0017 0072

31302928272625242322212019181716
ID[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
ID[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 ID[31:0]: Identification code

This field returns the PKA identification code.

63.7.8 PKA size identification register (PKA_SIDR)

Address offset: 0x1FFC

Reset value: 0xA3C5 DD08

31302928272625242322212019181716
SID[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
SID[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 SID[31:0]: Size identification code

This field returns the size identification code of the PKA as defined below:

Bits[31:8] = 0xA3C5DD (fixed code)

Bits[7:0] = 0x08 (8 KB address decoding)

63.7.9 PKA register map

Table 606. PKA register map and reset values
OffsetRegister name313029282726252423222120191817161514131211109876543210
0x000PKA_CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.OPERRIEADDRERIERAMERIERes.PROCENDIERes.Res.Res.MODE[5:0]Res.Res.Res.Res.Res.Res.STARTEN
Reset value000000000000
0x004PKA_SRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.OPERRFADDRERFRAMERFRes.PROCENDFBUSYRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.LMFINITOK
Reset value0000000
0x008PKA_CLRFRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.OPERRFCADDRERFCRAMERRFCRes.PROCENDFCRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0000
0x1FF0PKA_HWCFGRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CFG2[3:0]CFG1[3:0]
Reset value00010001
0x1FF4PKA_VERRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.MAJREV
[3:0]
MINREV
[3:0]
Reset value00010001
0x1FF8PKA_IPIDRID[31:0]
Reset value00000000000101110000000001100010
0x1FFCPKA_SIDRSID[31:0]
Reset value10100011110001011101000100001000

Refer to Section 2.4 on page 228 for the register boundary addresses.