Skip to content

Commit c9c6f68

Browse files
committed
ed25519-dalek: use SignatureAlgorithmIdenfier instead of the dynamic counterpart
This allows to use ed25519 to create certificates for example This partially reverts dalek-cryptography#712
1 parent a9aa947 commit c9c6f68

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

ed25519-dalek/src/signing.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -672,20 +672,6 @@ impl pkcs8::EncodePrivateKey for SigningKey {
672672
}
673673
}
674674

675-
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
676-
impl pkcs8::spki::DynSignatureAlgorithmIdentifier for SigningKey {
677-
fn signature_algorithm_identifier(
678-
&self,
679-
) -> pkcs8::spki::Result<pkcs8::spki::AlgorithmIdentifierOwned> {
680-
// From https://datatracker.ietf.org/doc/html/rfc8410
681-
// `id-Ed25519 OBJECT IDENTIFIER ::= { 1 3 101 112 }`
682-
Ok(pkcs8::spki::AlgorithmIdentifier {
683-
oid: ed25519::pkcs8::ALGORITHM_OID,
684-
parameters: None,
685-
})
686-
}
687-
}
688-
689675
#[cfg(feature = "pkcs8")]
690676
impl TryFrom<pkcs8::KeypairBytes> for SigningKey {
691677
type Error = pkcs8::Error;
@@ -716,6 +702,14 @@ impl TryFrom<&pkcs8::KeypairBytes> for SigningKey {
716702
}
717703
}
718704

705+
#[cfg(feature = "pkcs8")]
706+
impl pkcs8::spki::SignatureAlgorithmIdentifier for SigningKey {
707+
type Params = pkcs8::spki::der::AnyRef<'static>;
708+
709+
const SIGNATURE_ALGORITHM_IDENTIFIER: pkcs8::spki::AlgorithmIdentifier<Self::Params> =
710+
<Signature as pkcs8::spki::AssociatedAlgorithmIdentifier>::ALGORITHM_IDENTIFIER;
711+
}
712+
719713
#[cfg(feature = "pkcs8")]
720714
impl From<SigningKey> for pkcs8::KeypairBytes {
721715
fn from(signing_key: SigningKey) -> pkcs8::KeypairBytes {

ed25519-dalek/src/verifying.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,14 @@ impl TryFrom<&[u8]> for VerifyingKey {
610610
}
611611
}
612612

613+
#[cfg(feature = "pkcs8")]
614+
impl pkcs8::spki::SignatureAlgorithmIdentifier for VerifyingKey {
615+
type Params = pkcs8::spki::der::AnyRef<'static>;
616+
617+
const SIGNATURE_ALGORITHM_IDENTIFIER: pkcs8::spki::AlgorithmIdentifier<Self::Params> =
618+
<ed25519::Signature as pkcs8::spki::AssociatedAlgorithmIdentifier>::ALGORITHM_IDENTIFIER;
619+
}
620+
613621
impl From<VerifyingKey> for EdwardsPoint {
614622
fn from(vk: VerifyingKey) -> EdwardsPoint {
615623
vk.point
@@ -623,20 +631,6 @@ impl pkcs8::EncodePublicKey for VerifyingKey {
623631
}
624632
}
625633

626-
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
627-
impl pkcs8::spki::DynSignatureAlgorithmIdentifier for VerifyingKey {
628-
fn signature_algorithm_identifier(
629-
&self,
630-
) -> pkcs8::spki::Result<pkcs8::spki::AlgorithmIdentifierOwned> {
631-
// From https://datatracker.ietf.org/doc/html/rfc8410
632-
// `id-Ed25519 OBJECT IDENTIFIER ::= { 1 3 101 112 }`
633-
Ok(ed25519::pkcs8::spki::AlgorithmIdentifierOwned {
634-
oid: ed25519::pkcs8::ALGORITHM_OID,
635-
parameters: None,
636-
})
637-
}
638-
}
639-
640634
#[cfg(feature = "pkcs8")]
641635
impl TryFrom<pkcs8::PublicKeyBytes> for VerifyingKey {
642636
type Error = pkcs8::spki::Error;

0 commit comments

Comments
 (0)