Struct min_jwt::sign::ring::EcdsaKeyPairSigner
source · pub struct EcdsaKeyPairSigner<K, R, A>{ /* private fields */ }
Available on crate feature
ring
only.Expand description
Wrapper for ::ring::signature::EcdsaKeyPair
.
Examples
ES256 PKCS8
let private_key =
"-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg8UmkmK0KO64KCDRZ
b4RCAHRZ0AfRWBn3Pv6hTv1VR9mhRANCAAR6sST7OqgbWhgEsPeiG7PS3MiVTtfM
UbXT3wdwI67QKZUCynxkthepgPe2zr6PQJX8jbJ/PDH+iMGub5n+lJCc
-----END PRIVATE KEY-----";
// Convert the PKCS8 PEM to DER
let private_key = convert_pkcs8_pem_to_der(private_key);
let secure_random = ::ring::rand::SystemRandom::new();
let private_key = ::ring::signature::EcdsaKeyPair::from_pkcs8(
&ring::signature::ECDSA_P256_SHA256_FIXED_SIGNING,
private_key.as_ref(),
&secure_random,
).unwrap();
let signer = min_jwt::sign::ring::EcdsaKeyPairSigner::with_es256(
private_key,
secure_random
);
let jwt = min_jwt::encode_and_sign(header.as_bytes(), claims.as_bytes(), &signer)?;
Implementations§
source§impl<K, R, A> EcdsaKeyPairSigner<K, R, A>
impl<K, R, A> EcdsaKeyPairSigner<K, R, A>
sourcepub fn into_inner(self) -> (K, R)
pub fn into_inner(self) -> (K, R)
Returns the inner key and SecureRandom
.
source§impl<K, R> EcdsaKeyPairSigner<K, R, Es256>where
K: EcdsaKey,
R: SecureRandom,
impl<K, R> EcdsaKeyPairSigner<K, R, Es256>where
K: EcdsaKey,
R: SecureRandom,
sourcepub fn with_es256(
key_pair: K,
secure_random: R
) -> EcdsaKeyPairSigner<K, R, Es256>
pub fn with_es256( key_pair: K, secure_random: R ) -> EcdsaKeyPairSigner<K, R, Es256>
Creates a new Es256
key signer.
Trait Implementations§
source§impl<K, R, A> Debug for EcdsaKeyPairSigner<K, R, A>
impl<K, R, A> Debug for EcdsaKeyPairSigner<K, R, A>
source§impl<K, R, A> Signer for EcdsaKeyPairSigner<K, R, A>
impl<K, R, A> Signer for EcdsaKeyPairSigner<K, R, A>
Auto Trait Implementations§
impl<K, R, A> RefUnwindSafe for EcdsaKeyPairSigner<K, R, A>
impl<K, R, A> Send for EcdsaKeyPairSigner<K, R, A>
impl<K, R, A> Sync for EcdsaKeyPairSigner<K, R, A>
impl<K, R, A> Unpin for EcdsaKeyPairSigner<K, R, A>
impl<K, R, A> UnwindSafe for EcdsaKeyPairSigner<K, R, A>
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
Mutably borrows from an owned value. Read more