Skip to content

Commit d9c304c

Browse files
authored
ed448: Ed448 Implementation (#727)
1 parent e8d4d23 commit d9c304c

22 files changed

+1150
-8
lines changed

.github/workflows/ed448.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: ed448
2+
on:
3+
pull_request:
4+
paths:
5+
- "ed448/**"
6+
- "Cargo.*"
7+
push:
8+
branches: master
9+
10+
defaults:
11+
run:
12+
working-directory: ed448
13+
14+
env:
15+
CARGO_INCREMENTAL: 0
16+
RUSTFLAGS: "-Dwarnings"
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
target:
24+
- thumbv7em-none-eabi
25+
- wasm32-unknown-unknown
26+
toolchain:
27+
- 1.60.0 # MSRV
28+
- stable
29+
steps:
30+
- uses: actions/checkout@v3
31+
- uses: dtolnay/rust-toolchain@master
32+
with:
33+
targets: ${{ matrix.target }}
34+
toolchain: ${{ matrix.toolchain }}
35+
- run: cargo build --target ${{ matrix.target }} --release --no-default-features
36+
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc
37+
# TODO(tarcieri): re-enable the following when MSRV is 1.65
38+
#- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pem
39+
#- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8
40+
#- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc,pem,pkcs8
41+
42+
test:
43+
strategy:
44+
matrix:
45+
toolchain:
46+
- 1.65.0 # Technically MSRV is 1.60, but we have 1.65 dev-dependencies (i.e. ring-compat)
47+
- stable
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v3
51+
- uses: dtolnay/rust-toolchain@master
52+
with:
53+
toolchain: ${{ matrix.toolchain }}
54+
- run: cargo test --release --no-default-features
55+
- run: cargo test --release
56+
- run: cargo test --release --all-features

Cargo.lock

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ resolver = "2"
33
members = [
44
"dsa",
55
"ecdsa",
6+
"ed448",
67
"ed25519",
78
"rfc6979"
89
]

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ and can be easily used for bare-metal or lightweight WebAssembly programming.
1515
|-------------|-----------|-----------|---------------|-------|
1616
| [`dsa`] | [DSA](https://en.wikipedia.org/wiki/Digital_Signature_Algorithm) | [![crates.io](https://img.shields.io/crates/v/dsa.svg)](https://crates.io/crates/dsa) | [![Documentation](https://docs.rs/dsa/badge.svg)](https://docs.rs/dsa) | [![dsa build](https://github.com/RustCrypto/signatures/workflows/dsa/badge.svg?branch=master&event=push)](https://github.com/RustCrypto/signatures/actions?query=workflow%3Adsa)
1717
| [`ecdsa`] | [ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm) | [![crates.io](https://img.shields.io/crates/v/ecdsa.svg)](https://crates.io/crates/ecdsa) | [![Documentation](https://docs.rs/ecdsa/badge.svg)](https://docs.rs/ecdsa) | [![ecdsa build](https://github.com/RustCrypto/signatures/workflows/ecdsa/badge.svg?branch=master&event=push)](https://github.com/RustCrypto/signatures/actions?query=workflow%3Aecdsa) |
18-
| [`ed25519`] | [Ed25519](https://en.wikipedia.org/wiki/EdDSA) | [![crates.io](https://img.shields.io/crates/v/ed25519.svg)](https://crates.io/crates/ed25519) | [![Documentation](https://docs.rs/ed25519/badge.svg)](https://docs.rs/ed25519) | [![ed25519 build](https://github.com/RustCrypto/signatures/workflows/ed25519/badge.svg?branch=master&event=push)](https://github.com/RustCrypto/signatures/actions?query=workflow%3Aed25519)
18+
| [`ed448`] | [Ed448](https://en.wikipedia.org/wiki/EdDSA#Ed448) | [![crates.io](https://img.shields.io/crates/v/ed448-signature.svg)](https://crates.io/crates/ed448-signature) | [![Documentation](https://docs.rs/ed448-signature/badge.svg)](https://docs.rs/ed448-signature) | [![ed448 build](https://github.com/RustCrypto/signatures/workflows/ed448-signature/badge.svg?branch=master&event=push)](https://github.com/RustCrypto/signatures/actions?query=workflow%3Aed448-signature) |
19+
| [`ed25519`] | [Ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) | [![crates.io](https://img.shields.io/crates/v/ed25519.svg)](https://crates.io/crates/ed25519) | [![Documentation](https://docs.rs/ed25519/badge.svg)](https://docs.rs/ed25519) | [![ed25519 build](https://github.com/RustCrypto/signatures/workflows/ed25519/badge.svg?branch=master&event=push)](https://github.com/RustCrypto/signatures/actions?query=workflow%3Aed25519)
1920
| [`rfc6979`] | [RFC6979](https://datatracker.ietf.org/doc/html/rfc6979) | [![crates.io](https://img.shields.io/crates/v/rfc6979.svg)](https://crates.io/crates/rfc6979) | [![Documentation](https://docs.rs/rfc6979/badge.svg)](https://docs.rs/rfc6979) | [![rfc6979 build](https://github.com/RustCrypto/signatures/actions/workflows/rfc6979.yml/badge.svg)](https://github.com/RustCrypto/signatures/actions/workflows/rfc6979.yml)
2021

2122
NOTE: for RSA signatures see <https://github.com/RustCrypto/RSA>
@@ -51,6 +52,7 @@ dual licensed as above, without any additional terms or conditions.
5152

5253
[`dsa`]: ./dsa
5354
[`ecdsa`]: ./ecdsa
55+
[`ed448`]: ./ed448
5456
[`ed25519`]: ./ed25519
5557
[`rfc6979`]: ./rfc6979
5658

ed25519/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ for the default feature set.
3737

3838
- All on-by-default features of this library are covered by SemVer
3939
- MSRV is considered exempt from SemVer as noted above
40-
- The `pkcs8` module is exempted as it uses a pre-1.0 dependency, however,
40+
- The `pkcs8` module is exempted as it uses a pre-1.0 dependency, however,
4141
breaking changes to this module will be accompanied by a minor version bump.
4242

4343
## License
@@ -74,7 +74,7 @@ dual licensed as above, without any additional terms or conditions.
7474

7575
[//]: # (footnotes)
7676

77-
[1]: https://en.wikipedia.org/wiki/EdDSA
77+
[1]: https://en.wikipedia.org/wiki/EdDSA#Ed25519
7878
[2]: https://tools.ietf.org/html/rfc8032
7979
[3]: https://docs.rs/ed25519/latest/ed25519/struct.Signature.html
8080
[4]: https://docs.rs/signature/latest/signature/trait.Signer.html

ed25519/src/pkcs8.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
//! Please lock to a specific minor version of the `ed25519` crate to avoid
1515
//! breaking changes when using this module.
1616
17-
pub use pkcs8::{spki, DecodePrivateKey, DecodePublicKey, Error, PrivateKeyInfo, Result};
17+
pub use pkcs8::{
18+
spki, DecodePrivateKey, DecodePublicKey, Error, ObjectIdentifier, PrivateKeyInfo, Result,
19+
};
1820

1921
#[cfg(feature = "alloc")]
2022
pub use pkcs8::{spki::EncodePublicKey, EncodePrivateKey};
@@ -23,7 +25,6 @@ pub use pkcs8::{spki::EncodePublicKey, EncodePrivateKey};
2325
pub use pkcs8::der::{asn1::BitStringRef, Document, SecretDocument};
2426

2527
use core::fmt;
26-
use pkcs8::ObjectIdentifier;
2728

2829
#[cfg(feature = "pem")]
2930
use {

ed25519/tests/pkcs8.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn decode_pkcs8_v1() {
2222
let keypair = KeypairBytes::from_pkcs8_der(PKCS8_V1_DER).unwrap();
2323

2424
// Extracted with:
25-
// $ openssl asn1parse -inform der -in tests/examples/p256-priv.der
25+
// $ openssl asn1parse -inform der -in tests/examples/pkcs8-v1.der
2626
assert_eq!(
2727
keypair.secret_key,
2828
&hex!("D4EE72DBF913584AD5B6D8F1F769F8AD3AFE7C28CBF1D4FBE097A88F44755842")[..]
@@ -36,7 +36,7 @@ fn decode_pkcs8_v2() {
3636
let keypair = KeypairBytes::from_pkcs8_der(PKCS8_V2_DER).unwrap();
3737

3838
// Extracted with:
39-
// $ openssl asn1parse -inform der -in tests/examples/p256-priv.der
39+
// $ openssl asn1parse -inform der -in tests/examples/pkcs8-v2.der
4040
assert_eq!(
4141
keypair.secret_key,
4242
&hex!("D4EE72DBF913584AD5B6D8F1F769F8AD3AFE7C28CBF1D4FBE097A88F44755842")[..]
@@ -53,7 +53,7 @@ fn decode_public_key() {
5353
let public_key = PublicKeyBytes::from_public_key_der(PUBLIC_KEY_DER).unwrap();
5454

5555
// Extracted with:
56-
// $ openssl pkey -inform der -in pkcs8-v1.der -pubout -text
56+
// $ openssl pkey -inform der -in tests/examples/pkcs8-v1.der -pubout -text
5757
assert_eq!(
5858
public_key.as_ref(),
5959
&hex!("19BF44096984CDFE8541BAC167DC3B96C85086AA30B6B6CB0C5C38AD703166E1")

ed448/Cargo.toml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[package]
2+
name = "ed448-signature"
3+
version = "0.1.0"
4+
edition = "2021"
5+
authors = ["RustCrypto Developers"]
6+
license = "Apache-2.0 OR MIT"
7+
description = """
8+
Edwards Digital Signature Algorithm (EdDSA) over Curve448 (as specified in RFC 7748)
9+
support library providing signature type definitions and PKCS#8 private key
10+
decoding/encoding support
11+
"""
12+
documentation = "https://docs.rs/ed448-signature"
13+
repository = "https://github.com/RustCrypto/signatures/tree/master/ed448-signature"
14+
readme = "README.md"
15+
categories = ["cryptography", "no-std"]
16+
keywords = ["crypto", "curve448", "ecc", "signature", "signing"]
17+
18+
[dependencies]
19+
signature = { version = "2", default-features = false }
20+
21+
# optional dependencies
22+
pkcs8 = { version = "0.10", optional = true }
23+
serde = { version = "1", optional = true, default-features = false }
24+
serde_bytes = { version = "0.11", optional = true }
25+
26+
[dev-dependencies]
27+
hex-literal = "0.4"
28+
bincode = "1"
29+
30+
[features]
31+
default = ["std"]
32+
alloc = ["pkcs8?/alloc"]
33+
pem = ["alloc", "pkcs8/pem"]
34+
serde_bytes = ["serde", "dep:serde_bytes"]
35+
std = ["signature/std"]

0 commit comments

Comments
 (0)