ed25519-dalek: use SignatureAlgorithmIdenfier instead of the dynamic counterpart (#779)

This allows to use ed25519 to create certificates for example

This partially reverts #712
This commit is contained in:
Arthur Gautier 2025-07-07 21:57:47 +02:00 committed by GitHub
parent a99efe2304
commit d159f47f53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 28 deletions

View file

@ -676,20 +676,6 @@ impl pkcs8::EncodePrivateKey for SigningKey {
}
}
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
impl pkcs8::spki::DynSignatureAlgorithmIdentifier for SigningKey {
fn signature_algorithm_identifier(
&self,
) -> pkcs8::spki::Result<pkcs8::spki::AlgorithmIdentifierOwned> {
// From https://datatracker.ietf.org/doc/html/rfc8410
// `id-Ed25519 OBJECT IDENTIFIER ::= { 1 3 101 112 }`
Ok(pkcs8::spki::AlgorithmIdentifier {
oid: ed25519::pkcs8::ALGORITHM_OID,
parameters: None,
})
}
}
#[cfg(feature = "pkcs8")]
impl TryFrom<pkcs8::KeypairBytes> for SigningKey {
type Error = pkcs8::Error;
@ -720,6 +706,14 @@ impl TryFrom<&pkcs8::KeypairBytes> for SigningKey {
}
}
#[cfg(feature = "pkcs8")]
impl pkcs8::spki::SignatureAlgorithmIdentifier for SigningKey {
type Params = pkcs8::spki::der::AnyRef<'static>;
const SIGNATURE_ALGORITHM_IDENTIFIER: pkcs8::spki::AlgorithmIdentifier<Self::Params> =
<Signature as pkcs8::spki::AssociatedAlgorithmIdentifier>::ALGORITHM_IDENTIFIER;
}
#[cfg(feature = "pkcs8")]
impl From<SigningKey> for pkcs8::KeypairBytes {
fn from(signing_key: SigningKey) -> pkcs8::KeypairBytes {

View file

@ -610,6 +610,14 @@ impl TryFrom<&[u8]> for VerifyingKey {
}
}
#[cfg(feature = "pkcs8")]
impl pkcs8::spki::SignatureAlgorithmIdentifier for VerifyingKey {
type Params = pkcs8::spki::der::AnyRef<'static>;
const SIGNATURE_ALGORITHM_IDENTIFIER: pkcs8::spki::AlgorithmIdentifier<Self::Params> =
<ed25519::Signature as pkcs8::spki::AssociatedAlgorithmIdentifier>::ALGORITHM_IDENTIFIER;
}
impl From<VerifyingKey> for EdwardsPoint {
fn from(vk: VerifyingKey) -> EdwardsPoint {
vk.point
@ -623,20 +631,6 @@ impl pkcs8::EncodePublicKey for VerifyingKey {
}
}
#[cfg(all(feature = "alloc", feature = "pkcs8"))]
impl pkcs8::spki::DynSignatureAlgorithmIdentifier for VerifyingKey {
fn signature_algorithm_identifier(
&self,
) -> pkcs8::spki::Result<pkcs8::spki::AlgorithmIdentifierOwned> {
// From https://datatracker.ietf.org/doc/html/rfc8410
// `id-Ed25519 OBJECT IDENTIFIER ::= { 1 3 101 112 }`
Ok(ed25519::pkcs8::spki::AlgorithmIdentifierOwned {
oid: ed25519::pkcs8::ALGORITHM_OID,
parameters: None,
})
}
}
#[cfg(feature = "pkcs8")]
impl TryFrom<pkcs8::PublicKeyBytes> for VerifyingKey {
type Error = pkcs8::spki::Error;