embassy-nrf

Crates

git

Versions

nrf9151-s

Flavors

Skip to main content

Module pka

Module pka 

Source
Expand description

Public key accelerator.

The driver runs on the PKA engine of the CryptoCell (nRF52840, nRF91, nRF5340) or the public key engine of CRACEN (nRF54L). It provides:

  • ECDSA signature generation and verification.
  • ECDH and public key derivation, through scalar multiplication of a curve point.
  • RSA, through modular exponentiation, with or without the Chinese remainder theorem.

Curve points, scalars, moduli and signatures are big-endian byte slices, as in SEC 1 and PKCS#1.

  • Every value of a curve operation must be exactly Curve::size bytes long. Pad it with zeros on the left if needed.
  • Every value of an RSA operation must be at most as long as the modulus.

§Example

use embassy_nrf::crypto::pka::{Pka, PointMut, curve};

// On CRACEN (nRF54L) the constructor also takes the engine microcode.
let mut pka = Pka::new_blocking(p.CRYPTO_PKA);

// Derive the public key of a private key.
let mut x = [0; 32];
let mut y = [0; 32];
pka.blocking_public_key(&curve::NIST_P256, &private_key, PointMut { x: &mut x, y: &mut y })?;

Modules§

curve
Domain parameters of common elliptic curves.

Structs§

Curve
Domain parameters of a short Weierstrass curve y² = x³ + a·x + b over a prime field.
Pka
Driver for the public key accelerator.
Point
A curve point in affine coordinates.
PointMut
Buffers receiving a curve point in affine coordinates.
Signature
An ECDSA signature.
SignatureMut
Buffers receiving an ECDSA signature.

Enums§

Error
PKA error.

Constants§

MAX_CURVE_LEN
Largest curve size in bytes that the driver accepts. This fits NIST P-521.
MAX_MODULUS_LEN
Largest modulus in bytes that the driver accepts. This fits RSA-4096.