pub struct P384EcImpl;Expand description
The global P384Ec implementation.
Implementations§
Source§impl P384EcImpl
impl P384EcImpl
Sourcepub fn generate_keypair(
rng: &mut dyn Rng,
) -> Result<(P384Scalar, P384AffinePoint), CryptoError>
pub fn generate_keypair( rng: &mut dyn Rng, ) -> Result<(P384Scalar, P384AffinePoint), CryptoError>
Generate a fresh keypair: d uniform in [1, n-1], Q = d * G.
Used for TLS 1.3 ECDHE keygen.
Sourcepub fn public_key(k: P384Scalar) -> Result<P384AffinePoint, CryptoError>
pub fn public_key(k: P384Scalar) -> Result<P384AffinePoint, CryptoError>
Derive the public key k * G from a known private scalar.
No RNG: used for persistent keys (e.g. a TLS static ECDSA identity
loaded from flash, or deriving a BLE public key from a stored
secret) where the caller already holds k.
Sourcepub fn validate_point(p: &P384AffinePoint) -> bool
pub fn validate_point(p: &P384AffinePoint) -> bool
Validate that p is a non-identity point on the P-384 curve.
ECDH shared secret: X coordinate of k * peer, big-endian.
This is the TLS 1.3 ecdhe_shared_secret (fed into HKDF via
HmacSha256) and the BLE LE-SC DHKey.
Sourcepub fn ecdsa_sign(
k: P384Scalar,
digest: &[u8; 48],
rng: &mut dyn Rng,
) -> Result<P384Signature, CryptoError>
pub fn ecdsa_sign( k: P384Scalar, digest: &[u8; 48], rng: &mut dyn Rng, ) -> Result<P384Signature, CryptoError>
ECDSA sign a pre-hashed message (ecdsa_secp384r1_sha384).
The nonce is drawn from rng unless the hardware mandates an
internal entropy source. Returns a low-S normalized signature.
Sourcepub fn ecdsa_verify(
q: P384AffinePoint,
digest: &[u8; 48],
sig: &P384Signature,
) -> Result<(), CryptoError>
pub fn ecdsa_verify( q: P384AffinePoint, digest: &[u8; 48], sig: &P384Signature, ) -> Result<(), CryptoError>
ECDSA verify a pre-hashed message. All inputs public; may be
variable-time. Err(CryptoError::InvalidSignature) on failure.
Trait Implementations§
Source§impl P384Ec for P384EcImpl
impl P384Ec for P384EcImpl
Source§fn generate_keypair(
rng: &mut dyn Rng,
) -> Result<(P384Scalar, P384AffinePoint), CryptoError>
fn generate_keypair( rng: &mut dyn Rng, ) -> Result<(P384Scalar, P384AffinePoint), CryptoError>
Source§fn public_key(k: P384Scalar) -> Result<P384AffinePoint, CryptoError>
fn public_key(k: P384Scalar) -> Result<P384AffinePoint, CryptoError>
k * G from a known private scalar. Read moreSource§fn validate_point(p: &P384AffinePoint) -> bool
fn validate_point(p: &P384AffinePoint) -> bool
p is a non-identity point on the P-384 curve.k * peer, big-endian. Read moreSource§fn ecdsa_sign(
k: P384Scalar,
digest: &[u8; 48],
rng: &mut dyn Rng,
) -> Result<P384Signature, CryptoError>
fn ecdsa_sign( k: P384Scalar, digest: &[u8; 48], rng: &mut dyn Rng, ) -> Result<P384Signature, CryptoError>
ecdsa_secp384r1_sha384). Read moreSource§fn ecdsa_verify(
q: P384AffinePoint,
digest: &[u8; 48],
sig: &P384Signature,
) -> Result<(), CryptoError>
fn ecdsa_verify( q: P384AffinePoint, digest: &[u8; 48], sig: &P384Signature, ) -> Result<(), CryptoError>
Err(CryptoError::InvalidSignature) on failure.