[−][src]Struct yubihsm::ecdsa::Signature
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-endians
: 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]
C: Curve + CheckSignatureBytes,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
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]
r: impl Into<GenericArray<u8, <C as Curve>::FieldSize>>,
s: impl Into<GenericArray<u8, <C as Curve>::FieldSize>>
) -> Result<Signature<C>, Error>
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]
<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>,
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]
<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>,
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]
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>,
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]
<<C as ProjectiveArithmetic>::ProjectivePoint as Group>::Scalar: NormalizeLow,
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]
C: Curve + CheckSignatureBytes,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
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]
C: CheckSignatureBytes + Clone + Curve,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
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]
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,
impl<C> Debug for Signature<C> where
C: Curve + CheckSignatureBytes,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
[src]
C: Curve + CheckSignatureBytes,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
impl<D> DigestSigner<D, Signature<NistP256>> for Signer<NistP256> where
D: Digest<OutputSize = U32> + Default,
[src]
D: Digest<OutputSize = U32> + Default,
fn try_sign_digest(&self, digest: D) -> Result<Signature<NistP256>, Error>
[src]
Compute a fixed-sized P-256 ECDSA signature of the given digest
fn sign_digest(&self, digest: D) -> S
[src]
impl<D> DigestSigner<D, Signature<NistP384>> for Signer<NistP384> where
D: Digest<OutputSize = U32> + Default,
[src]
D: Digest<OutputSize = U32> + Default,
fn try_sign_digest(&self, digest: D) -> Result<Signature<NistP384>, Error>
[src]
Compute a fixed-sized P-384 ECDSA signature of the given digest
fn sign_digest(&self, digest: D) -> S
[src]
impl<D> DigestSigner<D, Signature<Secp256k1>> for Signer<Secp256k1> where
D: Digest<OutputSize = U32> + Default,
[src]
D: Digest<OutputSize = U32> + Default,
fn try_sign_digest(&self, digest: D) -> Result<Signature<Secp256k1>, Error>
[src]
Compute a fixed-size secp256k1 ECDSA signature of the given digest
fn sign_digest(&self, digest: D) -> S
[src]
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]
C: CheckSignatureBytes + Eq + Curve,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
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]
C: CheckSignatureBytes + PartialEq<C> + Curve,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
impl<C> PrehashSignature for Signature<C> where
C: DigestPrimitive + CheckSignatureBytes,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
[src]
C: DigestPrimitive + CheckSignatureBytes,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
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]
C: Curve + CheckSignatureBytes,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
impl<C> StructuralEq for Signature<C> where
C: CheckSignatureBytes + Curve,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
[src]
C: CheckSignatureBytes + Curve,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
impl<C> StructuralPartialEq for Signature<C> where
C: CheckSignatureBytes + Curve,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
[src]
C: CheckSignatureBytes + Curve,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
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]
C: Curve + CheckSignatureBytes,
<<C as Curve>::FieldSize as Add<<C as Curve>::FieldSize>>::Output: ArrayLength<u8>,
type Error = Error
The type returned in the event of a conversion error.
fn try_from(bytes: &[u8]) -> Result<Signature<C>, Error>
[src]
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]
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>,
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>,
<<<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>,
<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>,
<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>,
<<<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>,
<<<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]
T: 'static + ?Sized,
impl<A, T> AsBits<T> for A where
A: AsRef<[T]>,
T: BitStore + BitMemory,
A: AsRef<[T]>,
T: BitStore + BitMemory,
fn as_bits<O>(&self) -> &BitSlice<O, T> where
O: BitOrder,
O: BitOrder,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Conv for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Self: Binary,
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Self: Display,
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Self: LowerExp,
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Self: LowerHex,
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Self: Octal,
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Self: Pointer,
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Self: UpperExp,
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Self: UpperHex,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pipe for T
impl<T> PipeAsRef for T
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
R: 'a,
Self: AsRef<T>,
T: 'a,
R: 'a,
Self: AsRef<T>,
T: 'a,
fn pipe_as_mut<'a, T, R>(&'a mut self, func: impl FnOnce(&'a mut T) -> R) -> R where
R: 'a,
Self: AsMut<T>,
T: 'a,
R: 'a,
Self: AsMut<T>,
T: 'a,
impl<T> PipeBorrow for T
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
R: 'a,
Self: Borrow<T>,
T: 'a,
R: 'a,
Self: Borrow<T>,
T: 'a,
fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: BorrowMut<T>,
T: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: BorrowMut<T>,
T: 'a,
impl<T> PipeDeref for T
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
R: 'a,
Self: Deref,
R: 'a,
Self: Deref,
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
R: 'a,
Self: DerefMut,
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
R: 'a,
Self: DerefMut,
impl<T> PipeRef for T
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
R: 'a,
fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
R: 'a,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Tap for T
fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
U: ?Sized,
fn tap_ref<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
fn tap_ref_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
fn tap_ref_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
U: ?Sized,
fn tap_borrow<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
impl<T> TapDeref for T
fn tap_deref<F, R>(self, func: F) -> Self where
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> TryConv for T
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,