1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00
arduinolibs/classChaCha.html
Rhys Weatherley 6fadd58f39 Update docs
2018-04-27 12:01:49 +10:00

681 lines
38 KiB
HTML

<!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.6"/>
<title>Arduino Cryptography Library: ChaCha Class 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="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</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 style="padding-left: 0.5em;">
<div id="projectname">Arduino Cryptography Library
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class&#160;List</span></a></li>
<li><a href="classes.html"><span>Class&#160;Index</span></a></li>
<li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class&#160;Members</span></a></li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Pages</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="#friends">Friends</a> &#124;
<a href="classChaCha-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">ChaCha Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<p><a class="el" href="classChaCha.html" title="ChaCha stream cipher. ">ChaCha</a> stream cipher.
<a href="classChaCha.html#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="ChaCha_8h_source.html">ChaCha.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for ChaCha:</div>
<div class="dyncontent">
<div class="center">
<img src="classChaCha.png" usemap="#ChaCha_map" alt=""/>
<map id="ChaCha_map" name="ChaCha_map">
<area href="classCipher.html" title="Abstract base class for stream ciphers. " alt="Cipher" shape="rect" coords="0,0,58,24"/>
</map>
</div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a5831811b705d3c80e97f0242597f0c7e"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#a5831811b705d3c80e97f0242597f0c7e">ChaCha</a> (uint8_t <a class="el" href="classChaCha.html#a0a73d3623da377bc593876156768dd72">numRounds</a>=20)</td></tr>
<tr class="memdesc:a5831811b705d3c80e97f0242597f0c7e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a new <a class="el" href="classChaCha.html" title="ChaCha stream cipher. ">ChaCha</a> stream cipher. <a href="#a5831811b705d3c80e97f0242597f0c7e">More...</a><br/></td></tr>
<tr class="separator:a5831811b705d3c80e97f0242597f0c7e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af286083291fab2bd36dc7ad1f54d5cd7"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#af286083291fab2bd36dc7ad1f54d5cd7">keySize</a> () const </td></tr>
<tr class="memdesc:af286083291fab2bd36dc7ad1f54d5cd7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default size of the key for this cipher, in bytes. <a href="#af286083291fab2bd36dc7ad1f54d5cd7">More...</a><br/></td></tr>
<tr class="separator:af286083291fab2bd36dc7ad1f54d5cd7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afaa3df343a7d07976bd7e03a0c1bf43c"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#afaa3df343a7d07976bd7e03a0c1bf43c">ivSize</a> () const </td></tr>
<tr class="memdesc:afaa3df343a7d07976bd7e03a0c1bf43c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Size of the initialization vector for this cipher, in bytes. <a href="#afaa3df343a7d07976bd7e03a0c1bf43c">More...</a><br/></td></tr>
<tr class="separator:afaa3df343a7d07976bd7e03a0c1bf43c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0a73d3623da377bc593876156768dd72"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#a0a73d3623da377bc593876156768dd72">numRounds</a> () const </td></tr>
<tr class="memdesc:a0a73d3623da377bc593876156768dd72"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the number of encryption rounds; usually 8, 12, or 20. <a href="#a0a73d3623da377bc593876156768dd72">More...</a><br/></td></tr>
<tr class="separator:a0a73d3623da377bc593876156768dd72"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1a0911e0be8f4590d7fb76884d98c541"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#a1a0911e0be8f4590d7fb76884d98c541">setNumRounds</a> (uint8_t <a class="el" href="classChaCha.html#a0a73d3623da377bc593876156768dd72">numRounds</a>)</td></tr>
<tr class="memdesc:a1a0911e0be8f4590d7fb76884d98c541"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the number of encryption rounds. <a href="#a1a0911e0be8f4590d7fb76884d98c541">More...</a><br/></td></tr>
<tr class="separator:a1a0911e0be8f4590d7fb76884d98c541"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6b2bdffbd3705e388bb458edb2f40c90"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#a6b2bdffbd3705e388bb458edb2f40c90">setKey</a> (const uint8_t *key, size_t len)</td></tr>
<tr class="memdesc:a6b2bdffbd3705e388bb458edb2f40c90"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the key to use for future encryption and decryption operations. <a href="#a6b2bdffbd3705e388bb458edb2f40c90">More...</a><br/></td></tr>
<tr class="separator:a6b2bdffbd3705e388bb458edb2f40c90"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a734f3246b1e6810c63637b8cda26b259"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#a734f3246b1e6810c63637b8cda26b259">setIV</a> (const uint8_t *iv, size_t len)</td></tr>
<tr class="memdesc:a734f3246b1e6810c63637b8cda26b259"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the initialization vector to use for future encryption and decryption operations. <a href="#a734f3246b1e6810c63637b8cda26b259">More...</a><br/></td></tr>
<tr class="separator:a734f3246b1e6810c63637b8cda26b259"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acab9109b7189ea88d9e5417a3a209eac"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#acab9109b7189ea88d9e5417a3a209eac">setCounter</a> (const uint8_t *counter, size_t len)</td></tr>
<tr class="memdesc:acab9109b7189ea88d9e5417a3a209eac"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the starting counter for encryption. <a href="#acab9109b7189ea88d9e5417a3a209eac">More...</a><br/></td></tr>
<tr class="separator:acab9109b7189ea88d9e5417a3a209eac"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acd4fff140b8871c233d9a31abf753ed8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#acd4fff140b8871c233d9a31abf753ed8">encrypt</a> (uint8_t *output, const uint8_t *input, size_t len)</td></tr>
<tr class="memdesc:acd4fff140b8871c233d9a31abf753ed8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Encrypts an input buffer and writes the ciphertext to an output buffer. <a href="#acd4fff140b8871c233d9a31abf753ed8">More...</a><br/></td></tr>
<tr class="separator:acd4fff140b8871c233d9a31abf753ed8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1f54b2b51b59428010f81a6c4dc4e42c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#a1f54b2b51b59428010f81a6c4dc4e42c">decrypt</a> (uint8_t *output, const uint8_t *input, size_t len)</td></tr>
<tr class="memdesc:a1f54b2b51b59428010f81a6c4dc4e42c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Decrypts an input buffer and writes the plaintext to an output buffer. <a href="#a1f54b2b51b59428010f81a6c4dc4e42c">More...</a><br/></td></tr>
<tr class="separator:a1f54b2b51b59428010f81a6c4dc4e42c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af533905f679066c41f4d6cd76bddb4cb"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#af533905f679066c41f4d6cd76bddb4cb">clear</a> ()</td></tr>
<tr class="memdesc:af533905f679066c41f4d6cd76bddb4cb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clears all security-sensitive state from this cipher. <a href="#af533905f679066c41f4d6cd76bddb4cb">More...</a><br/></td></tr>
<tr class="separator:af533905f679066c41f4d6cd76bddb4cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classCipher"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classCipher')"><img src="closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="classCipher.html">Cipher</a></td></tr>
<tr class="memitem:a6a61077eca3ccd5900f92ceac58fb09c inherit pub_methods_classCipher"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6a61077eca3ccd5900f92ceac58fb09c"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCipher.html#a6a61077eca3ccd5900f92ceac58fb09c">Cipher</a> ()</td></tr>
<tr class="memdesc:a6a61077eca3ccd5900f92ceac58fb09c inherit pub_methods_classCipher"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a new cipher object. <br/></td></tr>
<tr class="separator:a6a61077eca3ccd5900f92ceac58fb09c inherit pub_methods_classCipher"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a84bdea765f7e35aa5b5950dd2853a383 inherit pub_methods_classCipher"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCipher.html#a84bdea765f7e35aa5b5950dd2853a383">~Cipher</a> ()</td></tr>
<tr class="memdesc:a84bdea765f7e35aa5b5950dd2853a383 inherit pub_methods_classCipher"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroys this cipher object. <a href="#a84bdea765f7e35aa5b5950dd2853a383">More...</a><br/></td></tr>
<tr class="separator:a84bdea765f7e35aa5b5950dd2853a383 inherit pub_methods_classCipher"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:a41ac3262e52ff49dcd916d0b3b2e2038"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classChaCha.html#a41ac3262e52ff49dcd916d0b3b2e2038">hashCore</a> (uint32_t *output, const uint32_t *input, uint8_t rounds)</td></tr>
<tr class="memdesc:a41ac3262e52ff49dcd916d0b3b2e2038"><td class="mdescLeft">&#160;</td><td class="mdescRight">Executes the <a class="el" href="classChaCha.html" title="ChaCha stream cipher. ">ChaCha</a> hash core on an input memory block. <a href="#a41ac3262e52ff49dcd916d0b3b2e2038">More...</a><br/></td></tr>
<tr class="separator:a41ac3262e52ff49dcd916d0b3b2e2038"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="friends"></a>
Friends</h2></td></tr>
<tr class="memitem:a597954d014b0fcaa5d2a366a7411e523"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a597954d014b0fcaa5d2a366a7411e523"></a>
class&#160;</td><td class="memItemRight" valign="bottom"><b>ChaChaPoly</b></td></tr>
<tr class="separator:a597954d014b0fcaa5d2a366a7411e523"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p><a class="el" href="classChaCha.html" title="ChaCha stream cipher. ">ChaCha</a> stream cipher. </p>
<p><a class="el" href="classChaCha.html" title="ChaCha stream cipher. ">ChaCha</a> is a stream cipher that takes a key, an 8-byte nonce/IV, and a counter and hashes them to generate a keystream to XOR with the plaintext. Variations on the <a class="el" href="classChaCha.html" title="ChaCha stream cipher. ">ChaCha</a> cipher use 8, 12, or 20 rounds of hashing operations with either 128-bit or 256-bit keys.</p>
<p>Reference: <a href="http://cr.yp.to/chacha.html">http://cr.yp.to/chacha.html</a> </p>
<p>Definition at line <a class="el" href="ChaCha_8h_source.html#l00030">30</a> of file <a class="el" href="ChaCha_8h_source.html">ChaCha.h</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a5831811b705d3c80e97f0242597f0c7e"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">ChaCha::ChaCha </td>
<td>(</td>
<td class="paramtype">uint8_t&#160;</td>
<td class="paramname"><em>numRounds</em> = <code>20</code></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Constructs a new <a class="el" href="classChaCha.html" title="ChaCha stream cipher. ">ChaCha</a> stream cipher. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">numRounds</td><td>Number of encryption rounds to use; usually 8, 12, or 20. </td></tr>
</table>
</dd>
</dl>
<p>Definition at line <a class="el" href="ChaCha_8cpp_source.html#l00047">47</a> of file <a class="el" href="ChaCha_8cpp_source.html">ChaCha.cpp</a>.</p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="af533905f679066c41f4d6cd76bddb4cb"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void ChaCha::clear </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Clears all security-sensitive state from this cipher. </p>
<p>Security-sensitive information includes key schedules, initialization vectors, and any temporary state that is used by <a class="el" href="classChaCha.html#acd4fff140b8871c233d9a31abf753ed8" title="Encrypts an input buffer and writes the ciphertext to an output buffer. ">encrypt()</a> or <a class="el" href="classChaCha.html#a1f54b2b51b59428010f81a6c4dc4e42c" title="Decrypts an input buffer and writes the plaintext to an output buffer. ">decrypt()</a> which is stored in the cipher itself. </p>
<p>Implements <a class="el" href="classCipher.html#a4b7c3965646441a70d9ab934a7c92ab1">Cipher</a>.</p>
<p>Definition at line <a class="el" href="ChaCha_8cpp_source.html#l00218">218</a> of file <a class="el" href="ChaCha_8cpp_source.html">ChaCha.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="a1f54b2b51b59428010f81a6c4dc4e42c"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void ChaCha::decrypt </td>
<td>(</td>
<td class="paramtype">uint8_t *&#160;</td>
<td class="paramname"><em>output</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const uint8_t *&#160;</td>
<td class="paramname"><em>input</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>len</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Decrypts an input buffer and writes the plaintext to an output buffer. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">output</td><td>The output buffer to write to, which may be the same buffer as <em>input</em>. The <em>output</em> buffer must have at least as many bytes as the <em>input</em> buffer. </td></tr>
<tr><td class="paramname">input</td><td>The input buffer to read from. </td></tr>
<tr><td class="paramname">len</td><td>The number of bytes to decrypt.</td></tr>
</table>
</dd>
</dl>
<p>The <a class="el" href="classChaCha.html#a1f54b2b51b59428010f81a6c4dc4e42c" title="Decrypts an input buffer and writes the plaintext to an output buffer. ">decrypt()</a> function can be called multiple times with different regions of the ciphertext data.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classChaCha.html#acd4fff140b8871c233d9a31abf753ed8" title="Encrypts an input buffer and writes the ciphertext to an output buffer. ">encrypt()</a> </dd></dl>
<p>Implements <a class="el" href="classCipher.html#ac6099d1a0d7f2ff67b0e4ccb4a17eb08">Cipher</a>.</p>
<p>Definition at line <a class="el" href="ChaCha_8cpp_source.html#l00190">190</a> of file <a class="el" href="ChaCha_8cpp_source.html">ChaCha.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="acd4fff140b8871c233d9a31abf753ed8"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void ChaCha::encrypt </td>
<td>(</td>
<td class="paramtype">uint8_t *&#160;</td>
<td class="paramname"><em>output</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const uint8_t *&#160;</td>
<td class="paramname"><em>input</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>len</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Encrypts an input buffer and writes the ciphertext to an output buffer. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">output</td><td>The output buffer to write to, which may be the same buffer as <em>input</em>. The <em>output</em> buffer must have at least as many bytes as the <em>input</em> buffer. </td></tr>
<tr><td class="paramname">input</td><td>The input buffer to read from. </td></tr>
<tr><td class="paramname">len</td><td>The number of bytes to encrypt.</td></tr>
</table>
</dd>
</dl>
<p>The <a class="el" href="classChaCha.html#acd4fff140b8871c233d9a31abf753ed8" title="Encrypts an input buffer and writes the ciphertext to an output buffer. ">encrypt()</a> function can be called multiple times with different regions of the plaintext data.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classChaCha.html#a1f54b2b51b59428010f81a6c4dc4e42c" title="Decrypts an input buffer and writes the plaintext to an output buffer. ">decrypt()</a> </dd></dl>
<p>Implements <a class="el" href="classCipher.html#ad2832bd61039d61560e34ea3382ca562">Cipher</a>.</p>
<p>Definition at line <a class="el" href="ChaCha_8cpp_source.html#l00158">158</a> of file <a class="el" href="ChaCha_8cpp_source.html">ChaCha.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="a41ac3262e52ff49dcd916d0b3b2e2038"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void ChaCha::hashCore </td>
<td>(</td>
<td class="paramtype">uint32_t *&#160;</td>
<td class="paramname"><em>output</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const uint32_t *&#160;</td>
<td class="paramname"><em>input</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&#160;</td>
<td class="paramname"><em>rounds</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Executes the <a class="el" href="classChaCha.html" title="ChaCha stream cipher. ">ChaCha</a> hash core on an input memory block. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">output</td><td>Output memory block, must be at least 16 words in length and must not overlap with <em>input</em>. </td></tr>
<tr><td class="paramname">input</td><td>Input memory block, must be at least 16 words in length. </td></tr>
<tr><td class="paramname">rounds</td><td>Number of <a class="el" href="classChaCha.html" title="ChaCha stream cipher. ">ChaCha</a> rounds to perform; usually 8, 12, or 20.</td></tr>
</table>
</dd>
</dl>
<p>This function is provided for the convenience of applications that need access to the <a class="el" href="classChaCha.html" title="ChaCha stream cipher. ">ChaCha</a> hash core without the higher-level processing that turns the core into a stream cipher. </p>
<p>Definition at line <a class="el" href="ChaCha_8cpp_source.html#l00253">253</a> of file <a class="el" href="ChaCha_8cpp_source.html">ChaCha.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="afaa3df343a7d07976bd7e03a0c1bf43c"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">size_t ChaCha::ivSize </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Size of the initialization vector for this cipher, in bytes. </p>
<p>If the cipher does not need an initialization vector, this function will return zero. </p>
<p>Implements <a class="el" href="classCipher.html#ab8b53ddc4ce431f03c2a1903d70ace9c">Cipher</a>.</p>
<p>Definition at line <a class="el" href="ChaCha_8cpp_source.html#l00065">65</a> of file <a class="el" href="ChaCha_8cpp_source.html">ChaCha.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="af286083291fab2bd36dc7ad1f54d5cd7"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">size_t ChaCha::keySize </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Default size of the key for this cipher, in bytes. </p>
<p>If the cipher supports variable-sized keys, <a class="el" href="classChaCha.html#af286083291fab2bd36dc7ad1f54d5cd7" title="Default size of the key for this cipher, in bytes. ">keySize()</a> indicates the default or recommended key size. The cipher may support other key sizes.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classChaCha.html#a6b2bdffbd3705e388bb458edb2f40c90" title="Sets the key to use for future encryption and decryption operations. ">setKey()</a>, <a class="el" href="classChaCha.html#afaa3df343a7d07976bd7e03a0c1bf43c" title="Size of the initialization vector for this cipher, in bytes. ">ivSize()</a> </dd></dl>
<p>Implements <a class="el" href="classCipher.html#a4cea432ea0278c865441f17cbb88b1ab">Cipher</a>.</p>
<p>Definition at line <a class="el" href="ChaCha_8cpp_source.html#l00059">59</a> of file <a class="el" href="ChaCha_8cpp_source.html">ChaCha.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="a0a73d3623da377bc593876156768dd72"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">uint8_t ChaCha::numRounds </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns the number of encryption rounds; usually 8, 12, or 20. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classChaCha.html#a1a0911e0be8f4590d7fb76884d98c541" title="Sets the number of encryption rounds. ">setNumRounds()</a> </dd></dl>
<p>Definition at line <a class="el" href="ChaCha_8h_source.html#l00039">39</a> of file <a class="el" href="ChaCha_8h_source.html">ChaCha.h</a>.</p>
</div>
</div>
<a class="anchor" id="acab9109b7189ea88d9e5417a3a209eac"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">bool ChaCha::setCounter </td>
<td>(</td>
<td class="paramtype">const uint8_t *&#160;</td>
<td class="paramname"><em>counter</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>len</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Sets the starting counter for encryption. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">counter</td><td>A 4-byte or 8-byte value to use for the starting counter instead of the default value of zero. </td></tr>
<tr><td class="paramname">len</td><td>The length of the counter, which must be 4 or 8. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Returns false if <em>len</em> is not 4 or 8.</dd></dl>
<p>This function must be called after <a class="el" href="classChaCha.html#a734f3246b1e6810c63637b8cda26b259" title="Sets the initialization vector to use for future encryption and decryption operations. ">setIV()</a> and before the first call to <a class="el" href="classChaCha.html#acd4fff140b8871c233d9a31abf753ed8" title="Encrypts an input buffer and writes the ciphertext to an output buffer. ">encrypt()</a>. It is used to specify a different starting value than zero for the counter portion of the hash input.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classChaCha.html#a734f3246b1e6810c63637b8cda26b259" title="Sets the initialization vector to use for future encryption and decryption operations. ">setIV()</a> </dd></dl>
<p>Definition at line <a class="el" href="ChaCha_8cpp_source.html#l00145">145</a> of file <a class="el" href="ChaCha_8cpp_source.html">ChaCha.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="a734f3246b1e6810c63637b8cda26b259"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool ChaCha::setIV </td>
<td>(</td>
<td class="paramtype">const uint8_t *&#160;</td>
<td class="paramname"><em>iv</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>len</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Sets the initialization vector to use for future encryption and decryption operations. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">iv</td><td>The initialization vector to use. </td></tr>
<tr><td class="paramname">len</td><td>The length of the initialization vector in bytes. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Returns false if the length is not supported.</dd></dl>
<p>Initialization vectors should be set before the first call to <a class="el" href="classChaCha.html#acd4fff140b8871c233d9a31abf753ed8" title="Encrypts an input buffer and writes the ciphertext to an output buffer. ">encrypt()</a> or <a class="el" href="classChaCha.html#a1f54b2b51b59428010f81a6c4dc4e42c" title="Decrypts an input buffer and writes the plaintext to an output buffer. ">decrypt()</a> after a <a class="el" href="classChaCha.html#a6b2bdffbd3705e388bb458edb2f40c90" title="Sets the key to use for future encryption and decryption operations. ">setKey()</a> call. If the initialization vector is changed after encryption or decryption begins, then the behaviour is undefined.</p>
<dl class="section note"><dt>Note</dt><dd>The IV is not encoded into the output stream by <a class="el" href="classChaCha.html#acd4fff140b8871c233d9a31abf753ed8" title="Encrypts an input buffer and writes the ciphertext to an output buffer. ">encrypt()</a>. The caller is responsible for communicating the IV to the other party.</dd></dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classChaCha.html#afaa3df343a7d07976bd7e03a0c1bf43c" title="Size of the initialization vector for this cipher, in bytes. ">ivSize()</a> </dd></dl>
<p>Implements <a class="el" href="classCipher.html#a3777acd8ff776a4e945bb7c9f2d044d9">Cipher</a>.</p>
<p>Definition at line <a class="el" href="ChaCha_8cpp_source.html#l00111">111</a> of file <a class="el" href="ChaCha_8cpp_source.html">ChaCha.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="a6b2bdffbd3705e388bb458edb2f40c90"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">bool ChaCha::setKey </td>
<td>(</td>
<td class="paramtype">const uint8_t *&#160;</td>
<td class="paramname"><em>key</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>len</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Sets the key to use for future encryption and decryption operations. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">key</td><td>The key to use. </td></tr>
<tr><td class="paramname">len</td><td>The length of the key in bytes. </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Returns false if the key length is not supported, or the key is somehow "weak" and unusable by this cipher.</dd></dl>
<p>Use <a class="el" href="classChaCha.html#af533905f679066c41f4d6cd76bddb4cb" title="Clears all security-sensitive state from this cipher. ">clear()</a> or the destructor to remove the key and any other sensitive data from the object once encryption or decryption is complete.</p>
<p>Calling <a class="el" href="classChaCha.html#a6b2bdffbd3705e388bb458edb2f40c90" title="Sets the key to use for future encryption and decryption operations. ">setKey()</a> resets the cipher. Any temporary data that was being retained for encrypting partial blocks will be abandoned.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classChaCha.html#af286083291fab2bd36dc7ad1f54d5cd7" title="Default size of the key for this cipher, in bytes. ">keySize()</a>, <a class="el" href="classChaCha.html#af533905f679066c41f4d6cd76bddb4cb" title="Clears all security-sensitive state from this cipher. ">clear()</a> </dd></dl>
<p>Implements <a class="el" href="classCipher.html#a0dfe133bda81dfa680b668f5908ccbe5">Cipher</a>.</p>
<p>Definition at line <a class="el" href="ChaCha_8cpp_source.html#l00087">87</a> of file <a class="el" href="ChaCha_8cpp_source.html">ChaCha.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="a1a0911e0be8f4590d7fb76884d98c541"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void ChaCha::setNumRounds </td>
<td>(</td>
<td class="paramtype">uint8_t&#160;</td>
<td class="paramname"><em>numRounds</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Sets the number of encryption rounds. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">numRounds</td><td>The number of encryption rounds; usually 8, 12, or 20.</td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classChaCha.html#a0a73d3623da377bc593876156768dd72" title="Returns the number of encryption rounds; usually 8, 12, or 20. ">numRounds()</a> </dd></dl>
<p>Definition at line <a class="el" href="ChaCha_8h_source.html#l00040">40</a> of file <a class="el" href="ChaCha_8h_source.html">ChaCha.h</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="ChaCha_8h_source.html">ChaCha.h</a></li>
<li><a class="el" href="ChaCha_8cpp_source.html">ChaCha.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 27 2018 12:01:32 for Arduino Cryptography Library by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>