Skip to content

Commit

Permalink
Fix feature alloc and pem in pkcs1 (#1013)
Browse files Browse the repository at this point in the history
Avoid pulling in dep `pkcs8` or `zeroize` just because feature
`alloc`/`pem`/`std` is enabled.

Also removes unused dependency `zeeroize` and replace it with a feature.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu authored Apr 21, 2023
1 parent b020fcd commit 5bd941f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkcs1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ spki = { version = "0.7" }

# optional dependencies
pkcs8 = { version = "0.10", optional = true, default-features = false }
zeroize = { version = "1", optional = true, default-features = false }

[dev-dependencies]
const-oid = { version = "0.9", features = ["db"] } # TODO: path = "../const-oid"
hex-literal = "0.4"
tempfile = "3"

[features]
alloc = ["der/alloc", "pkcs8/alloc", "zeroize/alloc"]
pem = ["alloc", "der/pem", "pkcs8/pem"]
zeroize = ["der/zeroize"]
alloc = ["der/alloc", "zeroize", "pkcs8?/alloc"]
pem = ["alloc", "der/pem", "pkcs8?/pem"]
std = ["der/std", "alloc"]

[package.metadata.docs.rs]
Expand Down
10 changes: 5 additions & 5 deletions pkcs1/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
use crate::Result;

#[cfg(feature = "alloc")]
use {
crate::{RsaPrivateKey, RsaPublicKey},
der::SecretDocument,
};
use der::{Document, SecretDocument};

#[cfg(feature = "pem")]
use {
Expand All @@ -24,8 +21,11 @@ use {
#[cfg(feature = "std")]
use std::path::Path;

#[cfg(all(feature = "alloc", feature = "pem"))]
use crate::{RsaPrivateKey, RsaPublicKey};

#[cfg(all(feature = "alloc", feature = "pkcs8"))]
use der::{Decode, Document};
use der::Decode;

/// Parse an [`RsaPrivateKey`] from a PKCS#1-encoded document.
pub trait DecodeRsaPrivateKey: Sized {
Expand Down

0 comments on commit 5bd941f

Please sign in to comment.