Skip to content

Commit 40b250b

Browse files
committed
Clean up crate features
1 parent caa5355 commit 40b250b

File tree

6 files changed

+36
-30
lines changed

6 files changed

+36
-30
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ecdsa/Cargo.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ zeroize = { version = "1.5", default-features = false }
2424
# optional dependencies
2525
der = { version = "0.8.0-rc.8", optional = true }
2626
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 }
2728
rfc6979 = { version = "0.5.0-rc.1", optional = true }
2829
serdect = { version = "0.4", optional = true, default-features = false, features = ["alloc"] }
2930
sha2 = { version = "0.11.0-rc.2", optional = true, default-features = false, features = ["oid"] }
@@ -39,14 +40,15 @@ default = ["digest"]
3940
alloc = ["elliptic-curve/alloc", "signature/alloc", "spki/alloc"]
4041
std = ["alloc", "elliptic-curve/std"]
4142

42-
arithmetic = ["elliptic-curve/arithmetic"]
43+
arithmetic = ["dep:hmac", "dep:rfc6979", "elliptic-curve/arithmetic"]
44+
algorithm = ["dep:rfc6979", "arithmetic", "digest", "hazmat"]
4345
dev = ["arithmetic", "digest", "elliptic-curve/dev", "hazmat"]
44-
digest = ["dep:digest", "elliptic-curve/digest", "signature/digest", "rfc6979"]
46+
der = ["dep:der"]
47+
digest = ["dep:digest", "dep:hmac", "elliptic-curve/digest", "signature/digest"]
4548
hazmat = []
46-
pkcs8 = ["digest", "elliptic-curve/pkcs8", "der"]
49+
pkcs8 = ["dep:der", "digest", "elliptic-curve/pkcs8"]
4750
pem = ["elliptic-curve/pem", "pkcs8"]
48-
serde = ["elliptic-curve/serde", "pkcs8", "serdect"]
49-
signature = ["arithmetic", "digest", "hazmat", "rfc6979"]
51+
serde = ["dep:serdect", "elliptic-curve/serde", "pkcs8"]
5052

5153
[package.metadata.docs.rs]
5254
all-features = true

ecdsa/src/hazmat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::{
3434
};
3535

3636
#[cfg(any(feature = "arithmetic", feature = "digest"))]
37-
use rfc6979::hmac::EagerHash;
37+
use hmac::EagerHash;
3838

3939
/// Bind a preferred [`Digest`] algorithm to an elliptic curve type.
4040
///

ecdsa/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ pub mod der;
6565
pub mod dev;
6666
#[cfg(feature = "hazmat")]
6767
pub mod hazmat;
68-
#[cfg(feature = "signature")]
68+
#[cfg(feature = "algorithm")]
6969
mod signing;
70-
#[cfg(feature = "signature")]
70+
#[cfg(feature = "algorithm")]
7171
mod verifying;
7272

7373
pub use crate::recovery::RecoveryId;
@@ -79,9 +79,9 @@ pub use elliptic_curve::{self, PrimeCurve, sec1::EncodedPoint};
7979
pub use signature::{self, Error, Result, SignatureEncoding};
8080
use zeroize::Zeroize;
8181

82-
#[cfg(feature = "signature")]
82+
#[cfg(feature = "algorithm")]
8383
pub use crate::signing::SigningKey;
84-
#[cfg(feature = "signature")]
84+
#[cfg(feature = "algorithm")]
8585
pub use crate::verifying::VerifyingKey;
8686

8787
use core::{fmt, ops::Add};

ecdsa/src/recovery.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::{Error, Result};
44

5-
#[cfg(feature = "signature")]
5+
#[cfg(feature = "algorithm")]
66
use {
77
crate::{
88
EcdsaCurve, Signature, SignatureSize, SigningKey, VerifyingKey,
@@ -80,7 +80,7 @@ impl RecoveryId {
8080
}
8181
}
8282

83-
#[cfg(feature = "signature")]
83+
#[cfg(feature = "algorithm")]
8484
impl RecoveryId {
8585
/// Given a public key, message, and signature, use trial recovery
8686
/// to determine if a suitable recovery ID exists, or return an error
@@ -167,7 +167,7 @@ impl From<RecoveryId> for u8 {
167167
}
168168
}
169169

170-
#[cfg(feature = "signature")]
170+
#[cfg(feature = "algorithm")]
171171
impl<C> SigningKey<C>
172172
where
173173
C: EcdsaCurve + CurveArithmetic + DigestAlgorithm,
@@ -216,7 +216,7 @@ where
216216
}
217217
}
218218

219-
#[cfg(feature = "signature")]
219+
#[cfg(feature = "algorithm")]
220220
impl<C, D> DigestSigner<D, (Signature<C>, RecoveryId)> for SigningKey<C>
221221
where
222222
C: EcdsaCurve + CurveArithmetic + DigestAlgorithm,
@@ -234,7 +234,7 @@ where
234234
}
235235
}
236236

237-
#[cfg(feature = "signature")]
237+
#[cfg(feature = "algorithm")]
238238
impl<C> RandomizedPrehashSigner<(Signature<C>, RecoveryId)> for SigningKey<C>
239239
where
240240
C: EcdsaCurve + CurveArithmetic + DigestAlgorithm,
@@ -250,7 +250,7 @@ where
250250
}
251251
}
252252

