Fallible WS63 hardware/ROM backend for the chip-neutral hisi-crypto
capability traits.
The current surface contains explicitly owned hardware capabilities:
Ws63Crypto::newconsumesWs63CryptoResources, which binds the HALKm,Spacc, andTrngperipheral tokens to caller-owned staticWs63CryptoStorage.- PBKDF2-HMAC-SHA1 drives the PAC-modeled RKP engine directly with bounded lock and completion polling, key/salt/output-window clearing, and no dependency on a vendor security archive or global UAPI symbol.
- SHA-1/SHA-256/SM3 and HMAC-SHA1/HMAC-SHA256/HMAC-SM3 drive the PAC-modeled SPACC hash
channel with bounded lock/clear/completion polling, aligned DMA descriptors,
explicit D-cache maintenance, and secret-buffer clearing. SM3 uses the typed
algorithm capability so it cannot be confused with SHA-256 by output length;
both SM3 and HMAC-SM3 pass public known-answer vectors in the parent
repository's
tests-hilsuite on real WS63 silicon. - AES-128/192/256 single-block encryption and decryption drive a SPACC symmetric channel with a KM/KLAD-managed key slot. Algorithm-typed AES-128-CMAC composes that fallible primitive with bounded fragmented input and RFC 4493 subkeys; all four RFC message-length vectors pass in the parent repository's WS63 HIL suite. RFC 3394 key unwrap remains in its protocol owner.
Ws63P256separately consumes the HALPketoken and exposes bounded, fallible NIST P-256 affine point multiplication/addition and fixed-prime field multiplication/squaring. Field inputs use canonical typed elements; the backend reproduces the vendor RSA microcode's MontgomeryR^2setup explicitly rather than exposing generic bignum arithmetic. It borrows entropy only for an explicit session and never falls back to software after a PKE failure. Doubling is mapped to the verified scalar-multiplication sequence; inverse affine inputs return the explicit infinity result. The same session implements the chip-neutral typed P-256 public-key/ECDH contract through that point-multiply capability. Private-key generation still requires a separately selectedTryCryptoRng; the raw WS63 TRNG interface is not promoted to a DRBG.- raw entropy uses the same uniquely owned TRNG FIFO.
Remaining Dragonfly exponentiation/inversion/Legendre arithmetic, point
inversion, curve checks, and y^2 composition still use an explicit software
capability in the current mixed profile. Point and fixed-prime multiply/square
support must not be described as complete SAE or Dragonfly hardware
acceleration.
Callers must choose software, hardware, or accurately named mixed capabilities
explicitly; this crate never falls back to software after a hardware failure.
Ws63Crypto is intentionally not Sync. Operations are synchronous and must
be serialized with a bounded scheduler primitive outside IRQ, critical-section,
and scheduler-lock contexts. RkpPollLimits, SpaccPollLimits, and
SpaccCipherPollLimits make hardware waits explicit; timeouts are returned to
the caller and never trigger a software fallback. PKE ownership is kept in the
separate Ws63P256 capability so Ws63CryptoResources does not grow into an
all-hardware constructor.
The register behavior and sequencing were checked against the Apache-2.0
HiSilicon WS63 security_unified driver sources. This Rust implementation is a
modified, independently structured no_std implementation with typed resource
ownership, bounded failures, PAC access, and Rust crypto capability traits. See
NOTICE for attribution.