Skip to content

Commit 45fe401

Browse files
authored
fix: align bignp256 pkcs8 feature gating (#1655)
1 parent c9d6b42 commit 45fe401

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

bignp256/src/public_key.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
//! Public key types and traits
22
// TODO(tarcieri): replace with `elliptic_curve::PublicKey`
33

4-
use crate::{ALGORITHM_OID, AffinePoint, BignP256, NonZeroScalar, ProjectivePoint, Sec1Point};
4+
#[cfg(feature = "pkcs8")]
5+
use crate::ALGORITHM_OID;
6+
use crate::{AffinePoint, BignP256, NonZeroScalar, ProjectivePoint, Sec1Point};
57
use core::{fmt::Display, str::FromStr};
68
use elliptic_curve::{
79
CurveArithmetic, Error, Group,
810
array::Array,
911
point::NonIdentity,
1012
sec1::{FromSec1Point, ToSec1Point},
1113
};
14+
#[cfg(feature = "pkcs8")]
1215
use pkcs8::{
1316
AssociatedOid, DecodePublicKey, EncodePublicKey, ObjectIdentifier,
1417
spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier},

bignp256/src/secret_key.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
use core::str::FromStr;
55
use der::{SecretDocument, asn1::OctetStringRef};
66

7-
use crate::{ALGORITHM_OID, PublicKey, ScalarValue};
7+
#[cfg(feature = "pkcs8")]
8+
use crate::ALGORITHM_OID;
9+
use crate::{PublicKey, ScalarValue};
810
use elliptic_curve::{Error, Generate, array::typenum::Unsigned, zeroize::Zeroizing};
11+
#[cfg(feature = "pkcs8")]
912
use pkcs8::{
1013
AssociatedOid, DecodePrivateKey, EncodePrivateKey, ObjectIdentifier,
1114
spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier},
@@ -95,6 +98,7 @@ impl SecretKey {
9598
}
9699
}
97100

101+
#[cfg(feature = "pkcs8")]
98102
impl AssociatedAlgorithmIdentifier for SecretKey {
99103
type Params = ObjectIdentifier;
100104
const ALGORITHM_IDENTIFIER: AlgorithmIdentifier<Self::Params> = AlgorithmIdentifier {
@@ -135,6 +139,7 @@ impl Generate for SecretKey {
135139
}
136140
}
137141

142+
#[cfg(feature = "pkcs8")]
138143
impl TryFrom<pkcs8::PrivateKeyInfoRef<'_>> for SecretKey {
139144
type Error = pkcs8::Error;
140145

@@ -156,6 +161,7 @@ impl FromStr for SecretKey {
156161
}
157162
}
158163

164+
#[cfg(feature = "pkcs8")]
159165
impl EncodePrivateKey for SecretKey {
160166
fn to_pkcs8_der(&self) -> pkcs8::Result<SecretDocument> {
161167
let algorithm_identifier = pkcs8::AlgorithmIdentifierRef {

0 commit comments

Comments
 (0)