Skip to content
Closed
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
12 changes: 8 additions & 4 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
51 changes: 29 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
14 changes: 7 additions & 7 deletions ghash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
3 changes: 3 additions & 0 deletions ghash/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion ghash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand Down
10 changes: 5 additions & 5 deletions poly1305/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 3 additions & 0 deletions poly1305/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion poly1305/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand Down
13 changes: 6 additions & 7 deletions polyval/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }

Expand Down
3 changes: 3 additions & 0 deletions polyval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
13 changes: 8 additions & 5 deletions polyval/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -105,6 +111,3 @@ pub type Key = universal_hash::Key<Polyval>;

/// POLYVAL blocks (16-bytes)
pub type Block = universal_hash::Block<Polyval>;

/// POLYVAL tags (16-bytes)
pub type Tag = universal_hash::Output<Polyval>;
1 change: 1 addition & 0 deletions polyval/src/mulx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down