From 281be52e45582e769bb36cf641c78040e1c0e8fa Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Wed, 1 Dec 2021 10:42:08 -0700 Subject: [PATCH] ed25519: Rust 2021 edition upgrade Upgrades the Rust edition used by this crate to the latest available --- Cargo.lock | 22 +++++++++++----------- ed25519/Cargo.toml | 4 ++-- ed25519/README.md | 22 +++++++++++++++++----- ed25519/src/lib.rs | 31 ++++--------------------------- ed25519/src/pkcs8.rs | 5 +---- ed25519/tests/serde.rs | 6 ++---- 6 files changed, 37 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b11227b..2a6e7dec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,6 +171,15 @@ dependencies = [ [[package]] name = "ed25519" version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74e1069e39f1454367eb2de793ed062fac4c35c2934b76a81d90dd9abcd28816" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519" +version = "1.4.0-pre" dependencies = [ "bincode", "ed25519-dalek", @@ -184,15 +193,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "ed25519" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74e1069e39f1454367eb2de793ed062fac4c35c2934b76a81d90dd9abcd28816" -dependencies = [ - "signature", -] - [[package]] name = "ed25519-dalek" version = "1.0.1" @@ -200,7 +200,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek", - "ed25519 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519 1.3.0", "rand", "serde", "sha2", @@ -506,7 +506,7 @@ dependencies = [ "aead", "digest", "ecdsa 0.12.4", - "ed25519 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519 1.3.0", "generic-array", "opaque-debug", "p256", diff --git a/ed25519/Cargo.toml b/ed25519/Cargo.toml index 55cc62ab..f66825e2 100644 --- a/ed25519/Cargo.toml +++ b/ed25519/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ed25519" -version = "1.3.0" +version = "1.4.0-pre" authors = ["RustCrypto Developers"] license = "Apache-2.0 OR MIT" description = """ @@ -10,10 +10,10 @@ decoding/encoding support """ documentation = "https://docs.rs/ed25519" repository = "https://github.com/RustCrypto/signatures/tree/master/ed25519" -edition = "2018" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["crypto", "curve25519", "ecc", "signature", "signing"] +edition = "2021" rust-version = "1.56" [dependencies] diff --git a/ed25519/README.md b/ed25519/README.md index d4ce8da9..e80d2071 100644 --- a/ed25519/README.md +++ b/ed25519/README.md @@ -10,6 +10,10 @@ [Edwards Digital Signature Algorithm (EdDSA)][1] over Curve25519 as specified in [RFC 8032][2]. +[Documentation][docs-link] + +## About + This crate doesn't contain an implementation of Ed25519, but instead contains an [`ed25519::Signature`][3] type which other crates can use in conjunction with the [`signature::Signer`][4] and [`signature::Verifier`][5] @@ -20,14 +24,22 @@ to be written abstractly in such a way that different signer/verifier providers can be plugged in, enabling support for using different Ed25519 implementations, including HSMs or Cloud KMS services. -[Documentation][docs-link] - ## Minimum Supported Rust Version -This crate requires **Rust 1.56** at a minimum. +This crate requires **Rust 1.56** at a minimum as it is a Rust 2021 edition crate. + +Previous 1.x releases of this crate supported an MSRV of 1.47. If you would +like to use this crate with earlier releases of Rust, use the following version +constraint in your project's Cargo.toml to constrain it to the supported +version range: + +```toml +[dependencies] +ed25519 = ">=1, <1.4" # ed25519 1.4 requires MSRV 1.56 +``` -We may change the MSRV in the future, but it will be accompanied by a minor -version bump. +Note that is our policy that we may change the MSRV in the future, but it will +be accompanied by a minor version bump. ## License diff --git a/ed25519/src/lib.rs b/ed25519/src/lib.rs index c98d9aab..ebe27c90 100644 --- a/ed25519/src/lib.rs +++ b/ed25519/src/lib.rs @@ -1,25 +1,5 @@ -//! Ed25519 signatures. -//! -//! Edwards Digital Signature Algorithm (EdDSA) over Curve25519 as specified in -//! RFC 8032: -//! -//! This crate doesn't contain an implementation of Ed25519, but instead -//! contains an [`ed25519::Signature`][`Signature`] type which other crates can -//! use in conjunction with the [`signature::Signer`] and -//! [`signature::Verifier`] traits defined in the [`signature`] crate. -//! -//! These traits allow crates which produce and consume Ed25519 signatures -//! to be written abstractly in such a way that different signing_key/verifier -//! providers can be plugged in, enabling support for using different -//! Ed25519 implementations, including HSMs or Cloud KMS services. -//! -//! ## Minimum Supported Rust Version -//! -//! Rust **1.56** or higher. -//! -//! Minimum supported Rust version may be changed in the future, but such -//! changes will be accompanied with a minor version bump. -//! +#![doc = include_str!("../README.md")] + //! # Using Ed25519 generically over algorithm implementations/providers //! //! By using the `ed25519` crate, you can write code which signs and verifies @@ -272,7 +252,7 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo_small.png", - html_root_url = "https://docs.rs/ed25519/1.3.0" + html_root_url = "https://docs.rs/ed25519/1.4.0-pre" )] #![forbid(unsafe_code)] #![warn(missing_docs, rust_2018_idioms, unused_qualifications)] @@ -286,10 +266,7 @@ pub use signature::{self, Error}; #[cfg(feature = "pkcs8")] pub use crate::pkcs8::KeypairBytes; -use core::{ - convert::{TryFrom, TryInto}, - fmt, str, -}; +use core::{fmt, str}; #[cfg(feature = "serde")] use serde::{de, ser, Deserialize, Serialize}; diff --git a/ed25519/src/pkcs8.rs b/ed25519/src/pkcs8.rs index 92e77e8b..31db14ec 100644 --- a/ed25519/src/pkcs8.rs +++ b/ed25519/src/pkcs8.rs @@ -8,10 +8,7 @@ pub use pkcs8::DecodePrivateKey; #[cfg(feature = "alloc")] pub use pkcs8::EncodePrivateKey; -use core::{ - convert::{TryFrom, TryInto}, - fmt, -}; +use core::fmt; use pkcs8::ObjectIdentifier; #[cfg(feature = "zeroize")] diff --git a/ed25519/tests/serde.rs b/ed25519/tests/serde.rs index 85fc2120..c5b5baad 100644 --- a/ed25519/tests/serde.rs +++ b/ed25519/tests/serde.rs @@ -3,8 +3,6 @@ #![cfg(feature = "serde")] use ed25519::Signature; -use signature::Signature as _; -use std::{convert::TryFrom, vec::Vec}; #[cfg(feature = "serde_bytes")] use serde_bytes_crate as serde_bytes; @@ -25,7 +23,7 @@ fn test_serialize() { #[test] fn test_deserialize() { let signature = bincode::deserialize::(&EXAMPLE_SIGNATURE).unwrap(); - assert_eq!(&EXAMPLE_SIGNATURE[..], signature.as_bytes()); + assert_eq!(&EXAMPLE_SIGNATURE[..], signature.as_ref()); } #[cfg(feature = "serde_bytes")] @@ -62,5 +60,5 @@ fn test_deserialize_bytes() { let signature: Signature = serde_bytes::deserialize(&mut deserializer).unwrap(); - assert_eq!(&EXAMPLE_SIGNATURE[..], signature.as_bytes()); + assert_eq!(&EXAMPLE_SIGNATURE[..], signature.as_ref()); }