Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ed448: Ed448 Implementation #727

Merged
merged 11 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/ed448.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: ed448
on:
pull_request:
paths:
- "ed448/**"
- "Cargo.*"
push:
branches: master

defaults:
run:
working-directory: ed448

env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- thumbv7em-none-eabi
- wasm32-unknown-unknown
toolchain:
- 1.60.0 # MSRV
- stable
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
targets: ${{ matrix.target }}
toolchain: ${{ matrix.toolchain }}
- run: cargo build --target ${{ matrix.target }} --release --no-default-features
- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc
# TODO(tarcieri): re-enable the following when MSRV is 1.65
#- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pem
#- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8
#- run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc,pem,pkcs8

test:
strategy:
matrix:
toolchain:
- 1.65.0 # Technically MSRV is 1.60, but we have 1.65 dev-dependencies (i.e. ring-compat)
- stable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- run: cargo test --release --no-default-features
- run: cargo test --release
- run: cargo test --release --all-features
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resolver = "2"
members = [
"dsa",
"ecdsa",
"ed448",
"ed25519",
"rfc6979"
]
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ and can be easily used for bare-metal or lightweight WebAssembly programming.
|-------------|-----------|-----------|---------------|-------|
| [`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)
| [`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) |
| [`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)
| [`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) |
| [`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)
| [`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)

## Usage
Expand Down Expand Up @@ -49,6 +50,7 @@ dual licensed as above, without any additional terms or conditions.

[`dsa`]: ./dsa
[`ecdsa`]: ./ecdsa
[`ed448`]: ./ed448
[`ed25519`]: ./ed25519
[`rfc6979`]: ./rfc6979

Expand Down
4 changes: 2 additions & 2 deletions ed25519/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ for the default feature set.

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

## License
Expand Down Expand Up @@ -74,7 +74,7 @@ dual licensed as above, without any additional terms or conditions.

[//]: # (footnotes)

[1]: https://en.wikipedia.org/wiki/EdDSA
[1]: https://en.wikipedia.org/wiki/EdDSA#Ed25519
[2]: https://tools.ietf.org/html/rfc8032
[3]: https://docs.rs/ed25519/latest/ed25519/struct.Signature.html
[4]: https://docs.rs/signature/latest/signature/trait.Signer.html
Expand Down
5 changes: 3 additions & 2 deletions ed25519/src/pkcs8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
//! Please lock to a specific minor version of the `ed25519` crate to avoid
//! breaking changes when using this module.

pub use pkcs8::{spki, DecodePrivateKey, DecodePublicKey, Error, PrivateKeyInfo, Result};
pub use pkcs8::{
spki, DecodePrivateKey, DecodePublicKey, Error, ObjectIdentifier, PrivateKeyInfo, Result,
};

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

use core::fmt;
use pkcs8::ObjectIdentifier;

#[cfg(feature = "pem")]
use {
Expand Down
6 changes: 3 additions & 3 deletions ed25519/tests/pkcs8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn decode_pkcs8_v1() {
let keypair = KeypairBytes::from_pkcs8_der(PKCS8_V1_DER).unwrap();

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

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

// Extracted with:
// $ openssl pkey -inform der -in pkcs8-v1.der -pubout -text
// $ openssl pkey -inform der -in tests/examples/pkcs8-v1.der -pubout -text
assert_eq!(
public_key.as_ref(),
&hex!("19BF44096984CDFE8541BAC167DC3B96C85086AA30B6B6CB0C5C38AD703166E1")
Expand Down
35 changes: 35 additions & 0 deletions ed448/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "ed448-signature"
version = "0.1.0"
edition = "2021"
authors = ["RustCrypto Developers"]
license = "Apache-2.0 OR MIT"
description = """
Edwards Digital Signature Algorithm (EdDSA) over Curve448 (as specified in RFC 7748)
support library providing signature type definitions and PKCS#8 private key
decoding/encoding support
"""
documentation = "https://docs.rs/ed448-signature"
repository = "https://github.com/RustCrypto/signatures/tree/master/ed448-signature"
readme = "README.md"
categories = ["cryptography", "no-std"]
keywords = ["crypto", "curve448", "ecc", "signature", "signing"]

[dependencies]
signature = { version = "2", default-features = false }

# optional dependencies
pkcs8 = { version = "0.10", optional = true }
serde = { version = "1", optional = true, default-features = false }
serde_bytes = { version = "0.11", optional = true }

[dev-dependencies]
hex-literal = "0.4"
bincode = "1"

[features]
default = ["std"]
alloc = ["pkcs8?/alloc"]
pem = ["alloc", "pkcs8/pem"]
serde_bytes = ["serde", "dep:serde_bytes"]
std = ["signature/std"]
Loading
Loading