Skip to content

Commit 77c386e

Browse files
authored
pkcs8: replace subtle with ctutils (#2308)
See RustCrypto/meta#29
1 parent 967d9f1 commit 77c386e

4 files changed

Lines changed: 12 additions & 15 deletions

File tree

Cargo.lock

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

pkcs8/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ der = { version = "0.8.0-rc.12", features = ["oid"] }
2121
spki = "0.8"
2222

2323
# optional dependencies
24-
rand_core = { version = "0.10", optional = true, default-features = false }
24+
ctutils = { version = "0.4", optional = true }
2525
pkcs5 = { version = "0.8", optional = true, features = ["rand_core"] }
26-
subtle = { version = "2", optional = true, default-features = false }
26+
rand_core = { version = "0.10", optional = true, default-features = false }
2727

2828
[dev-dependencies]
2929
hex-literal = "1"

pkcs8/src/private_key_info.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,20 @@ use der::{
99
};
1010
use spki::AlgorithmIdentifier;
1111

12+
#[cfg(feature = "ctutils")]
13+
use ctutils::{Choice, CtEq};
14+
#[cfg(feature = "pem")]
15+
use der::pem::PemLabel;
1216
#[cfg(feature = "alloc")]
1317
use der::{
1418
SecretDocument,
1519
asn1::{Any, BitString, OctetString},
1620
};
17-
1821
#[cfg(feature = "encryption")]
1922
use {
2023
crate::EncryptedPrivateKeyInfoRef, der::zeroize::Zeroizing, pkcs5::pbes2, rand_core::CryptoRng,
2124
};
2225

23-
#[cfg(feature = "pem")]
24-
use der::pem::PemLabel;
25-
26-
#[cfg(feature = "subtle")]
27-
use subtle::{Choice, ConstantTimeEq};
28-
2926
/// Context-specific tag number for attributes.
3027
const ATTRIBUTES_TAG: TagNumber = TagNumber(0);
3128

@@ -336,8 +333,8 @@ impl<Params, Key, PubKey> PemLabel for PrivateKeyInfo<Params, Key, PubKey> {
336333
const PEM_LABEL: &'static str = "PRIVATE KEY";
337334
}
338335

339-
#[cfg(feature = "subtle")]
340-
impl<Params, Key, PubKey> ConstantTimeEq for PrivateKeyInfo<Params, Key, PubKey>
336+
#[cfg(feature = "ctutils")]
337+
impl<Params, Key, PubKey> CtEq for PrivateKeyInfo<Params, Key, PubKey>
341338
where
342339
Params: Eq,
343340
Key: PartialEq + AsRef<[u8]>,
@@ -353,7 +350,7 @@ where
353350
}
354351
}
355352

356-
#[cfg(feature = "subtle")]
353+
#[cfg(feature = "ctutils")]
357354
impl<Params, Key, PubKey> Eq for PrivateKeyInfo<Params, Key, PubKey>
358355
where
359356
Params: Eq,
@@ -362,7 +359,7 @@ where
362359
{
363360
}
364361

365-
#[cfg(feature = "subtle")]
362+
#[cfg(feature = "ctutils")]
366363
impl<Params, Key, PubKey> PartialEq for PrivateKeyInfo<Params, Key, PubKey>
367364
where
368365
Params: Eq,

pkcs8/tests/private_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ fn encode_ed25519_der_v1() {
194194
}
195195

196196
#[test]
197-
#[cfg(all(feature = "alloc", feature = "subtle"))]
197+
#[cfg(all(feature = "alloc", feature = "ctutils"))]
198198
fn encode_ed25519_der_v2() {
199199
let private_key = PrivateKeyInfoRef::try_from(ED25519_DER_V2_EXAMPLE).unwrap();
200200
let private_der = private_key.to_der().unwrap();

0 commit comments

Comments
 (0)