diff --git a/Cargo.lock b/Cargo.lock index 02b7e7c..41cbb66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,7 +29,7 @@ dependencies = [ [[package]] name = "ghash" -version = "0.4.4" +version = "0.5.0" dependencies = [ "hex-literal", "opaque-debug", @@ -57,7 +57,7 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "poly1305" -version = "0.7.2" +version = "0.8.0" dependencies = [ "cpufeatures", "hex-literal", @@ -68,12 +68,11 @@ dependencies = [ [[package]] name = "polyval" -version = "0.5.3" +version = "0.6.0" dependencies = [ "cfg-if", "cpufeatures", "hex-literal", - "opaque-debug", "universal-hash", "zeroize", ] @@ -111,3 +110,8 @@ name = "zeroize" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c88870063c39ee00ec285a2f8d6a966e5b6fb2becc4e8dac77ed0d370ed6006" + +[[patch.unused]] +name = "universal-hash" +version = "0.5.0" +source = "git+https://github.com/RustCrypto/traits?branch=uhf/v0.5#5ab0d10f40e89c93592ffb3c5e628d0cad176ce3" diff --git a/Cargo.toml b/Cargo.toml index 3464997..e4b9800 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,3 +5,9 @@ members = [ "polyval" ] resolver = "2" + +[profile.dev] +opt-level = 2 + +[patch.crates-io] +universal-hash = { git = "https://github.com/RustCrypto/traits", branch = "uhf/v0.5" } diff --git a/README.md b/README.md index 567a1c1..2648558 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,26 @@ -# RustCrypto: Universal Hash Functions ![Rust Version][rustc-image] [![dependency status][deps-image]][deps-link] +# RustCrypto: Universal Hash Functions -Collection of [Universal Hash Functions][1] written in pure Rust. +[![Project Chat][chat-image]][chat-link] +[![dependency status][deps-image]][deps-link] +![Apache2/MIT licensed][license-image] -## Crates +Collection of [Universal Hash Functions][1] (UHF) written in pure Rust. -| Name | Crates.io | Documentation | Build Status | -|--------------|-----------|---------------|--------------| -| [`ghash`] | [![crates.io](https://img.shields.io/crates/v/ghash.svg)](https://crates.io/crates/ghash) | [![Documentation](https://docs.rs/ghash/badge.svg)](https://docs.rs/ghash) | ![build](https://github.com/RustCrypto/universal-hashes/workflows/ghash/badge.svg?branch=master&event=push) | -| [`poly1305`] | [![crates.io](https://img.shields.io/crates/v/poly1305.svg)](https://crates.io/crates/poly1305) | [![Documentation](https://docs.rs/poly1305/badge.svg)](https://docs.rs/poly1305) | ![build](https://github.com/RustCrypto/universal-hashes/workflows/poly1305/badge.svg?branch=master&event=push) | -| [`polyval`] | [![crates.io](https://img.shields.io/crates/v/polyval.svg)](https://crates.io/crates/polyval) | [![Documentation](https://docs.rs/polyval/badge.svg)](https://docs.rs/polyval) | ![build](https://github.com/RustCrypto/universal-hashes/workflows/polyval/badge.svg?branch=master&event=push) | +## Crates -### Minimum Supported Rust Version +| Algorithm | Crate | Crates.io | Documentation | MSRV | +|------------|--------------|:---------:|:-------------:|:----:| +| [GHASH] | [`ghash`] | [![crates.io](https://img.shields.io/crates/v/ghash.svg)](https://crates.io/crates/ghash) | [![Documentation](https://docs.rs/ghash/badge.svg)](https://docs.rs/ghash) | ![MSRV 1.56][msrv-1.56] | +| [Poly1305] | [`poly1305`] | [![crates.io](https://img.shields.io/crates/v/poly1305.svg)](https://crates.io/crates/poly1305) | [![Documentation](https://docs.rs/poly1305/badge.svg)](https://docs.rs/poly1305) | ![MSRV 1.56][msrv-1.56] | +| [POLYVAL] | [`polyval`] | [![crates.io](https://img.shields.io/crates/v/polyval.svg)](https://crates.io/crates/polyval) | [![Documentation](https://docs.rs/polyval/badge.svg)](https://docs.rs/polyval) | ![MSRV 1.56][msrv-1.56] | -All crates in this repository support **Rust 1.56** or higher. +### Minimum Supported Rust Version (MSRV) Policy -In the future, we reserve the right to change the Minimum Supported Rust -Version, but it will be done with the minor version bump. +MSRV bumps are considered breaking changes and will be performed only with minor version bump. ## Usage -Crates functionality is expressed in terms of traits defined in the [`universal-hash`][2] -crate. +Crates functionality is expressed in terms of traits defined in the [`universal-hash`] crate. ## License @@ -33,23 +33,30 @@ at your option. ### Contribution -Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in the work by you, as defined in the Apache-2.0 license, shall be -dual licensed as above, without any additional terms or conditions. +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. [//]: # (badges) -[rustc-image]: https://img.shields.io/badge/rustc-1.56+-blue.svg +[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg +[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260051-universal-hashes +[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg [deps-image]: https://deps.rs/repo/github/RustCrypto/universal-hashes/status.svg [deps-link]: https://deps.rs/repo/github/RustCrypto/universal-hashes +[msrv-1.56]: https://img.shields.io/badge/rustc-1.56+-blue.svg [//]: # (crates) -[`ghash`]: https://github.com/RustCrypto/universal-hashes/tree/master/ghash -[`poly1305`]: https://github.com/RustCrypto/universal-hashes/tree/master/poly1305 -[`polyval`]: https://github.com/RustCrypto/universal-hashes/tree/master/polyval +[`ghash`]: ./ghash +[`poly1305`]: ./poly1305 +[`polyval`]: ./polyval [//]: # (footnotes) [1]: https://en.wikipedia.org/wiki/Universal_hashing -[2]: https://docs.rs/universal-hash +[`universal-hash`]: https://docs.rs/universal-hash + +[//]: # (algorithms) + +[GHASH]: https://en.wikipedia.org/wiki/Galois/Counter_Mode#Mathematical_basis +[Poly1305]: https://en.wikipedia.org/wiki/Poly1305 +[POLYVAL]: https://datatracker.ietf.org/doc/html/rfc8452#section-3 diff --git a/ghash/Cargo.toml b/ghash/Cargo.toml index 2e1b7be..3d163c7 100644 --- a/ghash/Cargo.toml +++ b/ghash/Cargo.toml @@ -1,23 +1,23 @@ [package] name = "ghash" -version = "0.4.4" # Also update html_root_url in lib.rs when bumping this -authors = ["RustCrypto Developers"] -license = "Apache-2.0 OR MIT" +version = "0.5.0" # Also update html_root_url in lib.rs when bumping this description = """ Universal hash over GF(2^128) useful for constructing a Message Authentication Code (MAC), as in the AES-GCM authenticated encryption cipher. """ +authors = ["RustCrypto Developers"] +license = "Apache-2.0 OR MIT" +edition = "2021" +rust-version = "1.56" +readme = "README.md" documentation = "https://docs.rs/ghash" repository = "https://github.com/RustCrypto/universal-hashes" -readme = "README.md" keywords = ["aes-gcm", "crypto", "universal-hashing"] categories = ["cryptography", "no-std"] -rust-version = "1.56" -edition = "2021" [dependencies] opaque-debug = "0.3" -polyval = { version = "0.5.1", path = "../polyval" } +polyval = { version = "0.6.0", path = "../polyval" } # optional dependencies zeroize = { version = "1", optional = true, default-features = false } diff --git a/ghash/README.md b/ghash/README.md index 05c96a8..1dea5e8 100644 --- a/ghash/README.md +++ b/ghash/README.md @@ -4,6 +4,7 @@ [![Docs][docs-image]][docs-link] ![Apache2/MIT licensed][license-image] ![Rust Version][rustc-image] +[![Project Chat][chat-image]][chat-link] [![Build Status][build-image]][build-link] [GHASH][1] is a [universal hash function][2] which operates over GF(2^128) and @@ -50,6 +51,8 @@ dual licensed as above, without any additional terms or conditions. [docs-link]: https://docs.rs/ghash/ [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 +[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg +[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260051-universal-hashes [build-image]: https://github.com/RustCrypto/universal-hashes/workflows/ghash/badge.svg?branch=master&event=push [build-link]: https://github.com/RustCrypto/universal-hashes/actions?query=workflow%3Aghash diff --git a/ghash/src/lib.rs b/ghash/src/lib.rs index 2c8fba2..cd31cf9 100644 --- a/ghash/src/lib.rs +++ b/ghash/src/lib.rs @@ -26,7 +26,7 @@ #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", - html_root_url = "https://docs.rs/ghash/0.4.3" + html_root_url = "https://docs.rs/ghash/0.5.0" )] #![warn(missing_docs, rust_2018_idioms)] diff --git a/poly1305/Cargo.toml b/poly1305/Cargo.toml index 3b5d634..dc01602 100644 --- a/poly1305/Cargo.toml +++ b/poly1305/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "poly1305" -version = "0.7.2" # Also update html_root_url in lib.rs when bumping this +version = "0.8.0" # Also update html_root_url in lib.rs when bumping this +description = "The Poly1305 universal hash function and message authentication code" authors = ["RustCrypto Developers"] license = "Apache-2.0 OR MIT" -description = "The Poly1305 universal hash function and message authentication code" +edition = "2021" +rust-version = "1.56" +readme = "README.md" documentation = "https://docs.rs/poly1305" repository = "https://github.com/RustCrypto/universal-hashes" keywords = ["crypto", "chacha20", "mac", "salsa20", "universal-hashing"] categories = ["cryptography", "no-std"] -readme = "README.md" -rust-version = "1.56" -edition = "2021" [dependencies] opaque-debug = "0.3" diff --git a/poly1305/README.md b/poly1305/README.md index 20d6e98..68eb174 100644 --- a/poly1305/README.md +++ b/poly1305/README.md @@ -4,6 +4,7 @@ [![Docs][docs-image]][docs-link] ![Apache2/MIT licensed][license-image] ![Rust Version][rustc-image] +[![Project Chat][chat-image]][chat-link] [![Build Status][build-image]][build-link] [Poly1305][1] is a [universal hash function][2] which, when combined with a cipher, @@ -54,6 +55,8 @@ dual licensed as above, without any additional terms or conditions. [docs-link]: https://docs.rs/poly1305/ [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 +[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg +[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260051-universal-hashes [build-image]: https://github.com/RustCrypto/universal-hashes/workflows/poly1305/badge.svg?branch=master&event=push [build-link]: https://github.com/RustCrypto/universal-hashes/actions?query=workflow%3Apoly1305 diff --git a/poly1305/src/lib.rs b/poly1305/src/lib.rs index 8c9940b..faa1a90 100644 --- a/poly1305/src/lib.rs +++ b/poly1305/src/lib.rs @@ -45,7 +45,7 @@ #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", - html_root_url = "https://docs.rs/poly1305/0.7.1" + html_root_url = "https://docs.rs/poly1305/0.8.0" )] #![warn(missing_docs, rust_2018_idioms)] diff --git a/polyval/Cargo.toml b/polyval/Cargo.toml index 3f311f6..ed5c895 100644 --- a/polyval/Cargo.toml +++ b/polyval/Cargo.toml @@ -1,23 +1,22 @@ [package] name = "polyval" -version = "0.5.3" # Also update html_root_url in lib.rs when bumping this -authors = ["RustCrypto Developers"] -license = "Apache-2.0 OR MIT" +version = "0.6.0" # Also update html_root_url in lib.rs when bumping this description = """ POLYVAL is a GHASH-like universal hash over GF(2^128) useful for constructing a Message Authentication Code (MAC) """ +authors = ["RustCrypto Developers"] +license = "Apache-2.0 OR MIT" +edition = "2021" +rust-version = "1.56" +readme = "README.md" documentation = "https://docs.rs/polyval" repository = "https://github.com/RustCrypto/universal-hashes" -readme = "README.md" keywords = ["aes-gcm", "aes-gcm-siv", "crypto", "ghash", "universal-hashing"] categories = ["cryptography", "no-std"] -rust-version = "1.56" -edition = "2021" [dependencies] cfg-if = "1" -opaque-debug = "0.3" universal-hash = { version = "0.4", default-features = false } zeroize = { version = "1", optional = true, default-features = false } diff --git a/polyval/README.md b/polyval/README.md index 1a9b6e4..ce3ff04 100644 --- a/polyval/README.md +++ b/polyval/README.md @@ -4,6 +4,7 @@ [![Docs][docs-image]][docs-link] ![Apache2/MIT licensed][license-image] ![Rust Version][rustc-image] +[![Project Chat][chat-image]][chat-link] [![Build Status][build-image]][build-link] [POLYVAL][1] ([RFC 8452][2]) is a [universal hash function][3] which operates @@ -53,6 +54,8 @@ dual licensed as above, without any additional terms or conditions. [docs-link]: https://docs.rs/polyval/ [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 +[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg +[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260051-universal-hashes [build-image]: https://github.com/RustCrypto/universal-hashes/workflows/polyval/badge.svg?branch=master&event=push [build-link]: https://github.com/RustCrypto/universal-hashes/actions?query=workflow%3Apolyval diff --git a/polyval/src/lib.rs b/polyval/src/lib.rs index f92c2ae..ba23ff8 100644 --- a/polyval/src/lib.rs +++ b/polyval/src/lib.rs @@ -82,17 +82,23 @@ #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", - html_root_url = "https://docs.rs/polyval/0.5.3" + html_root_url = "https://docs.rs/polyval/0.6.0" )] #![warn(missing_docs, rust_2018_idioms)] +use core::fmt; + mod backend; mod mulx; pub use crate::{backend::Polyval, mulx::mulx}; pub use universal_hash; -opaque_debug::implement!(Polyval); +impl fmt::Debug for Polyval { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("Polyval { ... }") + } +} /// Size of a POLYVAL block in bytes pub const BLOCK_SIZE: usize = 16; @@ -105,6 +111,3 @@ pub type Key = universal_hash::Key; /// POLYVAL blocks (16-bytes) pub type Block = universal_hash::Block; - -/// POLYVAL tags (16-bytes) -pub type Tag = universal_hash::Output; diff --git a/polyval/src/mulx.rs b/polyval/src/mulx.rs index 2abd868..6defbdc 100644 --- a/polyval/src/mulx.rs +++ b/polyval/src/mulx.rs @@ -8,6 +8,7 @@ use crate::Block; /// This is useful for implementing GHASH in terms of POLYVAL. /// /// [1]: https://tools.ietf.org/html/rfc8452#appendix-A +#[inline(always)] pub fn mulx(block: &Block) -> Block { let mut v = u128::from_le_bytes((*block).into()); let v_hi = v >> 127;