Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bignp256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ arithmetic = ["dep:primefield", "dep:primeorder", "elliptic-curve/arithmetic"]
bits = ["arithmetic", "elliptic-curve/bits"]
ecdsa = ["arithmetic", "dep:rfc6979", "dep:signature", "dep:belt-hash"]
getrandom = ["elliptic-curve/getrandom"]
pem = ["pkcs8/pem", "sec1/pem"]
pem = ["pkcs8", "pkcs8/pem", "sec1/pem"]
pkcs8 = ["dep:pkcs8"]
ecdh = ["arithmetic", "elliptic-curve/ecdh", "dep:digest", "dep:hkdf", "dep:hmac", "dep:belt-hash", "alloc"]
serde = ["elliptic-curve/serde", "primeorder?/serde"]
Expand Down
5 changes: 4 additions & 1 deletion bignp256/src/public_key.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
//! Public key types and traits
// TODO(tarcieri): replace with `elliptic_curve::PublicKey`

use crate::{ALGORITHM_OID, AffinePoint, BignP256, NonZeroScalar, ProjectivePoint, Sec1Point};
#[cfg(feature = "pkcs8")]
use crate::ALGORITHM_OID;
use crate::{AffinePoint, BignP256, NonZeroScalar, ProjectivePoint, Sec1Point};
use core::{fmt::Display, str::FromStr};
use elliptic_curve::{
CurveArithmetic, Error, Group,
array::Array,
point::NonIdentity,
sec1::{FromSec1Point, ToSec1Point},
};
#[cfg(feature = "pkcs8")]
use pkcs8::{
AssociatedOid, DecodePublicKey, EncodePublicKey, ObjectIdentifier,
spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier},
Expand Down
8 changes: 7 additions & 1 deletion bignp256/src/secret_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
use core::str::FromStr;
use der::{SecretDocument, asn1::OctetStringRef};

use crate::{ALGORITHM_OID, PublicKey, ScalarValue};
#[cfg(feature = "pkcs8")]
use crate::ALGORITHM_OID;
use crate::{PublicKey, ScalarValue};
use elliptic_curve::{Error, Generate, array::typenum::Unsigned, zeroize::Zeroizing};
#[cfg(feature = "pkcs8")]
use pkcs8::{
AssociatedOid, DecodePrivateKey, EncodePrivateKey, ObjectIdentifier,
spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier},
Expand Down Expand Up @@ -95,6 +98,7 @@ impl SecretKey {
}
}

#[cfg(feature = "pkcs8")]
impl AssociatedAlgorithmIdentifier for SecretKey {
type Params = ObjectIdentifier;
const ALGORITHM_IDENTIFIER: AlgorithmIdentifier<Self::Params> = AlgorithmIdentifier {
Expand Down Expand Up @@ -135,6 +139,7 @@ impl Generate for SecretKey {
}
}

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

Expand All @@ -155,6 +160,7 @@ impl FromStr for SecretKey {
}
}

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