Skip to content

Commit d0198a1

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 #712
1 parent 88e1efa commit d0198a1

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
@@ -665,20 +665,6 @@ impl pkcs8::EncodePrivateKey for SigningKey {
665665
}
666666
}
667667

668-
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
669-
impl pkcs8::spki::DynSignatureAlgorithmIdentifier for SigningKey {
670-
fn signature_algorithm_identifier(
671-
&self,
672-
) -> pkcs8::spki::Result<pkcs8::spki::AlgorithmIdentifierOwned> {
673-
// From https://datatracker.ietf.org/doc/html/rfc8410
674-
// `id-Ed25519 OBJECT IDENTIFIER ::= { 1 3 101 112 }`
675-
Ok(pkcs8::spki::AlgorithmIdentifier {
676-
oid: ed25519::pkcs8::ALGORITHM_OID,
677-
parameters: None,
678-
})
679-
}
680-
}
681-
682668
#[cfg(feature = "pkcs8")]
683669
impl TryFrom<pkcs8::KeypairBytes> for SigningKey {
684670
type Error = pkcs8::Error;
@@ -709,6 +695,14 @@ impl TryFrom<&pkcs8::KeypairBytes> for SigningKey {
709695
}
710696
}
711697

698+
#[cfg(feature = "pkcs8")]
699+
impl pkcs8::spki::SignatureAlgorithmIdentifier for SigningKey {
700+
type Params = pkcs8::spki::der::AnyRef<'static>;
701+
702+
const SIGNATURE_ALGORITHM_IDENTIFIER: pkcs8::spki::AlgorithmIdentifier<Self::Params> =
703+
<Signature as pkcs8::spki::AssociatedAlgorithmIdentifier>::ALGORITHM_IDENTIFIER;
704+
}
705+
712706
#[cfg(feature = "pkcs8")]
713707
impl From<SigningKey> for pkcs8::KeypairBytes {
714708
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
@@ -567,6 +567,14 @@ impl TryFrom<&[u8]> for VerifyingKey {
567567
}
568568
}
569569

570+
#[cfg(feature = "pkcs8")]
571+
impl pkcs8::spki::SignatureAlgorithmIdentifier for VerifyingKey {
572+
type Params = pkcs8::spki::der::AnyRef<'static>;
573+
574+
const SIGNATURE_ALGORITHM_IDENTIFIER: pkcs8::spki::AlgorithmIdentifier<Self::Params> =
575+
<ed25519::Signature as pkcs8::spki::AssociatedAlgorithmIdentifier>::ALGORITHM_IDENTIFIER;
576+
}
577+
570578
impl From<VerifyingKey> for EdwardsPoint {
571579
fn from(vk: VerifyingKey) -> EdwardsPoint {
572580
vk.point
@@ -580,20 +588,6 @@ impl pkcs8::EncodePublicKey for VerifyingKey {
580588
}
581589
}
582590

583-
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
584-
impl pkcs8::spki::DynSignatureAlgorithmIdentifier for VerifyingKey {
585-
fn signature_algorithm_identifier(
586-
&self,
587-
) -> pkcs8::spki::Result<pkcs8::spki::AlgorithmIdentifierOwned> {
588-
// From https://datatracker.ietf.org/doc/html/rfc8410
589-
// `id-Ed25519 OBJECT IDENTIFIER ::= { 1 3 101 112 }`
590-
Ok(ed25519::pkcs8::spki::AlgorithmIdentifierOwned {
591-
oid: ed25519::pkcs8::ALGORITHM_OID,
592-
parameters: None,
593-
})
594-
}
595-
}
596-
597591
#[cfg(feature = "pkcs8")]
598592
impl TryFrom<pkcs8::PublicKeyBytes> for VerifyingKey {
599593
type Error = pkcs8::spki::Error;

0 commit comments

Comments
 (0)