Skip to content

Commit cd3752c

Browse files
fixup! Add Ed448 signature support and implement related structures
1 parent 7399095 commit cd3752c

File tree

4 files changed

+49
-49
lines changed

4 files changed

+49
-49
lines changed

Cargo.lock

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ itertools = { version = "0.14.0", default-features = false }
6060
rsa_098 = { package = "rsa", version = "0.9.8", features = ["sha2"] }
6161
signature_220 = { package = "signature", version = "2.2.0" }
6262
rustls = { version = "0.23.31", default-features = false, features = ["std"] }
63-
spki = { version = "0.8.0-rc.4", default-features = false, features = [
64-
"alloc",
65-
] }
6663
x509-cert = { version = "0.2.5", default-features = false, features = [
6764
"builder",
6865
] }

src/verify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ pub const ALGORITHMS: WebPkiSupportedAlgorithms = WebPkiSupportedAlgorithms {
211211
&[
212212
#[cfg(feature = "eddsa-ed25519")]
213213
eddsa::ed25519::ED25519,
214-
// #[cfg(feature = "eddsa-ed448")]
215-
// eddsa::ed448::ED448,
214+
#[cfg(feature = "eddsa-ed448")]
215+
eddsa::ed448::ED448,
216216
]
217217
}
218218

src/verify/eddsa/ed448.rs

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,45 @@
1-
use ed448_goldilocks::{Signature, VerifyingKey};
2-
use pki_types::{AlgorithmIdentifier, InvalidSignature, SignatureVerificationAlgorithm};
3-
use signature::Verifier;
4-
5-
#[derive(Debug)]
6-
pub struct Ed448Verify;
7-
8-
impl Ed448Verify {
9-
fn verify_inner(
10-
public_key: &[u8],
11-
message: &[u8],
12-
signature: &[u8],
13-
) -> Result<(), crate::verify::Error> {
14-
let public_key = public_key.try_into()?;
15-
let signature = Signature::from_slice(signature)?;
16-
let verifying_key = VerifyingKey::from_bytes(public_key)?;
17-
verifying_key.verify(message, &signature)?;
18-
Ok(())
19-
}
20-
}
21-
22-
impl SignatureVerificationAlgorithm for Ed448Verify {
23-
fn public_key_alg_id(&self) -> AlgorithmIdentifier {
24-
todo!()
25-
}
26-
27-
fn signature_alg_id(&self) -> AlgorithmIdentifier {
28-
todo!()
29-
}
30-
31-
fn verify_signature(
32-
&self,
33-
public_key: &[u8],
34-
message: &[u8],
35-
signature: &[u8],
36-
) -> Result<(), InvalidSignature> {
37-
Self::verify_inner(public_key, message, signature).map_err(|_| InvalidSignature)
38-
}
39-
}
40-
41-
pub const ED448: &dyn SignatureVerificationAlgorithm = &Ed448Verify;
1+
use ed448_goldilocks::{Signature, VerifyingKey};
2+
use pki_types::{AlgorithmIdentifier, InvalidSignature, SignatureVerificationAlgorithm};
3+
use signature::Verifier;
4+
5+
#[derive(Debug)]
6+
pub struct Ed448Verify;
7+
8+
impl Ed448Verify {
9+
fn verify_inner(
10+
public_key: &[u8],
11+
message: &[u8],
12+
signature: &[u8],
13+
) -> Result<(), crate::verify::Error> {
14+
let public_key = public_key.try_into()?;
15+
let signature = Signature::from_slice(signature)?;
16+
let verifying_key = VerifyingKey::from_bytes(public_key)?;
17+
verifying_key.verify(message, &signature)?;
18+
Ok(())
19+
}
20+
}
21+
22+
// Until https://github.com/rustls/pki-types/pull/87 was released, we need to use this hack
23+
const ED448_IDENTIFIER: AlgorithmIdentifier =
24+
AlgorithmIdentifier::from_slice(&[0x06, 0x03, 0x2B, 0x65, 0x71]);
25+
26+
impl SignatureVerificationAlgorithm for Ed448Verify {
27+
fn public_key_alg_id(&self) -> AlgorithmIdentifier {
28+
ED448_IDENTIFIER
29+
}
30+
31+
fn signature_alg_id(&self) -> AlgorithmIdentifier {
32+
ED448_IDENTIFIER
33+
}
34+
35+
fn verify_signature(
36+
&self,
37+
public_key: &[u8],
38+
message: &[u8],
39+
signature: &[u8],
40+
) -> Result<(), InvalidSignature> {
41+
Self::verify_inner(public_key, message, signature).map_err(|_| InvalidSignature)
42+
}
43+
}
44+
45+
pub const ED448: &dyn SignatureVerificationAlgorithm = &Ed448Verify;

0 commit comments

Comments
 (0)