Skip to main content

EcSigner

Struct EcSigner 

Source
pub struct EcSigner<C, Ctx>{ /* private fields */ }
Expand description

EcSigner will sign a payload with an elliptic curve secret key stored on the TPM.

§Parameters

Parameter C describes the curve that is of use (Nist P-256, Nist P-384, …)

use p256::NistP256;
use signature::Signer;

let key_params = EcSigner::<NistP256, ()>::key_params_default();
let (tpm_km, _tpm_auth) = context
    .create_key(key_params, 0)
    .expect("Failed to create a private keypair");

let signer = EcSigner::<NistP256,_>::new((Mutex::new(&mut context), tpm_km, key_params, None))
     .expect("Failed to create a signer");
let signature: p256::ecdsa::Signature = signer.sign(b"Hello Bob, Alice here.");

Implementations§

Source§

impl<C, Ctx> EcSigner<C, Ctx>

Source

pub fn new(context: Ctx) -> Result<Self, Error>

Source§

impl<C, Ctx> EcSigner<C, Ctx>

Source

pub fn key_params_default() -> KeyParams

Key parameters for this curve, selected digest is the one selected by DigestPrimitive

Source

pub fn key_params<D>() -> KeyParams

Key parameters for this curve

§Parameters

The hashing algorithm D is the digest that will be used for signatures (SHA-256, SHA3-256, …).

Trait Implementations§

Source§

impl<C, Ctx> AsRef<VerifyingKey<C>> for EcSigner<C, Ctx>

Source§

fn as_ref(&self) -> &VerifyingKey<C>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<C, Ctx: Debug> Debug for EcSigner<C, Ctx>

Source§

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

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

impl<C, Ctx, D> DigestSigner<D, Signature<C>> for EcSigner<C, Ctx>

Source§

fn try_sign_digest(&self, digest: D) -> Result<Signature<C>, SigError>

Attempt to sign the given prehashed message Digest, returning a digital signature on success, or an error if something went wrong.
Source§

fn sign_digest(&self, digest: D) -> S

Sign the given prehashed message Digest, returning a signature. Read more
Source§

impl<C, Ctx, D> DigestSigner<D, Signature<C>> for EcSigner<C, Ctx>

Source§

fn try_sign_digest(&self, digest: D) -> Result<DerSignature<C>, SigError>

Attempt to sign the given prehashed message Digest, returning a digital signature on success, or an error if something went wrong.
Source§

fn sign_digest(&self, digest: D) -> S

Sign the given prehashed message Digest, returning a signature. Read more
Source§

impl<C, Ctx> KeypairRef for EcSigner<C, Ctx>

Source§

type VerifyingKey = VerifyingKey<C>

Verifying key type for this keypair.
Source§

impl<C, Ctx> SignatureAlgorithmIdentifier for EcSigner<C, Ctx>

Source§

const SIGNATURE_ALGORITHM_IDENTIFIER: AlgorithmIdentifier<Self::Params> = Signature<C>::ALGORITHM_IDENTIFIER

AlgorithmIdentifier for the corresponding singature system.
Source§

type Params = AnyRef<'static>

Algorithm parameters.
Source§

impl<C, Ctx> Signer<Signature<C>> for EcSigner<C, Ctx>

Source§

fn try_sign(&self, msg: &[u8]) -> Result<Signature<C>, SigError>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign(&self, msg: &[u8]) -> S

Sign the given message and return a digital signature
Source§

impl<C, Ctx> Signer<Signature<C>> for EcSigner<C, Ctx>

Source§

fn try_sign(&self, msg: &[u8]) -> Result<DerSignature<C>, SigError>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign(&self, msg: &[u8]) -> S

Sign the given message and return a digital signature

Auto Trait Implementations§

§

impl<C, Ctx> Freeze for EcSigner<C, Ctx>

§

impl<C, Ctx> RefUnwindSafe for EcSigner<C, Ctx>

§

impl<C, Ctx> Send for EcSigner<C, Ctx>
where Ctx: Send,

§

impl<C, Ctx> Sync for EcSigner<C, Ctx>
where Ctx: Sync,

§

impl<C, Ctx> Unpin for EcSigner<C, Ctx>
where Ctx: Unpin, <C as CurveArithmetic>::AffinePoint: Unpin,

§

impl<C, Ctx> UnsafeUnpin for EcSigner<C, Ctx>

§

impl<C, Ctx> UnwindSafe for EcSigner<C, Ctx>

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<K> Keypair for K
where K: KeypairRef,

Source§

type VerifyingKey = <K as KeypairRef>::VerifyingKey

Verifying key type for this keypair.
Source§

fn verifying_key(&self) -> <K as Keypair>::VerifyingKey

Get the verifying key which can verify signatures produced by the signing key portion of this keypair.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<S, T> SignerMut<S> for T
where T: Signer<S>,

Source§

fn try_sign(&mut self, msg: &[u8]) -> Result<S, Error>

Attempt to sign the given message, updating the state, and returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign(&mut self, msg: &[u8]) -> S

Sign the given message, update the state, and return a digital signature.
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.