<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.14"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>Crypto++: poly1305.h File Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">Crypto++  <span id="projectnumber">7.0</span> </div> <div id="projectbrief">Free C++ class library of cryptographic schemes</div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.14 --> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(function() { initMenu('',false,false,'search.php','Search'); }); /* @license-end */</script> <div id="main-nav"></div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#nested-classes">Classes</a> </div> <div class="headertitle"> <div class="title">poly1305.h File Reference</div> </div> </div><!--header--> <div class="contents"> <p>Classes for <a class="el" href="class_poly1305.html" title="Poly1305 message authentication code. ">Poly1305</a> message authentication code. <a href="#details">More...</a></p> <p><a href="poly1305_8h_source.html">Go to the source code of this file.</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a> Classes</h2></td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="class_poly1305___base.html">Poly1305_Base< T ></a></td></tr> <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight"><a class="el" href="class_poly1305.html" title="Poly1305 message authentication code. ">Poly1305</a> message authentication code base class. <a href="class_poly1305___base.html#details">More...</a><br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class  </td><td class="memItemRight" valign="bottom"><a class="el" href="class_poly1305.html">Poly1305< T ></a></td></tr> <tr class="memdesc:"><td class="mdescLeft"> </td><td class="mdescRight"><a class="el" href="class_poly1305.html" title="Poly1305 message authentication code. ">Poly1305</a> message authentication code. <a href="class_poly1305.html#details">More...</a><br /></td></tr> <tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>Classes for <a class="el" href="class_poly1305.html" title="Poly1305 message authentication code. ">Poly1305</a> message authentication code. </p> <p>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 <a class="el" href="class_a_e_s.html" title="AES block cipher (Rijndael) ">AES</a> key, a 16-byte additional key, and a 16-byte nonce.</p> <p>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 <a class="el" href="class_poly1305.html" title="Poly1305 message authentication code. ">Poly1305</a> object with a key and nonce each time its needed. </p><pre> <a class="el" href="class_sec_byte_block.html" title="SecBlock<byte> typedef. ">SecByteBlock</a> key(32), nonce(16); prng.GenerateBlock(key, key.size()); prng.GenerateBlock(nonce, nonce.size());</pre><pre> Poly1305<AES> poly1305(key, key.size(), nonce, nonce.size()); poly1305.Update(...); poly1305.Final(...);</pre><p>Second, you can create a <a class="el" href="class_poly1305.html" title="Poly1305 message authentication code. ">Poly1305</a> object, reuse the key, and set a fresh nonce for each message. The second and subsequent nonces can be generated directly using a <a class="el" href="class_random_number_generator.html" title="Interface for random number generators. ">RandomNumberGenerator()</a> derived class; or it can be generated using GetNextIV(). </p><pre> <a class="el" href="class_sec_byte_block.html" title="SecBlock<byte> typedef. ">SecByteBlock</a> key(32), nonce(16); prng.GenerateBlock(key, key.size()); prng.GenerateBlock(nonce, nonce.size());</pre><pre> // First message Poly1305<AES> poly1305(key, key.size()); poly1305.Resynchronize(nonce); poly1305.Update(...); poly1305.Final(...);</pre><pre> // Second message poly1305.GetNextIV(prng, nonce); poly1305.Resynchronize(nonce); poly1305.Update(...); poly1305.Final(...); ...</pre> <dl class="section see"><dt>See also</dt><dd>Daniel J. Bernstein <a href="http://cr.yp.to/mac/poly1305-20050329.pdf">The Poly1305-AES Message-Authentication Code (20050329)</a> and Andy Polyakov <a href="http://www.openssl.org/blog/blog/2016/02/15/poly1305-revised/">Poly1305 Revised</a> </dd></dl> <dl class="section since"><dt>Since</dt><dd>Crypto++ 6.0 </dd></dl> <p class="definition">Definition in file <a class="el" href="poly1305_8h_source.html">poly1305.h</a>.</p> </div></div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Sun Sep 16 2018 07:58:11 for Crypto++ by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.14 </small></address> </body> </html>