Expand description
§embassy-crypto-driver
embassy-crypto provides universal optimized implementations of cryptographic functions,
targeted for embedded systems. This crate defines the driver interface for these functions.
Hardware-agnostic crypto driver unitraits for the Embassy ecosystem.
This crate defines a set of unitrait! traits that abstract over
hardware-accelerated (or software) cryptographic operations. Each trait
declares an opaque context type and a set of functions with stable C
linkage symbols, allowing exactly one driver implementation to be selected
at link time.
§Supported Operations
§Digests
Md5,Sha1,Sha224,Sha256,Sha384,Sha512,Sha512_224,Sha512_256
§HMAC
HmacSha1,HmacSha224,HmacSha256,HmacSha384,HmacSha512,HmacSha512_224,HmacSha512_256
§Block Ciphers
Aes128Ecb,Aes256Ecb— ECB modeAes128Cbc,Aes256Cbc— CBC mode
§AEAD
Aes128Gcm,Aes256Gcm— GCM modeAes128Ccm,Aes256Ccm— CCM mode
§Elliptic Curve (P256)
P256Ecdh— key generation, public-key derivation, and shared-secret computation for TLS and Bluetooth LE Secure ConnectionsP256Ecdsa— sign and verify pre-hashed digests for TLS certificate authentication
§Elliptic Curve (P384)
P384Ecdh— key generation, public-key derivation, and shared-secret computation for TLSP384Ecdsa— sign and verify pre-hashed digests for TLS certificate authentication
§X25519 (Curve25519)
X25519— key generation, public-key derivation, and X25519 shared-secret computation for TLS 1.3 ECDHE
§High-level EC operations
P256Ec— combined P-256 ECDH + ECDSA unitrait servingembassy-crypto’sasymmetricmoduleP384Ec— combined P-384 ECDH + ECDSA unitrait servingembassy-crypto’sasymmetric::p384module
§Driver Registration
A HAL crate registers itself by invoking the generated *_impl! macro
for each supported algorithm. Only one crate in the dependency tree may
register a driver for any given algorithm; otherwise linking will fail.
Macros§
- aes128cbc_
impl - aes128ccm_
impl - aes128cmac_
impl - aes128ctr_
impl - aes128ecb_
impl - aes128gcm_
impl - aes256cbc_
impl - aes256ccm_
impl - aes256cmac_
impl - aes256ctr_
impl - aes256ecb_
impl - aes256gcm_
impl - hmac_
sha1_ impl - hmac_
sha224_ impl - hmac_
sha256_ impl - hmac_
sha384_ impl - hmac_
sha512_ 224_ impl - hmac_
sha512_ 256_ impl - hmac_
sha512_ impl - md5_
impl - p256_
ec_ impl - p256_
lincomb_ impl - p256_
scalar_ invert_ impl - p256_
scalar_ mul_ impl - p384_
ec_ impl - p384_
lincomb_ impl - p384_
scalar_ invert_ impl - p384_
scalar_ mul_ impl - sha1_
impl - sha224_
impl - sha256_
impl - sha384_
impl - sha512_
224_ impl - sha512_
256_ impl - sha512_
impl - x25519_
impl
Structs§
- Aes128
CbcImpl - The global
Aes128Cbcimplementation. - Aes128
CbcImpl Decrypt Context - Opaque storage for the decryptor’s key schedule and chaining state.
- Aes128
CbcImpl Encrypt Context - Opaque storage for the encryptor’s key schedule and chaining state.
- Aes128
CcmImpl - The global
Aes128Ccmimplementation. - Aes128
CcmImpl Context - Opaque storage for the implementation’s key schedule.
- Aes128
Cmac Impl - The global
Aes128Cmacimplementation. - Aes128
Cmac Impl Context - Opaque storage for the implementation’s CMAC state.
- Aes128
CtrImpl - The global
Aes128Ctrimplementation. - Aes128
CtrImpl Context - Opaque storage for key schedule, counter state, and partial-block buffer.
- Aes128
EcbImpl - The global
Aes128Ecbimplementation. - Aes128
EcbImpl Context - Opaque storage for the implementation’s key schedule.
- Aes128
GcmImpl - The global
Aes128Gcmimplementation. - Aes128
GcmImpl Context - Opaque storage for the implementation’s key schedule.
- Aes256
CbcImpl - The global
Aes256Cbcimplementation. - Aes256
CbcImpl Decrypt Context - Opaque storage for the decryptor’s key schedule and chaining state.
- Aes256
CbcImpl Encrypt Context - Opaque storage for the encryptor’s key schedule and chaining state.
- Aes256
CcmImpl - The global
Aes256Ccmimplementation. - Aes256
CcmImpl Context - Opaque storage for the implementation’s key schedule.
- Aes256
Cmac Impl - The global
Aes256Cmacimplementation. - Aes256
Cmac Impl Context - Opaque storage for the implementation’s CMAC state.
- Aes256
CtrImpl - The global
Aes256Ctrimplementation. - Aes256
CtrImpl Context - Aes256
EcbImpl - The global
Aes256Ecbimplementation. - Aes256
EcbImpl Context - Opaque storage for the implementation’s key schedule.
- Aes256
GcmImpl - The global
Aes256Gcmimplementation. - Aes256
GcmImpl Context - Opaque storage for the implementation’s key schedule.
- Hmac
Sha1 Impl - The global
HmacSha1implementation. - Hmac
Sha1 Impl Context - Opaque storage for the implementation’s hash state.
- Hmac
Sha224 Impl - The global
HmacSha224implementation. - Hmac
Sha224 Impl Context - Opaque storage for the implementation’s hash state.
- Hmac
Sha256 Impl - The global
HmacSha256implementation. - Hmac
Sha256 Impl Context - Opaque storage for the implementation’s hash state.
- Hmac
Sha384 Impl - The global
HmacSha384implementation. - Hmac
Sha384 Impl Context - Opaque storage for the implementation’s hash state.
- Hmac
Sha512 Impl - The global
HmacSha512implementation. - Hmac
Sha512 Impl Context - Opaque storage for the implementation’s hash state.
- Hmac
Sha512_ 224Impl - The global
HmacSha512_224implementation. - Hmac
Sha512_ 224Impl Context - Opaque storage for the implementation’s hash state.
- Hmac
Sha512_ 256Impl - The global
HmacSha512_256implementation. - Hmac
Sha512_ 256Impl Context - Opaque storage for the implementation’s hash state.
- InOut
Buf - A lightweight I/O buffer abstraction without depending on the RustCrypto
inoutcrate. - Md5Impl
- The global
Md5implementation. - Md5Impl
Context - Opaque storage for the implementation’s hash state.
- NotEqual
Error - Error returned when a pair of input/output slices have unequal lengths.
- P256
Affine Point - Canonical P-256 affine point: big-endian (x, y), uncompressed.
- P256
EcImpl - The global
P256Ecimplementation. - P256
Lincomb Impl - The global
P256Lincombimplementation. - P256
Scalar - Canonical P-256 scalar: big-endian, 32 bytes.
- P256
Scalar Invert Impl - The global
P256ScalarInvertimplementation. - P256
Scalar MulImpl - The global
P256ScalarMulimplementation. - P256
Signature - Raw P-256 ECDSA signature: canonical
(r, s), each 32 bytes big-endian. - P384
Affine Point - Canonical P-384 affine point: big-endian (x, y), uncompressed.
- P384
EcImpl - The global
P384Ecimplementation. - P384
Lincomb Impl - The global
P384Lincombimplementation. - P384
Scalar - Canonical P-384 scalar: big-endian, 48 bytes.
- P384
Scalar Invert Impl - The global
P384ScalarInvertimplementation. - P384
Scalar MulImpl - The global
P384ScalarMulimplementation. - P384
Signature - Sha1
Impl - The global
Sha1implementation. - Sha1
Impl Context - Opaque storage for the implementation’s hash state.
- Sha224
Impl - The global
Sha224implementation. - Sha224
Impl Context - Opaque storage for the implementation’s hash state.
- Sha256
Impl - The global
Sha256implementation. - Sha256
Impl Context - Opaque storage for the implementation’s hash state.
- Sha384
Impl - The global
Sha384implementation. - Sha384
Impl Context - Opaque storage for the implementation’s hash state.
- Sha512
Impl - The global
Sha512implementation. - Sha512
Impl Context - Opaque storage for the implementation’s hash state.
- Sha512_
224Impl - The global
Sha512_224implementation. - Sha512_
224Impl Context - Opaque storage for the implementation’s hash state.
- Sha512_
256Impl - The global
Sha512_256implementation. - Sha512_
256Impl Context - Opaque storage for the implementation’s hash state.
- X25519
Impl - The global
X25519implementation. - X25519
Private Key - An X25519 private key: 32-byte Curve25519 scalar, little-endian.
- X25519
Public Key - An X25519 public key: 32-byte Curve25519 u-coordinate, little-endian (RFC 7748).
Enums§
- Crypto
Error - Error type for crypto operations.
Traits§
- Aes128
Cbc - AES-128 CBC block cipher trait.
- Aes128
Ccm - AES-128 CCM AEAD trait.
- Aes128
Cmac - AES-128 CMAC (Cipher-based Message Authentication Code) trait.
- Aes128
Ctr - AES-128 CTR stream cipher trait.
- Aes128
Ecb - AES-128 ECB block cipher trait.
- Aes128
Gcm - AES-128 GCM AEAD trait.
- Aes256
Cbc - AES-256 CBC block cipher trait.
- Aes256
Ccm - AES-256 CCM AEAD trait.
- Aes256
Cmac - AES-256 CMAC (Cipher-based Message Authentication Code) trait.
- Aes256
Ctr - AES-256 CTR stream cipher trait.
- Aes256
Ecb - AES-256 ECB block cipher trait.
- Aes256
Gcm - AES-256 GCM AEAD trait.
- Hmac
Sha1 - Sha1 trait
- Hmac
Sha224 - Sha224 trait
- Hmac
Sha256 - Sha256 trait
- Hmac
Sha384 - Sha384 trait
- Hmac
Sha512 - Sha512 trait
- Hmac
Sha512_ 224 - Sha512_224 trait
- Hmac
Sha512_ 256 - Sha512_256 trait
- Md5
- Md5 trait
- P256Ec
- High-level P-256 operations for TLS 1.3 and BLE Secure Connections.
- P256
Lincomb - P-256 double-base scalar multiplication accelerator (optional).
- P256
Scalar Invert - P-256 scalar field inversion accelerator (optional).
- P256
Scalar Mul - P-256 scalar multiplication accelerator.
- P384Ec
- High-level P-384 operations for TLS 1.3.
- P384
Lincomb - P-384 double-base scalar multiplication accelerator (optional).
- P384
Scalar Invert - P-384 scalar field inversion accelerator (optional).
- P384
Scalar Mul - P-384 scalar multiplication accelerator.
- Rng
- Caller-provided entropy source for crypto operations that need fresh randomness (ECDSA nonces, ephemeral key generation).
- Sha1
- Sha1 trait
- Sha224
- Sha224 trait
- Sha256
- Sha256 trait
- Sha384
- Sha384 trait
- Sha512
- Sha512 trait
- Sha512_
224 - Sha512_224 trait
- Sha512_
256 - Sha512_256 trait
- X25519
- X25519 (Curve25519) ECDH operations for TLS 1.3.