mirror of
https://github.com/RustCrypto/signatures
synced 2026-06-21 13:45:42 +00:00
ecdsa: use EcdsaCurve in bounds (#792)
Replaces previous `PrimeCurve` bounds with the new `EcdsaCurve` trait (which has a supertrait bound on `PrimeCurve`).
This commit is contained in:
+19
-19
@@ -3,7 +3,7 @@
|
||||
//!
|
||||
//! [RFC5912 Section 6]: https://www.rfc-editor.org/rfc/rfc5912#section-6
|
||||
|
||||
use crate::{Error, Result};
|
||||
use crate::{EcdsaCurve, Error, Result};
|
||||
use core::{
|
||||
fmt::{self, Debug},
|
||||
ops::{Add, Range},
|
||||
@@ -12,7 +12,7 @@ use der::{asn1::UintRef, Decode, Encode, FixedTag, Length, Reader, Tag, Writer};
|
||||
use elliptic_curve::{
|
||||
array::{typenum::Unsigned, Array, ArraySize},
|
||||
consts::U9,
|
||||
FieldBytesSize, PrimeCurve,
|
||||
FieldBytesSize,
|
||||
};
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
@@ -59,7 +59,7 @@ type SignatureBytes<C> = Array<u8, MaxSize<C>>;
|
||||
/// [RFC5912 Section 6]: https://www.rfc-editor.org/rfc/rfc5912#section-6
|
||||
pub struct Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -76,7 +76,7 @@ where
|
||||
#[allow(clippy::len_without_is_empty)]
|
||||
impl<C> Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -156,7 +156,7 @@ where
|
||||
|
||||
impl<C> AsRef<[u8]> for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -167,7 +167,7 @@ where
|
||||
|
||||
impl<C> Clone for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -182,7 +182,7 @@ where
|
||||
|
||||
impl<C> Debug for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -199,7 +199,7 @@ where
|
||||
|
||||
impl<'a, C> Decode<'a> for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -220,7 +220,7 @@ where
|
||||
|
||||
impl<C> Encode for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -235,7 +235,7 @@ where
|
||||
|
||||
impl<C> FixedTag for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -244,7 +244,7 @@ where
|
||||
|
||||
impl<C> From<crate::Signature<C>> for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -255,7 +255,7 @@ where
|
||||
|
||||
impl<C> TryFrom<&[u8]> for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -268,7 +268,7 @@ where
|
||||
|
||||
impl<C> TryFrom<Signature<C>> for crate::Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -287,7 +287,7 @@ where
|
||||
#[cfg(feature = "alloc")]
|
||||
impl<C> From<Signature<C>> for Box<[u8]>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -299,7 +299,7 @@ where
|
||||
#[cfg(feature = "alloc")]
|
||||
impl<C> SignatureEncoding for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -313,7 +313,7 @@ where
|
||||
#[cfg(feature = "alloc")]
|
||||
impl<C> SignatureBitStringEncoding for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -325,7 +325,7 @@ where
|
||||
#[cfg(feature = "serde")]
|
||||
impl<C> Serialize for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -340,7 +340,7 @@ where
|
||||
#[cfg(feature = "serde")]
|
||||
impl<'de, C> Deserialize<'de> for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -383,7 +383,7 @@ fn find_scalar_range(outer: &[u8], inner: &[u8]) -> Result<Range<usize>> {
|
||||
#[cfg(all(feature = "digest", feature = "hazmat"))]
|
||||
impl<C> signature::PrehashSignature for Signature<C>
|
||||
where
|
||||
C: PrimeCurve + crate::hazmat::DigestPrimitive,
|
||||
C: EcdsaCurve + crate::hazmat::DigestPrimitive,
|
||||
MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
|
||||
{
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
// TODO(tarcieri): implement full set of tests from ECDSA2VS
|
||||
// <https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-Validation-Program/documents/dss2/ecdsa2vs.pdf>
|
||||
|
||||
use crate::EcdsaCurve;
|
||||
use elliptic_curve::dev::MockCurve;
|
||||
|
||||
impl EcdsaCurve for MockCurve {
|
||||
const NORMALIZE_S: bool = false;
|
||||
}
|
||||
|
||||
/// ECDSA test vector
|
||||
pub struct TestVector {
|
||||
/// Private scalar
|
||||
|
||||
+9
-9
@@ -10,9 +10,9 @@
|
||||
//! Failure to use them correctly can lead to catastrophic failures including
|
||||
//! FULL PRIVATE KEY RECOVERY!
|
||||
|
||||
use crate::{Error, Result};
|
||||
use crate::{EcdsaCurve, Error, Result};
|
||||
use core::cmp;
|
||||
use elliptic_curve::{array::typenum::Unsigned, FieldBytes, PrimeCurve};
|
||||
use elliptic_curve::{array::typenum::Unsigned, FieldBytes};
|
||||
|
||||
#[cfg(feature = "arithmetic")]
|
||||
use {
|
||||
@@ -56,7 +56,7 @@ pub trait SignPrimitive<C>:
|
||||
+ Reduce<C::Uint, Bytes = FieldBytes<C>>
|
||||
+ Sized
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic<Scalar = Self>,
|
||||
C: EcdsaCurve + CurveArithmetic<Scalar = Self>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
/// Try to sign the prehashed message.
|
||||
@@ -128,7 +128,7 @@ where
|
||||
#[cfg(feature = "arithmetic")]
|
||||
pub trait VerifyPrimitive<C>: AffineCoordinates<FieldRepr = FieldBytes<C>> + Copy + Sized
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic<AffinePoint = Self>,
|
||||
C: EcdsaCurve + CurveArithmetic<AffinePoint = Self>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
/// Verify the prehashed message against the provided ECDSA signature.
|
||||
@@ -163,7 +163,7 @@ where
|
||||
///
|
||||
/// [1]: https://github.com/RustCrypto/traits/tree/master/signature/derive
|
||||
#[cfg(feature = "digest")]
|
||||
pub trait DigestPrimitive: PrimeCurve {
|
||||
pub trait DigestPrimitive: EcdsaCurve {
|
||||
/// Preferred digest to use when computing ECDSA signatures for this
|
||||
/// elliptic curve. This is typically a member of the SHA-2 family.
|
||||
type Digest: BlockSizeUser + Digest + FixedOutput + FixedOutputReset;
|
||||
@@ -187,7 +187,7 @@ where
|
||||
///
|
||||
/// [RFC6979 § 2.3.2]: https://datatracker.ietf.org/doc/html/rfc6979#section-2.3.2
|
||||
/// [SEC1]: https://www.secg.org/sec1-v2.pdf
|
||||
pub fn bits2field<C: PrimeCurve>(bits: &[u8]) -> Result<FieldBytes<C>> {
|
||||
pub fn bits2field<C: EcdsaCurve>(bits: &[u8]) -> Result<FieldBytes<C>> {
|
||||
// Minimum allowed bits size is half the field size
|
||||
if bits.len() < C::FieldBytesSize::USIZE / 2 {
|
||||
return Err(Error::new());
|
||||
@@ -232,7 +232,7 @@ pub fn sign_prehashed<C, K>(
|
||||
z: &FieldBytes<C>,
|
||||
) -> Result<(Signature<C>, RecoveryId)>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
K: AsRef<Scalar<C>> + Invert<Output = CtOption<Scalar<C>>>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -278,7 +278,7 @@ pub fn verify_prehashed<C>(
|
||||
sig: &Signature<C>,
|
||||
) -> Result<()>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
let z = Scalar::<C>::reduce_bytes(z);
|
||||
@@ -297,7 +297,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(all(test, feature = "dev"))]
|
||||
mod tests {
|
||||
use super::bits2field;
|
||||
use elliptic_curve::dev::MockCurve;
|
||||
|
||||
+24
-25
@@ -57,7 +57,6 @@
|
||||
#[cfg(feature = "alloc")]
|
||||
extern crate alloc;
|
||||
|
||||
mod normalized;
|
||||
mod recovery;
|
||||
|
||||
#[cfg(feature = "der")]
|
||||
@@ -71,7 +70,7 @@ mod signing;
|
||||
#[cfg(feature = "verifying")]
|
||||
mod verifying;
|
||||
|
||||
pub use crate::{normalized::NormalizedSignature, recovery::RecoveryId};
|
||||
pub use crate::recovery::RecoveryId;
|
||||
|
||||
// Re-export the `elliptic-curve` crate (and select types)
|
||||
pub use elliptic_curve::{self, sec1::EncodedPoint, PrimeCurve};
|
||||
@@ -205,14 +204,14 @@ pub type SignatureBytes<C> = Array<u8, SignatureSize<C>>;
|
||||
/// The serialization uses a hexadecimal encoding when used with
|
||||
/// "human readable" text formats, and a binary encoding otherwise.
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub struct Signature<C: PrimeCurve> {
|
||||
pub struct Signature<C: EcdsaCurve> {
|
||||
r: ScalarPrimitive<C>,
|
||||
s: ScalarPrimitive<C>,
|
||||
}
|
||||
|
||||
impl<C> Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
/// Parse a signature from fixed-width bytes, i.e. 2 * the size of
|
||||
@@ -301,7 +300,7 @@ where
|
||||
#[cfg(feature = "arithmetic")]
|
||||
impl<C> Signature<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
/// Get the `r` component of this signature
|
||||
@@ -333,7 +332,7 @@ where
|
||||
|
||||
impl<C> Copy for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
<SignatureSize<C> as ArraySize>::ArrayType<u8>: Copy,
|
||||
{
|
||||
@@ -341,7 +340,7 @@ where
|
||||
|
||||
impl<C> From<Signature<C>> for SignatureBytes<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn from(signature: Signature<C>) -> SignatureBytes<C> {
|
||||
@@ -351,7 +350,7 @@ where
|
||||
|
||||
impl<C> SignatureEncoding for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
type Repr = SignatureBytes<C>;
|
||||
@@ -359,7 +358,7 @@ where
|
||||
|
||||
impl<C> TryFrom<&[u8]> for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
type Error = Error;
|
||||
@@ -371,7 +370,7 @@ where
|
||||
|
||||
impl<C> fmt::Debug for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
@@ -387,7 +386,7 @@ where
|
||||
|
||||
impl<C> fmt::Display for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
@@ -397,7 +396,7 @@ where
|
||||
|
||||
impl<C> fmt::LowerHex for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
@@ -410,7 +409,7 @@ where
|
||||
|
||||
impl<C> fmt::UpperHex for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
@@ -424,7 +423,7 @@ where
|
||||
#[cfg(feature = "arithmetic")]
|
||||
impl<C> str::FromStr for Signature<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
type Err = Error;
|
||||
@@ -479,7 +478,7 @@ where
|
||||
#[cfg(feature = "pkcs8")]
|
||||
impl<C> AssociatedAlgorithmIdentifier for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
Self: AssociatedOid,
|
||||
{
|
||||
type Params = AnyRef<'static>;
|
||||
@@ -493,7 +492,7 @@ where
|
||||
#[cfg(feature = "serde")]
|
||||
impl<C> Serialize for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
|
||||
@@ -507,7 +506,7 @@ where
|
||||
#[cfg(feature = "serde")]
|
||||
impl<'de, C> Deserialize<'de> for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
|
||||
@@ -534,7 +533,7 @@ where
|
||||
/// [RFC5758 § 3.2]: https://www.rfc-editor.org/rfc/rfc5758#section-3.2
|
||||
#[cfg(feature = "digest")]
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub struct SignatureWithOid<C: PrimeCurve> {
|
||||
pub struct SignatureWithOid<C: EcdsaCurve> {
|
||||
/// Inner signature type.
|
||||
signature: Signature<C>,
|
||||
|
||||
@@ -549,7 +548,7 @@ pub struct SignatureWithOid<C: PrimeCurve> {
|
||||
#[cfg(feature = "digest")]
|
||||
impl<C> SignatureWithOid<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
{
|
||||
/// Create a new signature with an explicitly provided OID.
|
||||
///
|
||||
@@ -660,7 +659,7 @@ where
|
||||
#[cfg(feature = "digest")]
|
||||
impl<C> Copy for SignatureWithOid<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
<SignatureSize<C> as ArraySize>::ArrayType<u8>: Copy,
|
||||
{
|
||||
@@ -669,7 +668,7 @@ where
|
||||
#[cfg(feature = "digest")]
|
||||
impl<C> From<SignatureWithOid<C>> for Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
{
|
||||
fn from(sig: SignatureWithOid<C>) -> Signature<C> {
|
||||
sig.signature
|
||||
@@ -679,7 +678,7 @@ where
|
||||
#[cfg(feature = "digest")]
|
||||
impl<C> From<SignatureWithOid<C>> for SignatureBytes<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
fn from(signature: SignatureWithOid<C>) -> SignatureBytes<C> {
|
||||
@@ -690,7 +689,7 @@ where
|
||||
#[cfg(all(feature = "der", feature = "digest"))]
|
||||
impl<C> From<SignatureWithOid<C>> for der::Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
der::MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<der::MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -702,7 +701,7 @@ where
|
||||
#[cfg(all(feature = "der", feature = "digest"))]
|
||||
impl<C> From<&SignatureWithOid<C>> for der::Signature<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
der::MaxSize<C>: ArraySize,
|
||||
<FieldBytesSize<C> as Add>::Output: Add<der::MaxOverhead> + ArraySize,
|
||||
{
|
||||
@@ -748,7 +747,7 @@ where
|
||||
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
|
||||
impl<C> DynAssociatedAlgorithmIdentifier for SignatureWithOid<C>
|
||||
where
|
||||
C: PrimeCurve,
|
||||
C: EcdsaCurve,
|
||||
{
|
||||
fn algorithm_identifier(&self) -> spki::Result<AlgorithmIdentifierOwned> {
|
||||
Ok(AlgorithmIdentifierOwned {
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
//! Support for ECDSA signatures with low-S normalization.
|
||||
|
||||
use crate::Signature;
|
||||
use elliptic_curve::PrimeCurve;
|
||||
|
||||
/// ECDSA signature with low-S normalization applied.
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
#[repr(transparent)]
|
||||
pub struct NormalizedSignature<C: PrimeCurve> {
|
||||
inner: Signature<C>,
|
||||
}
|
||||
+10
-10
@@ -26,9 +26,9 @@ use {
|
||||
use {
|
||||
crate::{
|
||||
hazmat::{bits2field, DigestPrimitive},
|
||||
Signature, SignatureSize,
|
||||
EcdsaCurve, Signature, SignatureSize,
|
||||
},
|
||||
elliptic_curve::{array::ArraySize, ops::Invert, CurveArithmetic, PrimeCurve, Scalar},
|
||||
elliptic_curve::{array::ArraySize, ops::Invert, CurveArithmetic, Scalar},
|
||||
signature::digest::Digest,
|
||||
};
|
||||
|
||||
@@ -96,7 +96,7 @@ impl RecoveryId {
|
||||
signature: &Signature<C>,
|
||||
) -> Result<Self>
|
||||
where
|
||||
C: DigestPrimitive + PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
AffinePoint<C>:
|
||||
DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
@@ -114,7 +114,7 @@ impl RecoveryId {
|
||||
signature: &Signature<C>,
|
||||
) -> Result<Self>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
D: Digest,
|
||||
AffinePoint<C>:
|
||||
DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
|
||||
@@ -133,7 +133,7 @@ impl RecoveryId {
|
||||
signature: &Signature<C>,
|
||||
) -> Result<Self>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
AffinePoint<C>:
|
||||
DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
@@ -170,7 +170,7 @@ impl From<RecoveryId> for u8 {
|
||||
#[cfg(feature = "signing")]
|
||||
impl<C> SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -202,7 +202,7 @@ where
|
||||
#[cfg(feature = "signing")]
|
||||
impl<C, D> DigestSigner<D, (Signature<C>, RecoveryId)> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
D: Digest,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
@@ -215,7 +215,7 @@ where
|
||||
#[cfg(feature = "signing")]
|
||||
impl<C> PrehashSigner<(Signature<C>, RecoveryId)> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -227,7 +227,7 @@ where
|
||||
#[cfg(feature = "signing")]
|
||||
impl<C> Signer<(Signature<C>, RecoveryId)> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -239,7 +239,7 @@ where
|
||||
#[cfg(feature = "verifying")]
|
||||
impl<C> VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
AffinePoint<C>:
|
||||
DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
|
||||
+38
-38
@@ -3,7 +3,7 @@
|
||||
use crate::{
|
||||
ecdsa_oid_for_digest,
|
||||
hazmat::{bits2field, DigestPrimitive, SignPrimitive},
|
||||
Error, Result, Signature, SignatureSize, SignatureWithOid,
|
||||
EcdsaCurve, Error, Result, Signature, SignatureSize, SignatureWithOid,
|
||||
};
|
||||
use core::fmt::{self, Debug};
|
||||
use digest::{const_oid::AssociatedOid, Digest, FixedOutput};
|
||||
@@ -13,7 +13,7 @@ use elliptic_curve::{
|
||||
ops::Invert,
|
||||
subtle::{Choice, ConstantTimeEq, CtOption},
|
||||
zeroize::{Zeroize, ZeroizeOnDrop},
|
||||
CurveArithmetic, FieldBytes, NonZeroScalar, PrimeCurve, Scalar, SecretKey,
|
||||
CurveArithmetic, FieldBytes, NonZeroScalar, Scalar, SecretKey,
|
||||
};
|
||||
use signature::{
|
||||
hazmat::{PrehashSigner, RandomizedPrehashSigner},
|
||||
@@ -65,7 +65,7 @@ use elliptic_curve::pkcs8::{EncodePrivateKey, SecretDocument};
|
||||
#[derive(Clone)]
|
||||
pub struct SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -79,7 +79,7 @@ where
|
||||
|
||||
impl<C> SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -135,7 +135,7 @@ where
|
||||
/// [RFC6979 § 3.2]: https://tools.ietf.org/html/rfc6979#section-3
|
||||
impl<C, D> DigestSigner<D, Signature<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
D: Digest + FixedOutput,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
@@ -151,7 +151,7 @@ where
|
||||
/// [RFC6979 § 3.2]: https://tools.ietf.org/html/rfc6979#section-3
|
||||
impl<C> PrehashSigner<Signature<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -170,7 +170,7 @@ where
|
||||
/// [RFC6979 § 3.2]: https://tools.ietf.org/html/rfc6979#section-3
|
||||
impl<C> Signer<Signature<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -181,7 +181,7 @@ where
|
||||
|
||||
impl<C, D> RandomizedDigestSigner<D, Signature<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
D: Digest + FixedOutput,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
@@ -197,7 +197,7 @@ where
|
||||
|
||||
impl<C> RandomizedPrehashSigner<Signature<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -219,7 +219,7 @@ where
|
||||
impl<C> RandomizedSigner<Signature<C>> for SigningKey<C>
|
||||
where
|
||||
Self: RandomizedDigestSigner<C::Digest, Signature<C>>,
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -230,7 +230,7 @@ where
|
||||
|
||||
impl<C, D> DigestSigner<D, SignatureWithOid<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
D: AssociatedOid + Digest + FixedOutput,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
@@ -244,7 +244,7 @@ where
|
||||
|
||||
impl<C> Signer<SignatureWithOid<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
C::Digest: AssociatedOid,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
@@ -257,7 +257,7 @@ where
|
||||
#[cfg(feature = "der")]
|
||||
impl<C> PrehashSigner<der::Signature<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
der::MaxSize<C>: ArraySize,
|
||||
@@ -271,7 +271,7 @@ where
|
||||
#[cfg(feature = "der")]
|
||||
impl<C> Signer<der::Signature<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
der::MaxSize<C>: ArraySize,
|
||||
@@ -285,7 +285,7 @@ where
|
||||
#[cfg(feature = "der")]
|
||||
impl<C, D> RandomizedDigestSigner<D, der::Signature<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
D: Digest + FixedOutput,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
@@ -305,7 +305,7 @@ where
|
||||
#[cfg(feature = "der")]
|
||||
impl<C> RandomizedPrehashSigner<der::Signature<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
der::MaxSize<C>: ArraySize,
|
||||
@@ -324,7 +324,7 @@ where
|
||||
#[cfg(feature = "der")]
|
||||
impl<C> RandomizedSigner<der::Signature<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
der::MaxSize<C>: ArraySize,
|
||||
@@ -346,7 +346,7 @@ where
|
||||
#[cfg(feature = "verifying")]
|
||||
impl<C> AsRef<VerifyingKey<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -357,7 +357,7 @@ where
|
||||
|
||||
impl<C> ConstantTimeEq for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -368,7 +368,7 @@ where
|
||||
|
||||
impl<C> Debug for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -379,7 +379,7 @@ where
|
||||
|
||||
impl<C> Drop for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -391,14 +391,14 @@ where
|
||||
/// Constant-time comparison
|
||||
impl<C> Eq for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
}
|
||||
impl<C> PartialEq for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -409,7 +409,7 @@ where
|
||||
|
||||
impl<C> From<NonZeroScalar<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -427,7 +427,7 @@ where
|
||||
|
||||
impl<C> From<SecretKey<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -438,7 +438,7 @@ where
|
||||
|
||||
impl<C> From<&SecretKey<C>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -449,7 +449,7 @@ where
|
||||
|
||||
impl<C> From<SigningKey<C>> for SecretKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -460,7 +460,7 @@ where
|
||||
|
||||
impl<C> From<&SigningKey<C>> for SecretKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -471,7 +471,7 @@ where
|
||||
|
||||
impl<C> TryFrom<&[u8]> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -484,7 +484,7 @@ where
|
||||
|
||||
impl<C> ZeroizeOnDrop for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -493,7 +493,7 @@ where
|
||||
#[cfg(feature = "verifying")]
|
||||
impl<C> From<SigningKey<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -505,7 +505,7 @@ where
|
||||
#[cfg(feature = "verifying")]
|
||||
impl<C> From<&SigningKey<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -517,7 +517,7 @@ where
|
||||
#[cfg(feature = "verifying")]
|
||||
impl<C> KeypairRef for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -527,7 +527,7 @@ where
|
||||
#[cfg(feature = "pkcs8")]
|
||||
impl<C> AssociatedAlgorithmIdentifier for SigningKey<C>
|
||||
where
|
||||
C: AssociatedOid + CurveArithmetic + PrimeCurve,
|
||||
C: EcdsaCurve + AssociatedOid + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -540,7 +540,7 @@ where
|
||||
#[cfg(feature = "pkcs8")]
|
||||
impl<C> SignatureAlgorithmIdentifier for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
Signature<C>: AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
|
||||
@@ -554,7 +554,7 @@ where
|
||||
#[cfg(feature = "pkcs8")]
|
||||
impl<C> TryFrom<pkcs8::PrivateKeyInfo<'_>> for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + AssociatedOid + CurveArithmetic,
|
||||
C: EcdsaCurve + AssociatedOid + CurveArithmetic,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
@@ -570,7 +570,7 @@ where
|
||||
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
|
||||
impl<C> EncodePrivateKey for SigningKey<C>
|
||||
where
|
||||
C: AssociatedOid + PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + AssociatedOid + CurveArithmetic,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
@@ -584,7 +584,7 @@ where
|
||||
#[cfg(feature = "pem")]
|
||||
impl<C> FromStr for SigningKey<C>
|
||||
where
|
||||
C: PrimeCurve + AssociatedOid + CurveArithmetic,
|
||||
C: EcdsaCurve + AssociatedOid + CurveArithmetic,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
Scalar<C>: Invert<Output = CtOption<Scalar<C>>> + SignPrimitive<C>,
|
||||
|
||||
+33
-33
@@ -2,14 +2,14 @@
|
||||
|
||||
use crate::{
|
||||
hazmat::{bits2field, DigestPrimitive, VerifyPrimitive},
|
||||
Error, Result, Signature, SignatureSize,
|
||||
EcdsaCurve, Error, Result, Signature, SignatureSize,
|
||||
};
|
||||
use core::{cmp::Ordering, fmt::Debug};
|
||||
use elliptic_curve::{
|
||||
array::ArraySize,
|
||||
point::PointCompression,
|
||||
sec1::{self, CompressedPoint, EncodedPoint, FromEncodedPoint, ToEncodedPoint},
|
||||
AffinePoint, CurveArithmetic, FieldBytesSize, PrimeCurve, PublicKey,
|
||||
AffinePoint, CurveArithmetic, FieldBytesSize, PublicKey,
|
||||
};
|
||||
use signature::{
|
||||
digest::{Digest, FixedOutput},
|
||||
@@ -77,14 +77,14 @@ use serdect::serde::{de, ser, Deserialize, Serialize};
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
{
|
||||
pub(crate) inner: PublicKey<C>,
|
||||
}
|
||||
|
||||
impl<C> VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -144,7 +144,7 @@ where
|
||||
|
||||
impl<C, D> DigestVerifier<D, Signature<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
D: Digest + FixedOutput,
|
||||
AffinePoint<C>: VerifyPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
@@ -156,7 +156,7 @@ where
|
||||
|
||||
impl<C> PrehashVerifier<Signature<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
AffinePoint<C>: VerifyPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -168,7 +168,7 @@ where
|
||||
|
||||
impl<C> Verifier<Signature<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
AffinePoint<C>: VerifyPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -180,7 +180,7 @@ where
|
||||
#[cfg(feature = "sha2")]
|
||||
impl<C> Verifier<SignatureWithOid<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
AffinePoint<C>: VerifyPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
{
|
||||
@@ -198,7 +198,7 @@ where
|
||||
#[cfg(feature = "der")]
|
||||
impl<C, D> DigestVerifier<D, der::Signature<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
D: Digest + FixedOutput,
|
||||
AffinePoint<C>: VerifyPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
@@ -214,7 +214,7 @@ where
|
||||
#[cfg(feature = "der")]
|
||||
impl<C> PrehashVerifier<der::Signature<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
AffinePoint<C>: VerifyPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
der::MaxSize<C>: ArraySize,
|
||||
@@ -229,7 +229,7 @@ where
|
||||
#[cfg(feature = "der")]
|
||||
impl<C> Verifier<der::Signature<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + DigestPrimitive,
|
||||
C: EcdsaCurve + CurveArithmetic + DigestPrimitive,
|
||||
AffinePoint<C>: VerifyPrimitive<C>,
|
||||
SignatureSize<C>: ArraySize,
|
||||
der::MaxSize<C>: ArraySize,
|
||||
@@ -247,7 +247,7 @@ where
|
||||
|
||||
impl<C> AsRef<AffinePoint<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -256,11 +256,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> Copy for VerifyingKey<C> where C: PrimeCurve + CurveArithmetic {}
|
||||
impl<C> Copy for VerifyingKey<C> where C: EcdsaCurve + CurveArithmetic {}
|
||||
|
||||
impl<C> From<VerifyingKey<C>> for CompressedPoint<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + PointCompression,
|
||||
C: EcdsaCurve + CurveArithmetic + PointCompression,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -271,7 +271,7 @@ where
|
||||
|
||||
impl<C> From<&VerifyingKey<C>> for CompressedPoint<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + PointCompression,
|
||||
C: EcdsaCurve + CurveArithmetic + PointCompression,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -282,7 +282,7 @@ where
|
||||
|
||||
impl<C> From<VerifyingKey<C>> for EncodedPoint<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + PointCompression,
|
||||
C: EcdsaCurve + CurveArithmetic + PointCompression,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -293,7 +293,7 @@ where
|
||||
|
||||
impl<C> From<&VerifyingKey<C>> for EncodedPoint<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic + PointCompression,
|
||||
C: EcdsaCurve + CurveArithmetic + PointCompression,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -302,11 +302,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> Eq for VerifyingKey<C> where C: PrimeCurve + CurveArithmetic {}
|
||||
impl<C> Eq for VerifyingKey<C> where C: EcdsaCurve + CurveArithmetic {}
|
||||
|
||||
impl<C> PartialEq for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
{
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.inner.eq(&other.inner)
|
||||
@@ -315,7 +315,7 @@ where
|
||||
|
||||
impl<C> From<PublicKey<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
{
|
||||
fn from(public_key: PublicKey<C>) -> VerifyingKey<C> {
|
||||
VerifyingKey { inner: public_key }
|
||||
@@ -324,7 +324,7 @@ where
|
||||
|
||||
impl<C> From<&PublicKey<C>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
{
|
||||
fn from(public_key: &PublicKey<C>) -> VerifyingKey<C> {
|
||||
(*public_key).into()
|
||||
@@ -333,7 +333,7 @@ where
|
||||
|
||||
impl<C> From<VerifyingKey<C>> for PublicKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
{
|
||||
fn from(verifying_key: VerifyingKey<C>) -> PublicKey<C> {
|
||||
verifying_key.inner
|
||||
@@ -342,7 +342,7 @@ where
|
||||
|
||||
impl<C> From<&VerifyingKey<C>> for PublicKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
{
|
||||
fn from(verifying_key: &VerifyingKey<C>) -> PublicKey<C> {
|
||||
(*verifying_key).into()
|
||||
@@ -351,7 +351,7 @@ where
|
||||
|
||||
impl<C> PartialOrd for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -362,7 +362,7 @@ where
|
||||
|
||||
impl<C> Ord for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -373,7 +373,7 @@ where
|
||||
|
||||
impl<C> TryFrom<&[u8]> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -387,7 +387,7 @@ where
|
||||
#[cfg(feature = "pkcs8")]
|
||||
impl<C> AssociatedAlgorithmIdentifier for VerifyingKey<C>
|
||||
where
|
||||
C: AssociatedOid + CurveArithmetic + PrimeCurve,
|
||||
C: EcdsaCurve + AssociatedOid + CurveArithmetic,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -400,7 +400,7 @@ where
|
||||
#[cfg(feature = "pkcs8")]
|
||||
impl<C> SignatureAlgorithmIdentifier for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + CurveArithmetic,
|
||||
C: EcdsaCurve + CurveArithmetic,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
Signature<C>: AssociatedAlgorithmIdentifier<Params = AnyRef<'static>>,
|
||||
@@ -414,7 +414,7 @@ where
|
||||
#[cfg(feature = "pkcs8")]
|
||||
impl<C> TryFrom<pkcs8::SubjectPublicKeyInfoRef<'_>> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + AssociatedOid + CurveArithmetic + PointCompression,
|
||||
C: EcdsaCurve + AssociatedOid + CurveArithmetic + PointCompression,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -428,7 +428,7 @@ where
|
||||
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
|
||||
impl<C> EncodePublicKey for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + AssociatedOid + CurveArithmetic + PointCompression,
|
||||
C: EcdsaCurve + AssociatedOid + CurveArithmetic + PointCompression,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -440,7 +440,7 @@ where
|
||||
#[cfg(feature = "pem")]
|
||||
impl<C> FromStr for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + AssociatedOid + CurveArithmetic + PointCompression,
|
||||
C: EcdsaCurve + AssociatedOid + CurveArithmetic + PointCompression,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -454,7 +454,7 @@ where
|
||||
#[cfg(all(feature = "pem", feature = "serde"))]
|
||||
impl<C> Serialize for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + AssociatedOid + CurveArithmetic + PointCompression,
|
||||
C: EcdsaCurve + AssociatedOid + CurveArithmetic + PointCompression,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
@@ -469,7 +469,7 @@ where
|
||||
#[cfg(all(feature = "pem", feature = "serde"))]
|
||||
impl<'de, C> Deserialize<'de> for VerifyingKey<C>
|
||||
where
|
||||
C: PrimeCurve + AssociatedOid + CurveArithmetic + PointCompression,
|
||||
C: EcdsaCurve + AssociatedOid + CurveArithmetic + PointCompression,
|
||||
AffinePoint<C>: FromEncodedPoint<C> + ToEncodedPoint<C>,
|
||||
FieldBytesSize<C>: sec1::ModulusSize,
|
||||
{
|
||||
|
||||
@@ -13,7 +13,6 @@ const EXAMPLE_SIGNATURE: SignatureBytes = hex!(
|
||||
#[test]
|
||||
fn test_serialize() {
|
||||
let signature = Signature::try_from(&EXAMPLE_SIGNATURE[..]).unwrap();
|
||||
dbg!(&signature);
|
||||
let encoded_signature: Vec<u8> = bincode::serialize(&signature).unwrap();
|
||||
assert_eq!(&EXAMPLE_SIGNATURE[..], &encoded_signature[..]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user