Skip to main content

SigningKeyMaterial

Struct SigningKeyMaterial 

pub struct SigningKeyMaterial { /* private fields */ }
Expand description

The shared core’s key-material and policy types, re-exported for the embedder key constructors (SigningKey::from_material, VerifyingKey::from_material). The material behind a signature.signing-key resource: the private key bound to its algorithm at minting, and the key’s extractability.

Implementations§

§

impl SigningKeyMaterial

pub fn import_ed25519_seed( raw: &[u8], policy: SigningPolicy, ) -> Result<SigningKeyMaterial, Error>

Import a 32-byte RFC 8032 seed, rendering invalid-key for wrong lengths and not-permitted for a policy granting no usage (the mint rule every signing-key constructor enforces).

pub fn generate_ed25519( policy: SigningPolicy, ) -> Result<Result<SigningKeyMaterial, Error>, Error>

Generate a fresh random Ed25519 signing key.

pub fn import_ecdsa_scalar( variant: EcdsaVariant, raw: &[u8], policy: SigningPolicy, ) -> Result<SigningKeyMaterial, Error>

Import a raw big-endian scalar for the declared variant, rendering invalid-key for wrong lengths and out-of-range scalars, and not-permitted for a policy granting no usage (the mint rule every signing-key constructor enforces).

pub fn import_ecdsa_pkcs8( variant: EcdsaVariant, pkcs8_der: &[u8], policy: SigningPolicy, ) -> Result<SigningKeyMaterial, Error>

Import a signing key from a PKCS#8 PrivateKeyInfo (the ecdsa-sign.import-signing-key-pkcs8 contract): the encoded curve must match the declared variant’s; an embedded public key is validated by the decoder and never trusted on its own.

pub fn import_ecdsa_jwk( variant: EcdsaVariant, jwk: &str, policy: SigningPolicy, ) -> Result<SigningKeyMaterial, Error>

Import a signing key from an EC private JWK (the ecdsa-sign.import-signing-key-jwk contract). This implementation takes the MAY: a JWK whose x/y are not the public point of d is rejected invalid-key.

pub fn import_ed25519_pkcs8( pkcs8_der: &[u8], policy: SigningPolicy, ) -> Result<SigningKeyMaterial, Error>

Import a signing key from an RFC 8410 PKCS#8 PrivateKeyInfo (the ed25519-sign.import-signing-key-pkcs8 contract). A v2 public key, when present, is ignored: the key’s identity is the seed’s.

pub fn import_ed25519_jwk( jwk: &str, policy: SigningPolicy, ) -> Result<SigningKeyMaterial, Error>

Import a signing key from an RFC 8037 OKP private JWK (the ed25519-sign.import-signing-key-jwk contract). This implementation takes the MAY: a JWK whose x is not the public key of d is rejected invalid-key.

pub fn generate_ecdsa( variant: EcdsaVariant, policy: SigningPolicy, ) -> Result<Result<SigningKeyMaterial, Error>, Error>

Generate a fresh random ECDSA signing key of the declared variant by rejection-sampling the scalar range with fresh randomness (the probability of a retry is negligible for these curves).

pub fn import_rsassa_pkcs8( variant: RsaVariant, pkcs8_der: &[u8], policy: SigningPolicy, ) -> Result<SigningKeyMaterial, Error>

Import an RSASSA-PKCS1-v1_5 signing key from a PKCS#8 PrivateKeyInfo (the rsassa-pkcs1-v15-sign.import-signing-key-pkcs8 contract): admission follows the WIT rsa family contract plus the signing interfaces’ 2048–8192-bit window.

pub fn import_pss_pkcs8( variant: RsaVariant, pkcs8_der: &[u8], policy: SigningPolicy, ) -> Result<SigningKeyMaterial, Error>

Import an RSA-PSS signing key from a PKCS#8 PrivateKeyInfo (the rsa-pss-sign.import-signing-key-pkcs8 contract): admission as on the RSASSA import, and the minted key signs with salt = digest length (the WIT rsa-pss-sign contract).

pub fn import_rsassa_jwk( variant: RsaVariant, jwk: &str, policy: SigningPolicy, ) -> Result<SigningKeyMaterial, Error>

