[][src]Struct yubihsm::ecdsa::Signature

pub struct Signature<C> where
    C: CheckSignatureBytes + Curve,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
{ /* fields omitted */ }

ECDSA signatures (fixed-size).

Generic over elliptic curve types.

These signatures are serialized as fixed-sized big endian scalar values with no additional framing:

  • r: field element size for the given curve, big-endian
  • s: field element size for the given curve, big-endian

For example, in a curve with a 256-bit modulus like NIST P-256 or secp256k1, r and s will both be 32-bytes, resulting in a signature with a total of 64-bytes.

ASN.1 is also supported via the Signature::from_asn1 and Signature::to_asn1 methods.

Implementations

impl<C> Signature<C> where
    C: Curve + CheckSignatureBytes,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

pub fn from_scalars(
    r: impl Into<GenericArray<u8, <C as Curve>::FieldSize>>,
    s: impl Into<GenericArray<u8, <C as Curve>::FieldSize>>
) -> Result<Signature<C>, Error>
[src]

Create a Signature from the serialized r and s scalar values which comprise the signature.

pub fn from_asn1(bytes: &[u8]) -> Result<Signature<C>, Error> where
    <C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
    <C as Curve>::FieldSize: ArrayLength<u8>,
    <<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: ArrayLength<u8>,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

Parse a signature from ASN.1 DER

pub fn to_asn1(&self) -> Signature<C> where
    <C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
    <C as Curve>::FieldSize: ArrayLength<u8>,
    <<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: ArrayLength<u8>,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

Serialize this signature as ASN.1 DER

impl<C> Signature<C> where
    C: Curve + ProjectiveArithmetic,
    <<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar: PrimeField,
    <<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar as PrimeField>::Repr: From<<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar>,
    <<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar as PrimeField>::Repr: for<'a> From<&'a <<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar>,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
    <<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar as PrimeField>::Repr == GenericArray<u8, <C as Curve>::FieldSize>, 
[src]

pub fn r(&self) -> NonZeroScalar<C>[src]

Get the r component of this signature

pub fn s(&self) -> NonZeroScalar<C>[src]

Get the s component of this signature

pub fn normalize_s(&mut self) -> Result<bool, Error> where
    <<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar: NormalizeLow
[src]

Normalize signature into "low S" form as described in BIP 0062: Dealing with Malleability.

Trait Implementations

impl<C> AsRef<[u8]> for Signature<C> where
    C: Curve + CheckSignatureBytes,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

impl<C> Clone for Signature<C> where
    C: CheckSignatureBytes + Clone + Curve,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

impl<C> Copy for Signature<C> where
    C: Curve + CheckSignatureBytes,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
    <<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as ArrayLength<u8>>::ArrayType: Copy
[src]

impl<C> Debug for Signature<C> where
    C: Curve + CheckSignatureBytes,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

impl<D> DigestSigner<D, Signature<NistP256>> for Signer<NistP256> where
    D: Digest<OutputSize = U32> + Default
[src]

fn try_sign_digest(&self, digest: D) -> Result<Signature<NistP256>, Error>[src]

Compute a fixed-sized P-256 ECDSA signature of the given digest

impl<D> DigestSigner<D, Signature<NistP384>> for Signer<NistP384> where
    D: Digest<OutputSize = U32> + Default
[src]

fn try_sign_digest(&self, digest: D) -> Result<Signature<NistP384>, Error>[src]

Compute a fixed-sized P-384 ECDSA signature of the given digest

impl<D> DigestSigner<D, Signature<Secp256k1>> for Signer<Secp256k1> where
    D: Digest<OutputSize = U32> + Default
[src]

fn try_sign_digest(&self, digest: D) -> Result<Signature<Secp256k1>, Error>[src]

Compute a fixed-size secp256k1 ECDSA signature of the given digest

impl<C> Eq for Signature<C> where
    C: CheckSignatureBytes + Eq + Curve,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

impl From<Signature> for Signature<Secp256k1>[src]

impl<C> PartialEq<Signature<C>> for Signature<C> where
    C: CheckSignatureBytes + PartialEq<C> + Curve,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

impl<C> PrehashSignature for Signature<C> where
    C: DigestPrimitive + CheckSignatureBytes,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

type Digest = <C as DigestPrimitive>::Digest

Preferred Digest algorithm to use when computing this signature type.

impl<C> Signature for Signature<C> where
    C: Curve + CheckSignatureBytes,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

impl<C> StructuralEq for Signature<C> where
    C: CheckSignatureBytes + Curve,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

impl<C> StructuralPartialEq for Signature<C> where
    C: CheckSignatureBytes + Curve,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

impl<'_, C> TryFrom<&'_ [u8]> for Signature<C> where
    C: Curve + CheckSignatureBytes,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

type Error = Error

The type returned in the event of a conversion error.

impl<C> TryFrom<Signature<C>> for Signature<C> where
    C: Curve + CheckSignatureBytes,
    <C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>,
    <C as Curve>::FieldSize: ArrayLength<u8>,
    <<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>>::Output: ArrayLength<u8>,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: Add<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B1>>,
    <<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>, 
[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<C> RefUnwindSafe for Signature<C> where
    <<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
    <C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>, 

impl<C> Send for Signature<C> where
    <C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>, 

impl<C> Sync for Signature<C> where
    <C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>, 

impl<C> Unpin for Signature<C> where
    <<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as ArrayLength<u8>>::ArrayType: Unpin,
    <C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>, 

impl<C> UnwindSafe for Signature<C> where
    <<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output as ArrayLength<u8>>::ArrayType: UnwindSafe,
    <C as Curve>::FieldSize: Add<<C as Curve>::FieldSize>, 

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<A, T> AsBits<T> for A where
    A: AsRef<[T]>,
    T: BitStore + BitMemory, 

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,