Skip to content

Commit 0e4a329

Browse files
authored
Update to digest::EagerHash (#1077)
ecdsa: merges `arithmetic` into `algorithm` crate feature
1 parent 580758e commit 0e4a329

File tree

13 files changed

+31
-42
lines changed

13 files changed

+31
-42
lines changed

Cargo.lock

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dsa/src/generate/secret_number.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{Components, signing_key::SigningKey};
66
use alloc::vec;
77
use core::cmp::min;
88
use crypto_bigint::{BoxedUint, NonZero, RandomBits, Resize};
9-
use rfc6979::hmac::EagerHash;
9+
use digest::block_api::EagerHash;
1010
use signature::rand_core::TryCryptoRng;
1111
use zeroize::Zeroizing;
1212

dsa/src/signing_key.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use crypto_bigint::{
1313
BoxedUint, NonZero, Resize,
1414
modular::{BoxedMontyForm, BoxedMontyParams},
1515
};
16-
use digest::Update;
17-
use rfc6979::hmac::EagerHash;
16+
use digest::{Update, block_api::EagerHash};
1817
use signature::{
1918
DigestSigner, MultipartSigner, RandomizedDigestSigner, Signer,
2019
hazmat::{PrehashSigner, RandomizedPrehashSigner},

dsa/src/verifying_key.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use crypto_bigint::{
88
BoxedUint, NonZero, Resize,
99
modular::{BoxedMontyForm, BoxedMontyParams},
1010
};
11-
use digest::Update;
12-
use rfc6979::hmac::EagerHash;
11+
use digest::{Update, block_api::EagerHash};
1312
use signature::{DigestVerifier, MultipartVerifier, Verifier, hazmat::PrehashVerifier};
1413

1514
#[cfg(feature = "pkcs8")]

dsa/tests/deterministic.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#![cfg(feature = "hazmat")]
22
use crypto_bigint::BoxedUint;
3-
use digest::Update;
3+
use digest::{Update, block_api::EagerHash};
44
use dsa::{Components, Signature, SigningKey, VerifyingKey};
5-
use rfc6979::hmac::EagerHash;
65
use sha1::Sha1;
76
use sha2::{Sha224, Sha256, Sha384, Sha512};
87
use signature::DigestSigner;

ecdsa/Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ zeroize = { version = "1.5", default-features = false }
2323

2424
# optional dependencies
2525
der = { version = "0.8.0-rc.8", optional = true }
26-
digest = { version = "0.11.0-rc.1", optional = true, default-features = false, features = ["oid"] }
27-
hmac = { version = "0.13.0-rc.1", default-features = false, optional = true }
26+
digest = { version = "0.11.0-rc.2", optional = true, default-features = false, features = ["oid"] }
2827
rfc6979 = { version = "0.5.0-rc.1", optional = true }
2928
serdect = { version = "0.4", optional = true, default-features = false, features = ["alloc"] }
3029
sha2 = { version = "0.11.0-rc.2", optional = true, default-features = false, features = ["oid"] }
@@ -40,11 +39,10 @@ default = ["digest"]
4039
alloc = ["elliptic-curve/alloc", "signature/alloc", "spki/alloc"]
4140
std = ["alloc", "elliptic-curve/std"]
4241

43-
arithmetic = ["dep:hmac", "dep:rfc6979", "elliptic-curve/arithmetic"]
44-
algorithm = ["dep:rfc6979", "arithmetic", "digest", "hazmat"]
45-
dev = ["arithmetic", "digest", "elliptic-curve/dev", "hazmat"]
42+
algorithm = ["dep:rfc6979", "digest", "elliptic-curve/arithmetic", "hazmat"]
43+
dev = ["algorithm", "elliptic-curve/dev"]
4644
der = ["dep:der"]
47-
digest = ["dep:digest", "dep:hmac", "elliptic-curve/digest", "signature/digest"]
45+
digest = ["dep:digest", "elliptic-curve/digest", "signature/digest"]
4846
hazmat = []
4947
pkcs8 = ["der", "digest", "elliptic-curve/pkcs8"]
5048
pem = ["elliptic-curve/pem", "pkcs8"]

ecdsa/src/der.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ fn find_scalar_range(outer: &[u8], inner: &[u8]) -> Result<Range<usize>> {
393393
Ok(Range { start, end })
394394
}
395395

396-
#[cfg(all(test, feature = "arithmetic"))]
396+
#[cfg(all(test, feature = "algorithm"))]
397397
mod tests {
398398
use elliptic_curve::dev::MockCurve;
399399

ecdsa/src/hazmat.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ use crate::{EcdsaCurve, Error, Result};
1414
use core::cmp;
1515
use elliptic_curve::{FieldBytes, array::typenum::Unsigned};
1616

17-
#[cfg(feature = "arithmetic")]
17+
#[cfg(feature = "algorithm")]
1818
use {
19-
crate::{RecoveryId, SignatureSize},
19+
crate::{
20+
RecoveryId, Signature, SignatureSize,
21+
elliptic_curve::{FieldBytesEncoding, array::ArraySize},
22+
},
2023
elliptic_curve::{
2124
CurveArithmetic, NonZeroScalar, ProjectivePoint, Scalar,
2225
ff::PrimeField,
@@ -27,14 +30,8 @@ use {
2730
},
2831
};
2932

30-
#[cfg(feature = "arithmetic")]
31-
use crate::{
32-
Signature,
33-
elliptic_curve::{FieldBytesEncoding, array::ArraySize},
34-
};
35-
36-
#[cfg(any(feature = "arithmetic", feature = "digest"))]
37-
use hmac::EagerHash;
33+
#[cfg(feature = "digest")]
34+
use digest::block_api::EagerHash;
3835

3936
/// Bind a preferred [`Digest`] algorithm to an elliptic curve type.
4037
///
@@ -102,7 +99,7 @@ pub fn bits2field<C: EcdsaCurve>(bits: &[u8]) -> Result<FieldBytes<C>> {
10299
///
103100
/// This will return an error if a zero-scalar was generated. It can be tried again with a
104101
/// different `k`.
105-
#[cfg(feature = "arithmetic")]
102+
#[cfg(feature = "algorithm")]
106103
#[allow(non_snake_case)]
107104
pub fn sign_prehashed<C>(
108105
d: &NonZeroScalar<C>,
@@ -159,7 +156,7 @@ where
159156
/// entropy `ad`.
160157
///
161158
/// [RFC6979]: https://datatracker.ietf.org/doc/html/rfc6979
162-
#[cfg(feature = "arithmetic")]
159+
#[cfg(feature = "algorithm")]
163160
pub fn sign_prehashed_rfc6979<C, D>(
164161
d: &NonZeroScalar<C>,
165162
z: &FieldBytes<C>,
@@ -201,7 +198,7 @@ where
201198
/// # Low-S Normalization
202199
///
203200
/// This is a low-level function that does *NOT* apply the `EcdsaCurve::NORMALIZE_S` checks.
204-
#[cfg(feature = "arithmetic")]
201+
#[cfg(feature = "algorithm")]
205202
pub fn verify_prehashed<C>(
206203
q: &ProjectivePoint<C>,
207204
z: &FieldBytes<C>,

ecdsa/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ use elliptic_curve::{
9393
#[cfg(feature = "alloc")]
9494
use alloc::vec::Vec;
9595

96-
#[cfg(feature = "arithmetic")]
96+
#[cfg(feature = "algorithm")]
9797
use {
9898
core::str,
9999
elliptic_curve::{
@@ -300,7 +300,7 @@ where
300300
}
301301
}
302302

303-
#[cfg(feature = "arithmetic")]
303+
#[cfg(feature = "algorithm")]
304304
impl<C> Signature<C>
305305
where
306306
C: EcdsaCurve + CurveArithmetic,
@@ -423,7 +423,7 @@ where
423423
}
424424
}
425425

426-
#[cfg(feature = "arithmetic")]
426+
#[cfg(feature = "algorithm")]
427427
impl<C> str::FromStr for Signature<C>
428428
where
429429
C: EcdsaCurve + CurveArithmetic,

ecdsa/src/recovery.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use {
88
EcdsaCurve, Signature, SignatureSize, SigningKey, VerifyingKey,
99
hazmat::{DigestAlgorithm, bits2field, sign_prehashed_rfc6979, verify_prehashed},
1010
},
11+
digest::{Digest, block_api::EagerHash},
1112
elliptic_curve::{
1213
AffinePoint, FieldBytesEncoding, FieldBytesSize, Group, PrimeField, ProjectivePoint,
1314
bigint::CheckedAdd,
@@ -18,10 +19,8 @@ use {
1819
elliptic_curve::{
1920
CurveArithmetic, FieldBytes, Scalar, array::ArraySize, ops::Invert, subtle::CtOption,
2021
},
21-
rfc6979::hmac::EagerHash,
2222
signature::{
2323
DigestSigner, MultipartSigner, RandomizedDigestSigner, Signer,
24-
digest::Digest,
2524
hazmat::{PrehashSigner, RandomizedPrehashSigner},
2625
rand_core::TryCryptoRng,
2726
},

0 commit comments

Comments
 (0)