Skip to main content

SignatureWithOid

Struct SignatureWithOid 

Source
pub struct SignatureWithOid<C: EcdsaCurve> { /* private fields */ }
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: EcdsaCurve,

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.

§Errors

Returns Error if oid does not start with 1.2.840.10045.4.

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.

§Errors

Returns Error if the [AssociatedOid] for D is not one from the SHA2 family.

Source

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

Parse a signature from fixed-with bytes.

§Errors

Returns Error if Signature fails to parse, or if D is not a valid digest. See SignatureWithOid::new_with_digest documentation.

Source

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

Parse a signature from a byte slice.

§Errors

Returns Error if Signature fails to parse, or if D is not a valid digest. See SignatureWithOid::new_with_digest documentation.

Source

pub fn from_der_with_digest<D>(der_bytes: &[u8]) -> Result<Self>
where D: AssociatedOid + Digest, MaxSize<C>: ArraySize, <FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,

Parse a signature from ASN.1 DER and associate the given digest’s OID with it.

§Errors

Returns Error if input failed to parse as an ASN.1 DER-encoded ECDSA signature, or if D is not a valid digest.

Source

pub fn from_der_with_oid( der_bytes: &[u8], oid: ObjectIdentifier, ) -> Result<Self>
where MaxSize<C>: ArraySize, <FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,

Parse a signature from ASN.1 DER and associate the given OID with it.

§Errors

Returns Error if input failed to parse as an ASN.1 DER-encoded ECDSA signature, or if D is not a valid digest.

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>

Serialize this signature as fixed-width bytes.

Source

pub fn to_der(&self) -> Signature<C>
where MaxSize<C>: ArraySize, <FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,

Serialize this signature as ASN.1 DER.

Note that this includes only the r and s signature components, and not the OID.

See der::Signature documentation for more information.

Trait Implementations§

Source§

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

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<C: Copy + EcdsaCurve> Copy for SignatureWithOid<C>

Source§

impl<C: Debug + EcdsaCurve> Debug for SignatureWithOid<C>

Source§

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

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

impl<C, D> DigestSigner<D, SignatureWithOid<C>> for SigningKey<C>
where C: EcdsaCurve + CurveArithmetic + DigestAlgorithm, D: AssociatedOid + Digest + FixedOutput, Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,

Source§

fn try_sign_digest<F: Fn(&mut D) -> Result<()>>( &self, f: F, ) -> Result<SignatureWithOid<C>>

Attempt to sign a message by updating the received Digest with it, returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign_digest<F>(&self, f: F) -> S
where F: Fn(&mut D),

Sign a message by updating the received Digest with it, returning a signature. Read more
Source§

impl<C> DynAssociatedAlgorithmIdentifier for SignatureWithOid<C>
where C: EcdsaCurve,

Available on crate features alloc and pkcs8 only.
Source§

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

AlgorithmIdentifier for this structure. Read more
Source§

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

Source§

impl<C> From<&SignatureWithOid<C>> for Signature<C>
where C: EcdsaCurve, MaxSize<C>: ArraySize, <FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,

Available on crate features der and digest only.
Source§

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

Converts to this type from the input type.
Source§

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

Available on crate feature digest only.
Source§

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

Converts to this type from the input type.
Source§

impl<C> From<SignatureWithOid<C>> for SignatureBytes<C>
where C: EcdsaCurve,

Available on crate feature digest only.
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: EcdsaCurve, MaxSize<C>: ArraySize, <FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,

Available on crate features der and digest only.
Source§

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

Converts to this type from the input type.
Source§

impl<C> Hash for SignatureWithOid<C>
where C: EcdsaCurve,

Available on crate feature digest only.
Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<C> MultipartSigner<SignatureWithOid<C>> for SigningKey<C>
where C: EcdsaCurve + CurveArithmetic + DigestAlgorithm, C::Digest: AssociatedOid, Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,

Source§

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

Equivalent of Signer::try_sign() but the message is provided in non-contiguous byte slices. Read more
Source§

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

Equivalent of Signer::sign() but the message is provided in non-contiguous byte slices.
Source§

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

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

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: DigestAlgorithm, C::Digest: AssociatedOid,

Available on crate feature digest only.

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

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

Source§

type Repr = Array<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>

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: EcdsaCurve + CurveArithmetic + DigestAlgorithm, C::Digest: AssociatedOid, Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,

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: PartialEq + EcdsaCurve> StructuralPartialEq for SignatureWithOid<C>

Source§

impl<C> TryFrom<&[u8]> for SignatureWithOid<C>
where C: DigestAlgorithm, C::Digest: AssociatedOid,

Available on crate feature digest only.

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

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

Source§

type Error = Error

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

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

Performs the conversion.

Auto Trait Implementations§

§

impl<C> Freeze for SignatureWithOid<C>
where <<<C as Curve>::FieldBytesSize as Add>::Output as ArraySize>::ArrayType<u8>: Sized, <<C as Curve>::FieldBytesSize as Add>::Output: Sized, <C as Curve>::Uint: Freeze,

§

impl<C> RefUnwindSafe for SignatureWithOid<C>
where <<<C as Curve>::FieldBytesSize as Add>::Output as ArraySize>::ArrayType<u8>: Sized, <<C as Curve>::FieldBytesSize as Add>::Output: Sized, <C as Curve>::Uint: RefUnwindSafe,

§

impl<C> Send for SignatureWithOid<C>
where <<<C as Curve>::FieldBytesSize as Add>::Output as ArraySize>::ArrayType<u8>: Sized, <<C as Curve>::FieldBytesSize as Add>::Output: Sized,

§

impl<C> Sync for SignatureWithOid<C>
where <<<C as Curve>::FieldBytesSize as Add>::Output as ArraySize>::ArrayType<u8>: Sized, <<C as Curve>::FieldBytesSize as Add>::Output: Sized,

§

impl<C> Unpin for SignatureWithOid<C>
where <<<C as Curve>::FieldBytesSize as Add>::Output as ArraySize>::ArrayType<u8>: Sized, <<C as Curve>::FieldBytesSize as Add>::Output: Sized, <C as Curve>::Uint: Unpin,

§

impl<C> UnsafeUnpin for SignatureWithOid<C>
where <<<C as Curve>::FieldBytesSize as Add>::Output as ArraySize>::ArrayType<u8>: Sized, <<C as Curve>::FieldBytesSize as Add>::Output: Sized, <C as Curve>::Uint: UnsafeUnpin,

§

impl<C> UnwindSafe for SignatureWithOid<C>
where <<<C as Curve>::FieldBytesSize as Add>::Output as ArraySize>::ArrayType<u8>: Sized, <<C as Curve>::FieldBytesSize as Add>::Output: Sized, <C as Curve>::Uint: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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