Skip to content

Commit

Permalink
ecdsa: gate pkcs8::Encode*Key impls under alloc+pkcs8 (#783)
Browse files Browse the repository at this point in the history
...rather than `pem`, as these can be used to encode DER without having
full `pem` support enabled.

Closes #721
  • Loading branch information
tarcieri committed Jan 17, 2024
1 parent 55e4450 commit 970aacf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions ecdsa/src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ use signature::{
use {crate::der, core::ops::Add, elliptic_curve::FieldBytesSize};

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

#[cfg(feature = "pkcs8")]
use crate::elliptic_curve::{
Expand All @@ -45,6 +42,9 @@ use crate::elliptic_curve::{
#[cfg(feature = "verifying")]
use {crate::VerifyingKey, elliptic_curve::PublicKey, signature::KeypairRef};

#[cfg(all(feature = "alloc", feature = "pkcs8"))]
use elliptic_curve::pkcs8::{EncodePrivateKey, SecretDocument};

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

#[cfg(feature = "pem")]
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
impl<C> EncodePrivateKey for SigningKey<C>
where
C: AssociatedOid + PrimeCurve + CurveArithmetic,
Expand Down
10 changes: 5 additions & 5 deletions ecdsa/src/verifying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ use alloc::boxed::Box;
use {crate::der, core::ops::Add};

#[cfg(feature = "pem")]
use {
core::str::FromStr,
elliptic_curve::pkcs8::{DecodePublicKey, EncodePublicKey},
};
use {core::str::FromStr, elliptic_curve::pkcs8::DecodePublicKey};

#[cfg(feature = "pkcs8")]
use elliptic_curve::pkcs8::{
Expand All @@ -45,6 +42,9 @@ use {
sha2::{Sha224, Sha256, Sha384, Sha512},
};

#[cfg(all(feature = "alloc", feature = "pkcs8"))]
use elliptic_curve::pkcs8::EncodePublicKey;

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

Expand Down Expand Up @@ -425,7 +425,7 @@ where
}
}

#[cfg(feature = "pem")]
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
impl<C> EncodePublicKey for VerifyingKey<C>
where
C: PrimeCurve + AssociatedOid + CurveArithmetic + PointCompression,
Expand Down

0 comments on commit 970aacf

Please sign in to comment.