Fabcoin Core  0.16.2
P2P Digital Currency
Classes
poly1305.h File Reference

Classes for Poly1305 message authentication code. More...

#include "cryptlib.h"
#include "seckey.h"
#include "secblock.h"
#include "argnames.h"
#include "algparam.h"
Include dependency graph for poly1305.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Poly1305_Base< T >
 Poly1305 message authentication code base class. More...
 
class  Poly1305< T >
 Poly1305 message authentication code. More...
 

Detailed Description

Classes for Poly1305 message authentication code.

Poly1305-AES is a state-of-the-art message-authentication code suitable for a wide variety of applications. Poly1305-AES computes a 16-byte authenticator of a variable-length message, using a 16-byte AES key, a 16-byte additional key, and a 16-byte nonce.

Each message must use a unique security context, which means either the key or nonce must be changed after each message. It can be accomplished in one of two ways. First, you can create a new Poly1305 object with a key and nonce each time its needed.

  SecByteBlock key(32), nonce(16);
  prng.GenerateBlock(key, key.size());
  prng.GenerateBlock(nonce, nonce.size());
  Poly1305<AES> poly1305(key, key.size(), nonce, nonce.size());
  poly1305.Update(...);
  poly1305.Final(...);

Second, you can create a Poly1305 object, reuse the key, and set a fresh nonce for each message. The second and subsequent nonces can be generated directly using a RandomNumberGenerator() derived class; or it can be generated using GetNextIV().

  SecByteBlock key(32), nonce(16);
  prng.GenerateBlock(key, key.size());
  prng.GenerateBlock(nonce, nonce.size());
  // First message
  Poly1305<AES> poly1305(key, key.size());
  poly1305.Resynchronize(nonce);
  poly1305.Update(...);
  poly1305.Final(...);
  // Second message
  poly1305.GetNextIV(prng, nonce);
  poly1305.Resynchronize(nonce);
  poly1305.Update(...);
  poly1305.Final(...);
  ...
See also
Daniel J. Bernstein The Poly1305-AES Message-Authentication Code (20050329) and Andy Polyakov Poly1305 Revised
Since
Crypto++ 5.7

Definition in file poly1305.h.