253-
#[cfg(feature = "signature")]
253+
#[cfg(feature = "algorithm")]
254254
impl<C, D> RandomizedDigestSigner<D, (Signature<C>, RecoveryId)> for SigningKey<C>
255255
where
256256
C: EcdsaCurve + CurveArithmetic + DigestAlgorithm,
@@ -269,7 +269,7 @@ where
269269
}
270270
}
271271

272-
#[cfg(feature = "signature")]
272+
#[cfg(feature = "algorithm")]
273273
impl<C> PrehashSigner<(Signature<C>, RecoveryId)> for SigningKey<C>
274274
where
275275
C: EcdsaCurve + CurveArithmetic + DigestAlgorithm,
@@ -281,7 +281,7 @@ where
281281
}
282282
}
283283

284-
#[cfg(feature = "signature")]
284+
#[cfg(feature = "algorithm")]
285285
impl<C> Signer<(Signature<C>, RecoveryId)> for SigningKey<C>
286286
where
287287
C: EcdsaCurve + CurveArithmetic + DigestAlgorithm,
@@ -293,7 +293,7 @@ where
293293
}
294294
}
295295

296-
#[cfg(feature = "signature")]
296+
#[cfg(feature = "algorithm")]
297297
impl<C> MultipartSigner<(Signature<C>, RecoveryId)> for SigningKey<C>
298298
where
299299
C: EcdsaCurve + CurveArithmetic + DigestAlgorithm,
@@ -307,7 +307,7 @@ where
307307
}
308308
}
309309

310-
#[cfg(feature = "signature")]
310+
#[cfg(feature = "algorithm")]
311311
impl<C> VerifyingKey<C>
312312
where
313313
C: EcdsaCurve + CurveArithmetic,

ecdsa/src/signing.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ use signature::{
2323
};
2424

2525
#[cfg(feature = "der")]
26-
use {crate::der, core::ops::Add, elliptic_curve::FieldBytesSize};
26+
use {crate::der, core::ops::Add};
2727

2828
#[cfg(feature = "pem")]
2929
use {core::str::FromStr, elliptic_curve::pkcs8::DecodePrivateKey};
3030

31+
#[cfg(any(feature = "der", feature = "pem", feature = "pkcs8"))]
32+
use elliptic_curve::FieldBytesSize;
33+
3134
#[cfg(feature = "pkcs8")]
3235
use crate::elliptic_curve::{
3336
AffinePoint,
@@ -39,7 +42,7 @@ use crate::elliptic_curve::{
3942
sec1::{self, FromEncodedPoint, ToEncodedPoint},
4043
};
4144

42-
#[cfg(feature = "signature")]
45+
#[cfg(feature = "algorithm")]
4346
use {crate::VerifyingKey, elliptic_curve::PublicKey, signature::KeypairRef};
4447

4548
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
@@ -72,7 +75,7 @@ where
7275
secret_scalar: NonZeroScalar<C>,
7376

7477
/// Verifying key which corresponds to this signing key.
75-
#[cfg(feature = "signature")]
78+
#[cfg(feature = "algorithm")]
7679
verifying_key: VerifyingKey<C>,
7780
}
7881

@@ -125,7 +128,7 @@ where
125128
}
126129

127130
/// Get the [`VerifyingKey`] which corresponds to this [`SigningKey`].
128-
#[cfg(feature = "signature")]
131+
#[cfg(feature = "algorithm")]
129132
pub fn verifying_key(&self) -> &VerifyingKey<C> {
130133
&self.verifying_key
131134
}
@@ -441,7 +444,7 @@ where
441444
// Other trait impls
442445
//
443446

444-
#[cfg(feature = "signature")]
447+
#[cfg(feature = "algorithm")]
445448
impl<C> AsRef<VerifyingKey<C>> for SigningKey<C>
446449
where
447450
C: EcdsaCurve + CurveArithmetic,
@@ -512,12 +515,12 @@ where
512515
SignatureSize<C>: ArraySize,
513516
{
514517
fn from(secret_scalar: NonZeroScalar<C>) -> Self {
515-
#[cfg(feature = "signature")]
518+
#[cfg(feature = "algorithm")]
516519
let public_key = PublicKey::from_secret_scalar(&secret_scalar);
517520

518521
Self {
519522
secret_scalar,
520-
#[cfg(feature = "signature")]
523+
#[cfg(feature = "algorithm")]
521524
verifying_key: public_key.into(),
522525
}
523526
}
@@ -588,7 +591,7 @@ where
588591
{
589592
}
590593

591-
#[cfg(feature = "signature")]
594+
#[cfg(feature = "algorithm")]
592595
impl<C> From<SigningKey<C>> for VerifyingKey<C>
593596
where
594597
C: EcdsaCurve + CurveArithmetic,
@@ -600,7 +603,7 @@ where
600603
}
601604
}
602605

603-
#[cfg(feature = "signature")]
606+
#[cfg(feature = "algorithm")]
604607
impl<C> From<&SigningKey<C>> for VerifyingKey<C>
605608
where
606609
C: EcdsaCurve + CurveArithmetic,
@@ -612,7 +615,7 @@ where
612615
}
613616
}
614617

615-
#[cfg(feature = "signature")]
618+
#[cfg(feature = "algorithm")]
616619
impl<C> KeypairRef for SigningKey<C>
617620
where
618621
C: EcdsaCurve + CurveArithmetic,

0 commit comments

Comments
 (0)