[][src]Crate poly1305

The Poly1305 universal hash function and message authentication code.

About

Poly1305 is a universal hash function suitable for use as a one-time authenticator and, when combined with a cipher, a message authentication code (MAC).

It takes a 32-byte one-time key and a message and produces a 16-byte tag, which can be used to authenticate the message.

Poly1305 is primarily notable for its use in the ChaCha20Poly1305 and XSalsa20Poly1305 authenticated encryption algorithms.

Minimum Supported Rust Version

Rust 1.41 or higher.

Minimum supported Rust version may be changed in the future, but such changes will be accompanied with a minor version bump.

Performance Notes

For maximum performance on x86/x86_64 CPUs, we recommend enabling the AVX2 backend using the following RUSTFLAGS:

  • x86(-64) CPU: target-cpu=haswell or newer
  • AVX2: target-feature=+avx2

Example:

$ RUSTFLAGS="-Ctarget-cpu=haswell -Ctarget-feature=+avx2" cargo bench

Security Notes

This crate has received one security audit by NCC Group, with no significant findings. We would like to thank MobileCoin for funding the audit.

NOTE: the audit predates the AVX2 backend, which has not yet been audited.

All implementations contained in the crate are designed to execute in constant time, either by relying on hardware intrinsics (e.g. AVX2 on x86/x86_64), or using a portable implementation which is only constant time on processors which implement constant-time multiplication.

It is not suitable for use on processors with a variable-time multiplication operation (e.g. short circuit on multiply-by-zero / multiply-by-one, such as certain 32-bit PowerPC CPUs and some non-ARM microcontrollers).

Re-exports

pub use universal_hash;

Structs

Poly1305

The Poly1305 universal hash function.

Constants

BLOCK_SIZE

Size of the blocks Poly1305 acts upon

KEY_SIZE

Size of a Poly1305 key

Type Definitions

Block

Poly1305 blocks (16-bytes)

Key

Poly1305 keys (32-bytes)

Tag

Poly1305 tags (16-bytes)