Poly1305-AES using GMP and OpenSSL D. J. Bernstein
Authenticators and signatures
A state-of-the-art message-authentication code

Poly1305-AES using GMP and OpenSSL

poly1305aes_test is an implementation of Poly1305-AES that uses GMP for integer arithmetic and OpenSSL for AES. I recommend against using poly1305aes_test for anything other than tests; my main reason for publishing it is to help communicate the definition of Poly1305-AES.

Requirements: poly1305aes_test must be compiled with -lcrypto -lgmp. The system must have GMP 3 or later (for the mpz_tdiv_q_ui return value). The system must also have OpenSSL 0.9.7 or later (for AES_encrypt).

Here are the poly1305aes_test files:

Here are various tests:

The most obvious difference between poly1305aes_test and a serious Poly1305-AES implementation such as poly1305aes_sparc is that a serious implementation is much faster. poly1305aes_test_verify takes about 140000 UltraSPARC-III cycles (or 150000 Pentium-M cycles) for a 1024-byte message, for example, and 14000 UltraSPARC-III cycles (or 11000 Pentium-M cycles) for a 16-byte message; poly1305aes_sparc_verify takes only about 5600 UltraSPARC-III cycles for a 1024-byte message and only about 850 UltraSPARC-III cycles for a 16-byte message.

A less obvious difference between poly1305aes_test and a serious Poly1305-AES implementation is that, inside poly1305aes_test, GMP allocates memory and will kill the program if it fails. It's hard to use GMP safely in a typical server that needs to keep running. The only memory allocated by a serious implementation is a small, constant, easily pre-provisioned amount of stack space.