Struct ecdsa::SignatureWithOid

source ·
pub struct SignatureWithOid<C: PrimeCurve> { /* private fields */ }
Available on crate feature digest only.
Expand description

An extended Signature type which is parameterized by an ObjectIdentifier which identifies the ECDSA variant used by a particular signature.

Valid ObjectIdentifiers are defined in RFC5758 § 3.2:

Implementations§

source§

impl<C> SignatureWithOid<C>where C: PrimeCurve,

source

pub fn new(signature: Signature<C>, oid: ObjectIdentifier) -> Result<Self>

Create a new signature with an explicitly provided OID.

OID must begin with 1.2.840.10045.4, the RFC5758 OID prefix for ECDSA variants.

source

pub fn new_with_digest<D>(signature: Signature<C>) -> Result<Self>where D: AssociatedOid + Digest,

Create a new signature, determining the OID from the given digest.

Supports SHA-2 family digests as enumerated in RFC5758 § 3.2, i.e. SHA-224, SHA-256, SHA-384, or SHA-512.

source

pub fn from_bytes_with_digest<D>(bytes: &SignatureBytes<C>) -> Result<Self>where D: AssociatedOid + Digest, SignatureSize<C>: ArrayLength<u8>,

Parse a signature from fixed-with bytes.

source

pub fn from_slice_with_digest<D>(slice: &[u8]) -> Result<Self>where D: AssociatedOid + Digest, SignatureSize<C>: ArrayLength<u8>,

Parse a signature from a byte slice.

source

pub fn signature(&self) -> &Signature<C>

Get the fixed-width ECDSA signature.

source

pub fn oid(&self) -> ObjectIdentifier

Get the ECDSA OID for this signature.

source

pub fn to_bytes(&self) -> SignatureBytes<C>where SignatureSize<C>: ArrayLength<u8>,

Serialize this signature as bytes.

Trait Implementations§

source§

impl<C: Clone + PrimeCurve> Clone for SignatureWithOid<C>

source§

fn clone(&self) -> SignatureWithOid<C>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<C, D> DigestSigner<D, SignatureWithOid<C>> for SigningKey<C>where C: PrimeCurve + CurveArithmetic + DigestPrimitive, D: AssociatedOid + Digest + FixedOutput<OutputSize = FieldBytesSize<C>>, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,

Available on crate feature signing only.
source§

fn try_sign_digest(&self, msg_digest: D) -> Result<SignatureWithOid<C>>

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> DynAssociatedAlgorithmIdentifier for SignatureWithOid<C>where C: PrimeCurve,

Available on crate features alloc and pkcs8 only.
source§

fn algorithm_identifier(&self) -> Result<AlgorithmIdentifierOwned>

AlgorithmIdentifier for this structure.
source§

impl<C> From<SignatureWithOid<C>> for SignatureBytes<C>where C: PrimeCurve, SignatureSize<C>: ArrayLength<u8>,

source§

fn from(signature: SignatureWithOid<C>) -> SignatureBytes<C>

Converts to this type from the input type.
source§

impl<C> From<SignatureWithOid<C>> for Signature<C>where C: PrimeCurve,

source§

fn from(sig: SignatureWithOid<C>) -> Signature<C>

Converts to this type from the input type.
source§

impl<C: PartialEq + PrimeCurve> PartialEq for SignatureWithOid<C>

source§

fn eq(&self, other: &SignatureWithOid<C>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<C> SignatureEncoding for SignatureWithOid<C>where C: DigestPrimitive, C::Digest: AssociatedOid, SignatureSize<C>: ArrayLength<u8>,

Available on crate feature hazmat only.

NOTE: this implementation assumes the default digest for the given elliptic curve as defined by hazmat::DigestPrimitive.

When working with alternative digests, you will need to use e.g. SignatureWithOid::new_with_digest.

§

type Repr = GenericArray<u8, <<C as Curve>::FieldBytesSize as Add>::Output>

Byte representation of a signature.
source§

fn to_bytes(&self) -> Self::Repr

Encode signature as its byte representation.
source§

fn to_vec(&self) -> Vec<u8>

Available on crate feature alloc only.
Encode signature as a byte vector.
source§

fn encoded_len(&self) -> usize

Get the length of this signature when encoded.
source§

impl<C> Signer<SignatureWithOid<C>> for SigningKey<C>where C: PrimeCurve + CurveArithmetic + DigestPrimitive, C::Digest: AssociatedOid, Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,

Available on crate feature signing only.
source§

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

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> TryFrom<&[u8]> for SignatureWithOid<C>where C: DigestPrimitive, C::Digest: AssociatedOid, SignatureSize<C>: ArrayLength<u8>,

Available on crate feature hazmat only.

NOTE: this implementation assumes the default digest for the given elliptic curve as defined by hazmat::DigestPrimitive.

When working with alternative digests, you will need to use e.g. SignatureWithOid::new_with_digest.

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(slice: &[u8]) -> Result<Self>

Performs the conversion.
source§

impl<C> Verifier<SignatureWithOid<C>> for VerifyingKey<C>where C: PrimeCurve + CurveArithmetic + DigestPrimitive, AffinePoint<C>: VerifyPrimitive<C>, SignatureSize<C>: ArrayLength<u8>,

Available on crate features verifying and sha2 only.
source§

fn verify(&self, msg: &[u8], sig: &SignatureWithOid<C>) -> Result<()>

Use Self to verify that the provided signature for a given message bytestring is authentic. Read more
source§

impl<C> Copy for SignatureWithOid<C>where C: PrimeCurve, SignatureSize<C>: ArrayLength<u8>, <SignatureSize<C> as ArrayLength<u8>>::ArrayType: Copy,

source§

impl<C: Eq + PrimeCurve> Eq for SignatureWithOid<C>

source§

impl<C: PrimeCurve> StructuralEq for SignatureWithOid<C>

source§

impl<C: PrimeCurve> StructuralPartialEq for SignatureWithOid<C>

Auto Trait Implementations§

§

impl<C> RefUnwindSafe for SignatureWithOid<C>where <C as Curve>::Uint: RefUnwindSafe,

§

impl<C> Send for SignatureWithOid<C>

§

impl<C> Sync for SignatureWithOid<C>

§

impl<C> Unpin for SignatureWithOid<C>where <C as Curve>::Uint: Unpin,

§

impl<C> UnwindSafe for SignatureWithOid<C>where <C as Curve>::Uint: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.