Skip to content
Merged
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
31 changes: 16 additions & 15 deletions 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 k256/src/ecdsa/sign.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! ECDSA signer
//! ECDSA signing support.

use super::{recoverable, Error, Signature, VerifyingKey};
use crate::{FieldBytes, NonZeroScalar, ProjectivePoint, PublicKey, Scalar, Secp256k1, SecretKey};
Expand Down Expand Up @@ -26,7 +26,7 @@ use elliptic_curve::{
use ecdsa_core::signature::{self, digest::Digest, PrehashSignature, RandomizedSigner};

#[cfg(feature = "pkcs8")]
use crate::pkcs8::{self, FromPrivateKey};
use crate::pkcs8::{self, DecodePrivateKey};

#[cfg(feature = "pem")]
use core::str::FromStr;
Expand Down Expand Up @@ -283,7 +283,7 @@ impl Drop for SigningKey {

#[cfg(feature = "pkcs8")]
#[cfg_attr(docsrs, doc(cfg(feature = "pkcs8")))]
impl FromPrivateKey for SigningKey {
impl DecodePrivateKey for SigningKey {
fn from_pkcs8_private_key_info(
private_key_info: pkcs8::PrivateKeyInfo<'_>,
) -> pkcs8::Result<Self> {
Expand Down
8 changes: 4 additions & 4 deletions k256/src/ecdsa/verify.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! ECDSA verifier
//! ECDSA verification support.

use super::{recoverable, Error, Signature};
use crate::{
Expand All @@ -18,7 +18,7 @@ use signature::{digest::Digest, DigestVerifier};
use signature::PrehashSignature;

#[cfg(feature = "pkcs8")]
use crate::pkcs8::{self, FromPublicKey};
use crate::pkcs8::{self, DecodePublicKey};

#[cfg(feature = "pem")]
use core::str::FromStr;
Expand Down Expand Up @@ -166,8 +166,8 @@ impl TryFrom<&EncodedPoint> for VerifyingKey {

#[cfg(feature = "pkcs8")]
#[cfg_attr(docsrs, doc(cfg(feature = "pkcs8")))]
impl FromPublicKey for VerifyingKey {
fn from_spki(spki: pkcs8::SubjectPublicKeyInfo<'_>) -> pkcs8::Result<Self> {
impl DecodePublicKey for VerifyingKey {
fn from_spki(spki: pkcs8::SubjectPublicKeyInfo<'_>) -> pkcs8::der::Result<Self> {
PublicKey::from_spki(spki).map(|pk| Self { inner: pk.into() })
}
}
Expand Down
8 changes: 5 additions & 3 deletions p256/tests/pkcs8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use hex_literal::hex;
use p256::{
elliptic_curve::sec1::ToEncodedPoint,
pkcs8::{FromPrivateKey, FromPublicKey},
pkcs8::{DecodePrivateKey, DecodePublicKey},
};

#[cfg(feature = "pem")]
use p256::elliptic_curve::pkcs8::{ToPrivateKey, ToPublicKey};
use p256::elliptic_curve::pkcs8::{EncodePrivateKey, EncodePublicKey};

/// DER-encoded PKCS#8 private key
const PKCS8_PRIVATE_KEY_DER: &[u8; 138] = include_bytes!("examples/pkcs8-private-key.der");
Expand Down Expand Up @@ -83,7 +83,9 @@ fn encode_pkcs8_public_key_to_der() {
#[cfg(feature = "pem")]
fn encode_pkcs8_private_key_to_pem() {
let original_secret_key = p256::SecretKey::from_pkcs8_der(&PKCS8_PRIVATE_KEY_DER[..]).unwrap();
let reencoded_secret_key = original_secret_key.to_pkcs8_pem().unwrap();
let reencoded_secret_key = original_secret_key
.to_pkcs8_pem(Default::default())
.unwrap();
assert_eq!(reencoded_secret_key.as_str(), PKCS8_PRIVATE_KEY_PEM);
}

Expand Down