Skip to content

Commit

Permalink
ecdsa: simplify serde feature (#874)
Browse files Browse the repository at this point in the history
To get `serde` support for `VerifyingKey`, confusingly the `pem` feature
previously needed to be enabled (even though PEM is not actually used).

This changed the `serde` feature to auto-enable `pkcs8`, similar to
what was done in the `elliptic-curve` crate.
  • Loading branch information
tarcieri authored Oct 18, 2024
1 parent 5109516 commit f46f4a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ecdsa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ digest = ["dep:digest", "signature/digest"]
hazmat = []
pkcs8 = ["digest", "elliptic-curve/pkcs8", "der"]
pem = ["elliptic-curve/pem", "pkcs8"]
serde = ["elliptic-curve/serde", "serdect"]
serde = ["elliptic-curve/serde", "pkcs8", "serdect"]
signing = ["arithmetic", "digest", "hazmat", "rfc6979"]
verifying = ["arithmetic", "digest", "hazmat"]

Expand Down
10 changes: 5 additions & 5 deletions ecdsa/src/verifying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ use elliptic_curve::pkcs8::{
AssociatedOid, ObjectIdentifier,
};

#[cfg(feature = "serde")]
use serdect::serde::{de, ser, Deserialize, Serialize};

#[cfg(feature = "sha2")]
use {
crate::{
Expand All @@ -48,9 +51,6 @@ use {
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
use elliptic_curve::pkcs8::EncodePublicKey;

#[cfg(all(feature = "pem", feature = "serde"))]
use serdect::serde::{de, ser, Deserialize, Serialize};

/// ECDSA public key used for verifying signatures. Generic over prime order
/// elliptic curves (e.g. NIST P-curves).
///
Expand Down Expand Up @@ -453,7 +453,7 @@ where
}
}

#[cfg(all(feature = "pem", feature = "serde"))]
#[cfg(feature = "serde")]
impl<C> Serialize for VerifyingKey<C>
where
C: EcdsaCurve + AssociatedOid + CurveArithmetic + PointCompression,
Expand All @@ -468,7 +468,7 @@ where
}
}

#[cfg(all(feature = "pem", feature = "serde"))]
#[cfg(feature = "serde")]
impl<'de, C> Deserialize<'de> for VerifyingKey<C>
where
C: EcdsaCurve + AssociatedOid + CurveArithmetic + PointCompression,
Expand Down

0 comments on commit f46f4a3

Please sign in to comment.