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
impl SigningKeyMaterial
pub fn import_ed25519_seed(
raw: &[u8],
policy: SigningPolicy,
) -> Result<SigningKeyMaterial, Error>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
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 length(&self) -> Option<u32>
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>>
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
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 export(&self) -> Result<Vec<u8>, Error>
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>
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>
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§
Auto Trait Implementations§
impl Freeze for SigningKeyMaterial
impl RefUnwindSafe for SigningKeyMaterial
impl Send for SigningKeyMaterial
impl Sync for SigningKeyMaterial
impl Unpin for SigningKeyMaterial
impl UnsafeUnpin for SigningKeyMaterial
impl UnwindSafe for SigningKeyMaterial
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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