Message authentication codes

Poly1305

Bernstein's fast one-time authenticator, paired with ChaCha20 in RFC 8439

standard Safe API

About Poly1305

Poly1305 is a message authentication code. It uses a 32-byte (256-bit) key and a 16-byte (128-bit) authentication tag. Its registry entry cites RFC 8439. NextSSL lists it in the standard tier and exposes it through the safe API.

Overview

Poly1305 is a one-time message authentication code designed by Daniel J. Bernstein. Combined with ChaCha20 in the ChaCha20-Poly1305 AEAD, it is one of the two dominant authenticated-encryption constructions on the internet alongside AES-GCM.

Poly1305 evaluates a polynomial over the prime field modulo 2^130 − 5. The message is split into 16-byte chunks, each extended with a 1 bit, and the polynomial with these chunks as coefficients is evaluated at a secret point r, with certain bits of r clamped to zero for efficient implementation. A second secret s is added to the result modulo 2^128 to produce a 16-byte tag.

The pair (r, s) must be used for only one message. In ChaCha20-Poly1305 a fresh key pair is derived for each message from the first ChaCha20 keystream block. Poly1305 was originally published in 2005 with AES generating s; RFC 8439 standardises it with ChaCha20. It is constant-time when implemented carefully.

History

2005–2018
  1. Poly1305-AES published by Daniel J. Bernstein

  2. ChaCha20-Poly1305 specified in RFC 7539

  3. Updated in RFC 8439

Security notes

Poly1305 is secure only if each key is used once. Reusing a key for two messages allows forgeries. Within AEAD constructions with unique nonces this holds automatically.

Typical uses

ChaCha20-Poly1305 AEAD in TLS 1.3, SSH, WireGuardNaCl/libsodium secretbox (XSalsa20-Poly1305)Fast software authentication without AES hardware

Sizes

FieldBytesMeaning
key32Secret key
tag16Authentication tag

Use it

from nextssl_demo import NextSSL

ns = NextSSL()              # safe API: safe and standard tiers
key = ns.random(32)
tag = ns.call("mac", "poly1305", None, key, b"message", 0)[0]
ok  = ns.check("mac_verify", "poly1305", None, key, b"message", tag)

Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.

Frequently asked questions

What is Poly1305?

Poly1305 is a MAC in the Poly1305 family. Poly1305 is a one-time message authentication code designed by Daniel J. Bernstein.

What are the Poly1305 sizes?

In NextSSL, Poly1305 uses: key 32 bytes, tag 16 bytes.

Who designed Poly1305 and when?

Poly1305 belongs to the Poly1305 family, first published in 2005 by Daniel J. Bernstein. Its origin: RFC 8439.

Which standards define Poly1305?

Poly1305 is referenced by RFC 8439.

Is Poly1305 safe to use?

Poly1305 is in the standard tier. Standardised and sound. Reachable from the safe API. It can be called from the safe API.