From 9f9f3d7329ce2776d3945d9e98f5bab9069559bf Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 11 Nov 2023 21:54:44 -0700 Subject: [PATCH] (async-)signature: MSRV 1.60 To simplify the workspace, which contains weak/namespaced features, this bumps both `async-signature` and `signature` to MSRV 1.60. So as for the bump to have some justification, it adds weak feature activation for `rand_core?/std`, and uses this impl to write a `From` conversion which can preserve the original error as the boxed source. --- .github/workflows/async-signature.yml | 2 +- .github/workflows/signature.yml | 6 +- Cargo.lock | 49 ++++++- Cargo.toml | 5 +- crypto/Cargo.toml | 2 +- signature/Cargo.lock | 189 -------------------------- signature/Cargo.toml | 10 +- signature/README.md | 4 +- signature/async/Cargo.toml | 6 +- signature/async/README.md | 4 +- signature/src/error.rs | 13 ++ 11 files changed, 77 insertions(+), 213 deletions(-) delete mode 100644 signature/Cargo.lock diff --git a/.github/workflows/async-signature.yml b/.github/workflows/async-signature.yml index 497530a18..9d7da9f11 100644 --- a/.github/workflows/async-signature.yml +++ b/.github/workflows/async-signature.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: rust: - - 1.56.0 # MSRV + - 1.60.0 # MSRV - stable steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/signature.yml b/.github/workflows/signature.yml index 4816bd0e8..43cd3651e 100644 --- a/.github/workflows/signature.yml +++ b/.github/workflows/signature.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: rust: - - 1.56.0 # MSRV + - 1.60.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -51,7 +51,7 @@ jobs: strategy: matrix: rust: - - 1.56.0 # MSRV + - 1.60.0 # MSRV - stable steps: - uses: actions/checkout@v4 @@ -69,7 +69,7 @@ jobs: strategy: matrix: rust: - - 1.56.0 # MSRV + - 1.60.0 # MSRV - stable steps: - uses: actions/checkout@v4 diff --git a/Cargo.lock b/Cargo.lock index 363715652..8509c494b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,6 +54,25 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "async-signature" +version = "0.4.0-pre" +dependencies = [ + "async-trait", + "signature 2.2.0-pre", +] + +[[package]] +name = "async-trait" +version = "0.1.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atomic-polyfill" version = "0.1.11" @@ -484,7 +503,7 @@ dependencies = [ "ff 0.13.0", "generic-array", "group 0.13.0", - "hex-literal", + "hex-literal 0.4.1", "hkdf 0.12.3", "pem-rfc7468 0.7.0", "pkcs8 0.10.2", @@ -629,6 +648,12 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + [[package]] name = "hex-literal" version = "0.4.1" @@ -1134,6 +1159,28 @@ dependencies = [ [[package]] name = "signature" version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" + +[[package]] +name = "signature" +version = "2.2.0-pre" +dependencies = [ + "digest 0.10.7", + "hex-literal 0.3.4", + "rand_core 0.6.4", + "sha2 0.10.8", + "signature_derive", +] + +[[package]] +name = "signature_derive" +version = "2.0.1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "spin" diff --git a/Cargo.toml b/Cargo.toml index 90727b25a..01eb142f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,12 +9,9 @@ members = [ "elliptic-curve", "kem", "password-hash", - "universal-hash", -] -# TODO: re-add to `members` when MSRV has been bumped to 1.60+ -exclude = [ "signature", "signature/async", + "universal-hash", ] [patch.crates-io] diff --git a/crypto/Cargo.toml b/crypto/Cargo.toml index 95db1199a..8f31c6e17 100644 --- a/crypto/Cargo.toml +++ b/crypto/Cargo.toml @@ -21,7 +21,7 @@ cipher = { version = "0.4", optional = true } digest = { version = "0.10", optional = true, features = ["mac"] } elliptic-curve = { version = "0.13", optional = true, path = "../elliptic-curve" } password-hash = { version = "0.5", optional = true, path = "../password-hash" } -signature = { version = "2", optional = true, default-features = false, path = "../signature" } +signature = { version = "2", optional = true, default-features = false } universal-hash = { version = "0.5", optional = true } [features] diff --git a/signature/Cargo.lock b/signature/Cargo.lock deleted file mode 100644 index 470272724..000000000 --- a/signature/Cargo.lock +++ /dev/null @@ -1,189 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "async-signature" -version = "0.3.0" -dependencies = [ - "async-trait", - "signature", -] - -[[package]] -name = "async-trait" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62d042b64fd281d31d58e80ac29426e114ae8eead17beb12fbd396a1d04eee84" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.0", -] - -[[package]] -name = "block-buffer" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03588e54c62ae6d763e2a80090d50353b785795361b4ff5b3bf0a5097fc31c0b" -dependencies = [ - "generic-array", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "cpufeatures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" -dependencies = [ - "libc", -] - -[[package]] -name = "crypto-common" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "digest" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" -dependencies = [ - "block-buffer", - "crypto-common", -] - -[[package]] -name = "generic-array" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "hex-literal" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc38ca401ca1b8d89ff1185e39a132e5c4f86d844c0cf6364251576f2d7fa0c1" - -[[package]] -name = "libc" -version = "0.2.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" - -[[package]] -name = "proc-macro2" -version = "1.0.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" - -[[package]] -name = "sha2" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c3bd8169c58782adad9290a9af5939994036b76187f7b4f0e6de91dbbfc0ec" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - -[[package]] -name = "signature" -version = "2.1.0" -dependencies = [ - "digest", - "hex-literal", - "rand_core", - "sha2", - "signature_derive", -] - -[[package]] -name = "signature_derive" -version = "2.0.1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.0", -] - -[[package]] -name = "syn" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f8c8eab7d9f493cd89d4068085651d81ac7d39c56eb64f7158ea514b156e280" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "syn" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cff13bb1732bccfe3b246f3fdb09edfd51c01d6f5299b7ccd9457c2e4e37774" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "typenum" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" - -[[package]] -name = "unicode-ident" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" - -[[package]] -name = "version_check" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45d3d553fd9413fffe7147a20171d640eda0ad4c070acd7d0c885a21bcd2e8b7" diff --git a/signature/Cargo.toml b/signature/Cargo.toml index 0b1427dd5..b88f034c9 100644 --- a/signature/Cargo.toml +++ b/signature/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "signature" description = "Traits for cryptographic signature algorithms (e.g. ECDSA, Ed25519)" -version = "2.1.0" +version = "2.2.0-pre" authors = ["RustCrypto Developers"] license = "Apache-2.0 OR MIT" documentation = "https://docs.rs/signature" @@ -10,7 +10,7 @@ readme = "README.md" keywords = ["crypto", "ecdsa", "ed25519", "signature", "signing"] categories = ["cryptography", "no-std"] edition = "2021" -rust-version = "1.56" +rust-version = "1.60" [dependencies] derive = { package = "signature_derive", version = "2", optional = true, path = "derive" } @@ -23,12 +23,8 @@ sha2 = { version = "0.10", default-features = false } [features] alloc = [] -std = ["alloc"] +std = ["alloc", "rand_core?/std"] [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] - -# TODO(tarcieri): remove when these crates are added to toplevel `members` -[workspace] -members = [".", "async"] diff --git a/signature/README.md b/signature/README.md index 6f205d603..5e1100301 100644 --- a/signature/README.md +++ b/signature/README.md @@ -17,7 +17,7 @@ the [RustCrypto] organization, as well as [`ed25519-dalek`]. ## Minimum Supported Rust Version -Rust **1.56** or higher. +Rust **1.60** or higher. Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. @@ -56,7 +56,7 @@ dual licensed as above, without any additional terms or conditions. [build-image]: https://github.com/RustCrypto/traits/actions/workflows/signature.yml/badge.svg [build-link]: https://github.com/RustCrypto/traits/actions/workflows/signature.yml [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.56+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.60+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260048-signatures diff --git a/signature/async/Cargo.toml b/signature/async/Cargo.toml index 2fa5df953..260e540b1 100644 --- a/signature/async/Cargo.toml +++ b/signature/async/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "async-signature" description = "Traits for cryptographic signature algorithms (e.g. ECDSA, Ed25519)" -version = "0.3.0" +version = "0.4.0-pre" authors = ["RustCrypto Developers"] license = "Apache-2.0 OR MIT" documentation = "https://docs.rs/async-signature" @@ -10,11 +10,11 @@ readme = "README.md" keywords = ["crypto", "ecdsa", "ed25519", "signature", "signing"] categories = ["cryptography", "no-std"] edition = "2021" -rust-version = "1.56" +rust-version = "1.60" [dependencies] async-trait = "0.1.9" -signature = { version = "2.0, <2.2", path = ".." } +signature = { version = "=2.2.0-pre", path = ".." } [features] digest = ["signature/digest"] diff --git a/signature/async/README.md b/signature/async/README.md index 135e6241a..55b6e64c1 100644 --- a/signature/async/README.md +++ b/signature/async/README.md @@ -9,7 +9,7 @@ ## Minimum Supported Rust Version -Rust **1.56** or higher. +Rust **1.60** or higher. Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. @@ -36,7 +36,7 @@ dual licensed as above, without any additional terms or conditions. [docs-image]: https://docs.rs/async-signature/badge.svg [docs-link]: https://docs.rs/async-signature/ [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.56+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.60+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260048-signatures [build-image]: https://github.com/RustCrypto/traits/workflows/async-signature/badge.svg?branch=master&event=push diff --git a/signature/src/error.rs b/signature/src/error.rs index 1bfaf33bf..6518f17b8 100644 --- a/signature/src/error.rs +++ b/signature/src/error.rs @@ -93,6 +93,19 @@ impl From> for Error { } } +#[cfg(feature = "rand_core")] +impl From for Error { + #[cfg(not(feature = "std"))] + fn from(_source: rand_core::Error) -> Error { + Error::new() + } + + #[cfg(feature = "std")] + fn from(source: rand_core::Error) -> Error { + Error::from_source(source) + } +} + #[cfg(feature = "std")] impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {