Skip to content

Commit 7b989c1

Browse files
committed
ecdsa: Signer would only be implemented with hazmat
1 parent 37b1204 commit 7b989c1

6 files changed

Lines changed: 33 additions & 28 deletions

File tree

ecdsa/src/der.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,10 @@ fn find_scalar_range(outer: &[u8], inner: &[u8]) -> Result<Range<usize>> {
382382
Ok(Range { start, end })
383383
}
384384

385-
#[cfg(all(feature = "digest", feature = "hazmat"))]
385+
#[cfg(feature = "digest")]
386386
impl<C> signature::PrehashSignature for Signature<C>
387387
where
388-
C: EcdsaCurve + crate::hazmat::DigestPrimitive,
388+
C: EcdsaCurve + crate::DigestPrimitive,
389389
MaxSize<C>: ArraySize,
390390
<FieldBytesSize<C> as Add>::Output: Add<MaxOverhead> + ArraySize,
391391
{

ecdsa/src/hazmat.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,16 @@ use elliptic_curve::FieldBytesEncoding;
4242
#[cfg(any(feature = "arithmetic", feature = "digest"))]
4343
use crate::{Signature, elliptic_curve::array::ArraySize};
4444

45-
/// Bind a preferred [`Digest`] algorithm to an elliptic curve type.
46-
///
47-
/// Generally there is a preferred variety of the SHA-2 family used with ECDSA
48-
/// for a particular elliptic curve.
49-
///
50-
/// This trait can be used to specify it, and with it receive a blanket impl of
51-
/// [`PrehashSignature`], used by [`signature_derive`][1]) for the [`Signature`]
52-
/// type for a particular elliptic curve.
53-
///
54-
/// [1]: https://github.com/RustCrypto/traits/tree/master/signature/derive
55-
#[cfg(feature = "digest")]
56-
pub trait DigestPrimitive: EcdsaCurve {
57-
/// Preferred digest to use when computing ECDSA signatures for this
58-
/// elliptic curve. This is typically a member of the SHA-2 family.
59-
type Digest: BlockSizeUser + Digest + FixedOutput + FixedOutputReset;
60-
}
45+
#[deprecated(
46+
since = "0.17.0",
47+
note = "`DigestPrimitive` is no longer in `hazmat`, please use `ecdsa::DigestPrimitive` instead"
48+
)]
49+
pub use crate::DigestPrimitive;
6150

6251
#[cfg(feature = "digest")]
6352
impl<C> PrehashSignature for Signature<C>
6453
where
65-
C: DigestPrimitive,
54+
C: crate::DigestPrimitive,
6655
<FieldBytesSize<C> as core::ops::Add>::Output: ArraySize,
6756
{
6857
type Digest = C::Digest;

ecdsa/src/lib.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ use {
102102

103103
#[cfg(feature = "digest")]
104104
use digest::{
105-
Digest,
105+
Digest, FixedOutput, FixedOutputReset,
106106
const_oid::{AssociatedOid, ObjectIdentifier},
107+
core_api::BlockSizeUser,
107108
};
108109

109110
#[cfg(feature = "pkcs8")]
@@ -770,3 +771,20 @@ const fn ecdsa_oid_for_digest(digest_oid: ObjectIdentifier) -> Option<ObjectIden
770771
_ => None,
771772
}
772773
}
774+
775+
/// Bind a preferred [`Digest`] algorithm to an elliptic curve type.
776+
///
777+
/// Generally there is a preferred variety of the SHA-2 family used with ECDSA
778+
/// for a particular elliptic curve.
779+
///
780+
/// This trait can be used to specify it, and with it receive a blanket impl of
781+
/// [`PrehashSignature`], used by [`signature_derive`][1]) for the [`Signature`]
782+
/// type for a particular elliptic curve.
783+
///
784+
/// [1]: https://github.com/RustCrypto/traits/tree/master/signature/derive
785+
#[cfg(feature = "digest")]
786+
pub trait DigestPrimitive: EcdsaCurve {
787+
/// Preferred digest to use when computing ECDSA signatures for this
788+
/// elliptic curve. This is typically a member of the SHA-2 family.
789+
type Digest: BlockSizeUser + Digest + FixedOutput + FixedOutputReset;
790+
}

ecdsa/src/recovery.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ use {
2828

2929
#[cfg(any(feature = "signing", feature = "verifying"))]
3030
use {
31-
crate::{
32-
EcdsaCurve, Signature, SignatureSize,
33-
hazmat::{DigestPrimitive, bits2field},
34-
},
31+
crate::{DigestPrimitive, EcdsaCurve, Signature, SignatureSize, hazmat::bits2field},
3532
elliptic_curve::{CurveArithmetic, Scalar, array::ArraySize, ops::Invert},
3633
signature::digest::Digest,
3734
};

ecdsa/src/signing.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//! ECDSA signing: producing signatures using a [`SigningKey`].
22
33
use crate::{
4-
EcdsaCurve, Error, Result, Signature, SignatureSize, SignatureWithOid, ecdsa_oid_for_digest,
5-
hazmat::{DigestPrimitive, bits2field, sign_prehashed_rfc6979},
4+
DigestPrimitive, EcdsaCurve, Error, Result, Signature, SignatureSize, SignatureWithOid,
5+
ecdsa_oid_for_digest,
6+
hazmat::{bits2field, sign_prehashed_rfc6979},
67
};
78
use core::fmt::{self, Debug};
89
use digest::{Digest, FixedOutput, const_oid::AssociatedOid};

ecdsa/src/verifying.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! ECDSA verifying: checking signatures are authentic using a [`VerifyingKey`].
22
33
use crate::{
4-
EcdsaCurve, Error, Result, Signature, SignatureSize,
5-
hazmat::{self, DigestPrimitive, bits2field},
4+
DigestPrimitive, EcdsaCurve, Error, Result, Signature, SignatureSize,
5+
hazmat::{self, bits2field},
66
};
77
use core::{cmp::Ordering, fmt::Debug};
88
use elliptic_curve::{

0 commit comments

Comments
 (0)