pub struct SignatureWithOid<C: EcdsaCurve> {
pub(crate) signature: Signature<C>,
pub(crate) oid: ObjectIdentifier,
}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:
- SHA-224:
ECDSA_SHA224_OID(1.2.840.10045.4.3.1) - SHA-256:
ECDSA_SHA256_OID(1.2.840.10045.4.3.2) - SHA-384:
ECDSA_SHA384_OID(1.2.840.10045.4.3.3) - SHA-512:
ECDSA_SHA512_OID(1.2.840.10045.4.3.4)
Fields§
§signature: Signature<C>Inner signature type.
oid: ObjectIdentifierOID which identifies the ECDSA variant used.
MUST be one of the ECDSA algorithm variants as defined in RFC5758.
These OIDs begin with 1.2.840.10045.4.
Implementations§
Source§impl<C> SignatureWithOid<C>where
C: EcdsaCurve,
impl<C> SignatureWithOid<C>where
C: EcdsaCurve,
Sourcepub fn new(signature: Signature<C>, oid: ObjectIdentifier) -> Result<Self>
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.
Sourcepub fn new_with_digest<D>(signature: Signature<C>) -> Result<Self>where
D: AssociatedOid + Digest,
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.
Sourcepub fn from_bytes_with_digest<D>(bytes: &SignatureBytes<C>) -> Result<Self>
pub fn from_bytes_with_digest<D>(bytes: &SignatureBytes<C>) -> Result<Self>
Parse a signature from fixed-with bytes.
Sourcepub fn from_slice_with_digest<D>(slice: &[u8]) -> Result<Self>
pub fn from_slice_with_digest<D>(slice: &[u8]) -> Result<Self>
Parse a signature from a byte slice.
Sourcepub 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,
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.
Sourcepub fn from_der_with_oid(
der_bytes: &[u8],
oid: ObjectIdentifier,
) -> Result<Self>
pub fn from_der_with_oid( der_bytes: &[u8], oid: ObjectIdentifier, ) -> Result<Self>
Parse a signature from ASN.1 DER and associate the given OID with it.
Sourcepub fn oid(&self) -> ObjectIdentifier
pub fn oid(&self) -> ObjectIdentifier
Get the ECDSA OID for this signature.
Sourcepub fn to_bytes(&self) -> SignatureBytes<C>where
SignatureSize<C>: ArraySize,
pub fn to_bytes(&self) -> SignatureBytes<C>where
SignatureSize<C>: ArraySize,
Serialize this signature as fixed-width bytes.
Sourcepub fn to_der(&self) -> Signature<C>
pub fn to_der(&self) -> Signature<C>
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>
impl<C: Clone + EcdsaCurve> Clone for SignatureWithOid<C>
Source§fn clone(&self) -> SignatureWithOid<C>
fn clone(&self) -> SignatureWithOid<C>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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>>>,
SignatureSize<C>: ArraySize,
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>>>,
SignatureSize<C>: ArraySize,
Source§fn try_sign_digest<F: Fn(&mut D) -> Result<()>>(
&self,
f: F,
) -> Result<SignatureWithOid<C>>
fn try_sign_digest<F: Fn(&mut D) -> Result<()>>( &self, f: F, ) -> Result<SignatureWithOid<C>>
Digest with it, returning a digital
signature on success, or an error if something went wrong. Read moreSource§impl<C> DynAssociatedAlgorithmIdentifier for SignatureWithOid<C>where
C: EcdsaCurve,
Available on crate features alloc and pkcs8 only.
impl<C> DynAssociatedAlgorithmIdentifier for SignatureWithOid<C>where
C: EcdsaCurve,
alloc and pkcs8 only.Source§fn algorithm_identifier(&self) -> Result<AlgorithmIdentifierOwned>
fn algorithm_identifier(&self) -> Result<AlgorithmIdentifierOwned>
AlgorithmIdentifier for this structure. Read moreSource§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.
impl<C> From<&SignatureWithOid<C>> for Signature<C>where
C: EcdsaCurve,
MaxSize<C>: ArraySize,
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
der and digest only.Source§fn from(sig: &SignatureWithOid<C>) -> Signature<C>
fn from(sig: &SignatureWithOid<C>) -> Signature<C>
Source§impl<C> From<SignatureWithOid<C>> for SignatureBytes<C>
Available on crate feature digest only.
impl<C> From<SignatureWithOid<C>> for SignatureBytes<C>
digest only.Source§fn from(signature: SignatureWithOid<C>) -> SignatureBytes<C>
fn from(signature: SignatureWithOid<C>) -> SignatureBytes<C>
Source§impl<C> From<SignatureWithOid<C>> for Signature<C>where
C: EcdsaCurve,
Available on crate feature digest only.
impl<C> From<SignatureWithOid<C>> for Signature<C>where
C: EcdsaCurve,
digest only.Source§fn from(sig: SignatureWithOid<C>) -> Signature<C>
fn from(sig: SignatureWithOid<C>) -> Signature<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.
impl<C> From<SignatureWithOid<C>> for Signature<C>where
C: EcdsaCurve,
MaxSize<C>: ArraySize,
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
der and digest only.Source§fn from(sig: SignatureWithOid<C>) -> Signature<C>
fn from(sig: SignatureWithOid<C>) -> Signature<C>
Source§impl<C> Hash for SignatureWithOid<C>
Available on crate feature digest only.
impl<C> Hash for SignatureWithOid<C>
digest only.Source§impl<C> MultipartSigner<SignatureWithOid<C>> for SigningKey<C>where
C: EcdsaCurve + CurveArithmetic + DigestAlgorithm,
C::Digest: AssociatedOid,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,
SignatureSize<C>: ArraySize,
impl<C> MultipartSigner<SignatureWithOid<C>> for SigningKey<C>where
C: EcdsaCurve + CurveArithmetic + DigestAlgorithm,
C::Digest: AssociatedOid,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,
SignatureSize<C>: ArraySize,
Source§fn try_multipart_sign(&self, msg: &[&[u8]]) -> Result<SignatureWithOid<C>>
fn try_multipart_sign(&self, msg: &[&[u8]]) -> Result<SignatureWithOid<C>>
Signer::try_sign() but the message is provided in non-contiguous byte
slices. Read moreSource§fn multipart_sign(&self, msg: &[&[u8]]) -> S
fn multipart_sign(&self, msg: &[&[u8]]) -> S
Signer::sign() but the message is provided in non-contiguous byte slices.Source§impl<C: PartialEq + EcdsaCurve> PartialEq for SignatureWithOid<C>
impl<C: PartialEq + EcdsaCurve> PartialEq for SignatureWithOid<C>
Source§impl<C> SignatureEncoding for SignatureWithOid<C>
Available on crate features digest and hazmat only.NOTE: this implementation assumes the default digest for the given elliptic
curve as defined by hazmat::DigestAlgorithm.
impl<C> SignatureEncoding for SignatureWithOid<C>
digest and hazmat only.NOTE: this implementation assumes the default digest for the given elliptic
curve as defined by hazmat::DigestAlgorithm.
When working with alternative digests, you will need to use e.g.
SignatureWithOid::new_with_digest.
Source§impl<C> Signer<SignatureWithOid<C>> for SigningKey<C>where
C: EcdsaCurve + CurveArithmetic + DigestAlgorithm,
C::Digest: AssociatedOid,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,
SignatureSize<C>: ArraySize,
impl<C> Signer<SignatureWithOid<C>> for SigningKey<C>where
C: EcdsaCurve + CurveArithmetic + DigestAlgorithm,
C::Digest: AssociatedOid,
Scalar<C>: Invert<Output = CtOption<Scalar<C>>>,
SignatureSize<C>: ArraySize,
Source§impl<C> TryFrom<&[u8]> for SignatureWithOid<C>
Available on crate features digest and hazmat only.NOTE: this implementation assumes the default digest for the given elliptic
curve as defined by hazmat::DigestAlgorithm.
impl<C> TryFrom<&[u8]> for SignatureWithOid<C>
digest and hazmat only.NOTE: this implementation assumes the default digest for the given elliptic
curve as defined by hazmat::DigestAlgorithm.
When working with alternative digests, you will need to use e.g.
SignatureWithOid::new_with_digest.
impl<C> Copy for SignatureWithOid<C>where
C: EcdsaCurve,
SignatureSize<C>: ArraySize,
<SignatureSize<C> as ArraySize>::ArrayType<u8>: Copy,
digest only.