pub struct EcdsaKeyPairSigner<K, R, A>
where K: EcdsaKey, R: SecureRandom, A: Algorithm,
{ /* 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>
where K: EcdsaKey, R: SecureRandom, A: Algorithm,

source

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,

source

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>

source§

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

Formats the value using the given formatter. Read more
source§

impl<K, R, A> Signer for EcdsaKeyPairSigner<K, R, A>
where K: EcdsaKey, R: SecureRandom, A: Algorithm,

§

type Signature = <K as EcdsaKey>::Signature

Returned signature type which implmenets the Signature trait.
§

type Error = <K as EcdsaKey>::Error

Returns an error.
source§

fn sign(&self, bytes: &[u8]) -> Result<Self::Signature, Self::Error>

Returns a signature from a byte buffer. Read more

Auto Trait Implementations§

§

impl<K, R, A> RefUnwindSafe for EcdsaKeyPairSigner<K, R, A>

§

impl<K, R, A> Send for EcdsaKeyPairSigner<K, R, A>
where A: Send, K: Send, R: Send,

§

impl<K, R, A> Sync for EcdsaKeyPairSigner<K, R, A>
where A: Sync, K: Sync, R: Sync,

§

impl<K, R, A> Unpin for EcdsaKeyPairSigner<K, R, A>
where A: Unpin, K: Unpin, R: Unpin,

§

impl<K, R, A> UnwindSafe for EcdsaKeyPairSigner<K, R, A>
where A: UnwindSafe, K: UnwindSafe, R: UnwindSafe,

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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