Import an RSASSA-PKCS1-v1_5 signing key from an RSA private JWK (the rsassa-pkcs1-v15-sign.import-signing-key-jwk contract): the full two-prime CRT form is required, a present alg must be the variant’s JOSE alg, and admission then follows the PKCS#8 import’s contract.

pub fn import_pss_jwk( variant: RsaVariant, jwk: &str, policy: SigningPolicy, ) -> Result<SigningKeyMaterial, Error>

Import an RSA-PSS signing key from an RSA private JWK (the rsa-pss-sign.import-signing-key-jwk contract), as on the RSASSA JWK import; the minted key signs with salt = digest length.

pub fn generate_rsassa( variant: RsaVariant, modulus: RsaModulus, policy: SigningPolicy, ) -> Result<Result<SigningKeyMaterial, Error>, Error>

Generate a fresh random RSASSA-PKCS1-v1_5 signing key of a standard modulus size (the rsassa-pkcs1-v15-sign.generate-key contract); the public exponent is 65537.

The outer channel is never Err here: aws-lc-rs generates from its own internal DRBG, so an entropy failure is indistinguishable from any other generation failure and surfaces as the inner other.

pub fn generate_pss( variant: RsaVariant, modulus: RsaModulus, policy: SigningPolicy, ) -> Result<Result<SigningKeyMaterial, Error>, Error>

Generate a fresh random RSA-PSS signing key (the rsa-pss-sign.generate-key contract), as on generate_rsassa; the minted key signs with salt = digest length.

pub fn sign(&self, data: &[u8]) -> Result<Vec<u8>, Error>

One-shot signature over data (the signing-key.sign contract): 64 bytes for Ed25519 (RFC 8032), fixed-width r ‖ s (IEEE P1363, RFC 6979 deterministic) for ECDSA, and a modulus-length RSA signature under the mint-bound scheme — deterministic EMSA-PKCS1-v1_5, or PSS with a fresh random salt of the digest length.

pub fn public(&self) -> SigPublic

The corresponding SigPublic. There is no WIT derive contract — the package’s generate-key functions return the pair instead — but this core holds the private material, so hosts use this to mint the public half at generation.

pub fn name(&self) -> &'static str

The registry algorithm name (signing-key.algorithm-name).

pub fn curve(&self) -> Option<&'static str>

The registry curve name (signing-key.algorithm-curve).

pub fn hash(&self) -> Option<&'static str>

The mint-bound digest name (signing-key.algorithm-hash).

pub fn length(&self) -> Option<u32>

The key’s length in bits (signing-key.algorithm-length): the RSA modulus length. None for Ed25519 and ECDSA, whose key size is fixed by the algorithm or curve.

pub fn public_exponent(&self) -> Option<Vec<u8>>

The RSA public exponent’s big-endian bytes (signing-key.algorithm-public-exponent). None for Ed25519 and ECDSA, which have no such parameter.

pub fn extractable(&self) -> bool

Whether the private material may be exported — mint-time recorded policy for future format exports (signing-key.extractable).

pub fn can_sign(&self) -> bool

Whether the key permits sign (signing-key.can-sign).

pub fn export(&self) -> Result<Vec<u8>, Error>

The private key material — the 32-byte RFC 8032 seed for Ed25519, the raw big-endian scalar for ECDSA — or not-extractable. RSA private keys have no raw form (the platform serves pkcs8 and jwk only) and render unsupported. No WIT operation reaches this today (signing keys have no raw export); it stays for the unit tests that pin the known answers.

The copy returned is not protected: see the note on crate.

pub fn export_jwk(&self) -> Result<String, Error>

The private key as a JWK (the signing-key.export-key-jwk contract), behind the extractability gate. The RSA form is the full two-prime CRT private JWK, mirroring what the imports require.

The copy returned is not protected: see the note on crate.

pub fn export_pkcs8(&self) -> Result<Vec<u8>, Error>

The private key as a PKCS#8 PrivateKeyInfo (the signing-key.export-key-pkcs8 contract), behind the same gate: the RFC 8410 v1 form for Ed25519, the SEC1 body for ECDSA, the RFC 8017 RSAPrivateKey body for RSA.

Trait Implementations§

§

impl Debug for SigningKeyMaterial

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,