pub struct EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic,{ /* 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>where
C: PrimeCurve + CurveArithmetic + AssociatedTpmCurve,
FieldBytesSize<C>: ModulusSize,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
Ctx: TpmSigner,
impl<C, Ctx> EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic + AssociatedTpmCurve,
FieldBytesSize<C>: ModulusSize,
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
Ctx: TpmSigner,
Source§impl<C, Ctx> EcSigner<C, Ctx>
impl<C, Ctx> EcSigner<C, Ctx>
Sourcepub fn key_params_default() -> KeyParamswhere
C: DigestPrimitive,
<C as DigestPrimitive>::Digest: FixedOutput<OutputSize = FieldBytesSize<C>> + AssociatedHashingAlgorithm,
pub fn key_params_default() -> KeyParamswhere
C: DigestPrimitive,
<C as DigestPrimitive>::Digest: FixedOutput<OutputSize = FieldBytesSize<C>> + AssociatedHashingAlgorithm,
Key parameters for this curve, selected digest is the one selected by DigestPrimitive
Sourcepub fn key_params<D>() -> KeyParams
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>where
C: PrimeCurve + CurveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C, Ctx> AsRef<VerifyingKey<C>> for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Source§fn as_ref(&self) -> &VerifyingKey<C>
fn as_ref(&self) -> &VerifyingKey<C>
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<C, Ctx, D> DigestSigner<D, Signature<C>> for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic + AssociatedTpmCurve,
D: Digest + FixedOutput<OutputSize = FieldBytesSize<C>> + AssociatedHashingAlgorithm,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Digest: From<Output<D>>,
Ctx: TpmSigner,
impl<C, Ctx, D> DigestSigner<D, Signature<C>> for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic + AssociatedTpmCurve,
D: Digest + FixedOutput<OutputSize = FieldBytesSize<C>> + AssociatedHashingAlgorithm,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Digest: From<Output<D>>,
Ctx: TpmSigner,
Source§fn try_sign_digest(&self, digest: D) -> Result<Signature<C>, SigError>
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
fn sign_digest(&self, digest: D) -> S
Source§impl<C, Ctx, D> DigestSigner<D, Signature<C>> for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic + AssociatedTpmCurve,
D: Digest + FixedOutput<OutputSize = FieldBytesSize<C>> + AssociatedHashingAlgorithm,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Digest: From<Output<D>>,
MaxSize<C>: ArrayLength<u8>,
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
Ctx: TpmSigner,
impl<C, Ctx, D> DigestSigner<D, Signature<C>> for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic + AssociatedTpmCurve,
D: Digest + FixedOutput<OutputSize = FieldBytesSize<C>> + AssociatedHashingAlgorithm,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Digest: From<Output<D>>,
MaxSize<C>: ArrayLength<u8>,
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
Ctx: TpmSigner,
Source§fn try_sign_digest(&self, digest: D) -> Result<DerSignature<C>, SigError>
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
fn sign_digest(&self, digest: D) -> S
Source§impl<C, Ctx> KeypairRef for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
impl<C, Ctx> KeypairRef for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Source§type VerifyingKey = VerifyingKey<C>
type VerifyingKey = VerifyingKey<C>
Verifying key type for this keypair.
Source§impl<C, Ctx> SignatureAlgorithmIdentifier for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Signature<C>: AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
impl<C, Ctx> SignatureAlgorithmIdentifier for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Signature<C>: AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
Source§const SIGNATURE_ALGORITHM_IDENTIFIER: AlgorithmIdentifier<Self::Params> = Signature<C>::ALGORITHM_IDENTIFIER
const SIGNATURE_ALGORITHM_IDENTIFIER: AlgorithmIdentifier<Self::Params> = Signature<C>::ALGORITHM_IDENTIFIER
AlgorithmIdentifier for the corresponding singature system.Source§impl<C, Ctx> Signer<Signature<C>> for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic + DigestPrimitive + AssociatedTpmCurve,
<C as DigestPrimitive>::Digest: AssociatedHashingAlgorithm,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Digest: From<Output<<C as DigestPrimitive>::Digest>>,
Ctx: TpmSigner,
impl<C, Ctx> Signer<Signature<C>> for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic + DigestPrimitive + AssociatedTpmCurve,
<C as DigestPrimitive>::Digest: AssociatedHashingAlgorithm,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Digest: From<Output<<C as DigestPrimitive>::Digest>>,
Ctx: TpmSigner,
Source§impl<C, Ctx> Signer<Signature<C>> for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic + DigestPrimitive + AssociatedTpmCurve,
<C as DigestPrimitive>::Digest: AssociatedHashingAlgorithm,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Digest: From<Output<<C as DigestPrimitive>::Digest>>,
MaxSize<C>: ArrayLength<u8>,
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
Ctx: TpmSigner,
impl<C, Ctx> Signer<Signature<C>> for EcSigner<C, Ctx>where
C: PrimeCurve + CurveArithmetic + DigestPrimitive + AssociatedTpmCurve,
<C as DigestPrimitive>::Digest: AssociatedHashingAlgorithm,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
SignatureSize<C>: ArrayLength<u8>,
Digest: From<Output<<C as DigestPrimitive>::Digest>>,
MaxSize<C>: ArrayLength<u8>,
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArrayLength<u8>,
Ctx: TpmSigner,
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>
impl<C, Ctx> UnsafeUnpin for EcSigner<C, Ctx>
impl<C, Ctx> UnwindSafe for EcSigner<C, Ctx>
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
Source§impl<K> Keypair for Kwhere
K: KeypairRef,
impl<K> Keypair for Kwhere
K: KeypairRef,
Source§type VerifyingKey = <K as KeypairRef>::VerifyingKey
type VerifyingKey = <K as KeypairRef>::VerifyingKey
Verifying key type for this keypair.
Source§fn verifying_key(&self) -> <K as Keypair>::VerifyingKey
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.