1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00
arduinolibs/classCTR.html
Rhys Weatherley e923155962 Update docs
2017-11-03 10:49:30 +10:00

190 lines
20 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>ArduinoLibs: CTR&lt; T &gt; Class Template 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">ArduinoLibs
</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><a href="modules.html"><span>Modules</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>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><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="classCTR-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">CTR&lt; T &gt; Class Template Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>Implementation of the Counter (<a class="el" href="classCTR.html" title="Implementation of the Counter (CTR) mode for 128-bit block ciphers. ">CTR</a>) mode for 128-bit block ciphers.
<a href="classCTR.html#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="CTR_8h_source.html">CTR.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for CTR&lt; T &gt;:</div>
<div class="dyncontent">
<div class="center">
<img src="classCTR.png" usemap="#CTR&lt; T &gt;_map" alt=""/>
<map id="CTR&lt; T &gt;_map" name="CTR&lt; T &gt;_map">
<area href="classCTRCommon.html" title="Concrete base class to assist with implementing CTR mode for 128-bit block ciphers. " alt="CTRCommon" shape="rect" coords="0,56,84,80"/>
<area href="classCipher.html" title="Abstract base class for stream ciphers. " alt="Cipher" shape="rect" coords="0,0,84,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:a7025ab5d79f0f0763f751aeabc425ca9"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7025ab5d79f0f0763f751aeabc425ca9"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCTR.html#a7025ab5d79f0f0763f751aeabc425ca9">CTR</a> ()</td></tr>
<tr class="memdesc:a7025ab5d79f0f0763f751aeabc425ca9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a new <a class="el" href="classCTR.html" title="Implementation of the Counter (CTR) mode for 128-bit block ciphers. ">CTR</a> object for the 128-bit block cipher T. <br/></td></tr>
<tr class="separator:a7025ab5d79f0f0763f751aeabc425ca9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classCTRCommon"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classCTRCommon')"><img src="closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="classCTRCommon.html">CTRCommon</a></td></tr>
<tr class="memitem:a29ce8e13a302350397fc6790a686bea2 inherit pub_methods_classCTRCommon"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCTRCommon.html#a29ce8e13a302350397fc6790a686bea2">keySize</a> () const </td></tr>
<tr class="memdesc:a29ce8e13a302350397fc6790a686bea2 inherit pub_methods_classCTRCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default size of the key for this cipher, in bytes. <a href="#a29ce8e13a302350397fc6790a686bea2">More...</a><br/></td></tr>
<tr class="separator:a29ce8e13a302350397fc6790a686bea2 inherit pub_methods_classCTRCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a98c1717d11d8da8e1fa108607358774a inherit pub_methods_classCTRCommon"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCTRCommon.html#a98c1717d11d8da8e1fa108607358774a">ivSize</a> () const </td></tr>
<tr class="memdesc:a98c1717d11d8da8e1fa108607358774a inherit pub_methods_classCTRCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Size of the initialization vector for this cipher, in bytes. <a href="#a98c1717d11d8da8e1fa108607358774a">More...</a><br/></td></tr>
<tr class="separator:a98c1717d11d8da8e1fa108607358774a inherit pub_methods_classCTRCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae2bc6b33a864412598b426320d853337 inherit pub_methods_classCTRCommon"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCTRCommon.html#ae2bc6b33a864412598b426320d853337">setCounterSize</a> (size_t size)</td></tr>
<tr class="memdesc:ae2bc6b33a864412598b426320d853337 inherit pub_methods_classCTRCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the counter size for the IV. <a href="#ae2bc6b33a864412598b426320d853337">More...</a><br/></td></tr>
<tr class="separator:ae2bc6b33a864412598b426320d853337 inherit pub_methods_classCTRCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a79da937dc2c444a174176beab33c055a inherit pub_methods_classCTRCommon"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCTRCommon.html#a79da937dc2c444a174176beab33c055a">setKey</a> (const uint8_t *key, size_t len)</td></tr>
<tr class="memdesc:a79da937dc2c444a174176beab33c055a inherit pub_methods_classCTRCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the key to use for future encryption and decryption operations. <a href="#a79da937dc2c444a174176beab33c055a">More...</a><br/></td></tr>
<tr class="separator:a79da937dc2c444a174176beab33c055a inherit pub_methods_classCTRCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aad289af3eb013cb3ffda6d7e8e8b3d04 inherit pub_methods_classCTRCommon"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCTRCommon.html#aad289af3eb013cb3ffda6d7e8e8b3d04">setIV</a> (const uint8_t *iv, size_t len)</td></tr>
<tr class="memdesc:aad289af3eb013cb3ffda6d7e8e8b3d04 inherit pub_methods_classCTRCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the initial counter value to use for future encryption and decryption operations. <a href="#aad289af3eb013cb3ffda6d7e8e8b3d04">More...</a><br/></td></tr>
<tr class="separator:aad289af3eb013cb3ffda6d7e8e8b3d04 inherit pub_methods_classCTRCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a201bda584d111552ce8ec09fac759963 inherit pub_methods_classCTRCommon"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCTRCommon.html#a201bda584d111552ce8ec09fac759963">encrypt</a> (uint8_t *output, const uint8_t *input, size_t len)</td></tr>
<tr class="memdesc:a201bda584d111552ce8ec09fac759963 inherit pub_methods_classCTRCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Encrypts an input buffer and writes the ciphertext to an output buffer. <a href="#a201bda584d111552ce8ec09fac759963">More...</a><br/></td></tr>
<tr class="separator:a201bda584d111552ce8ec09fac759963 inherit pub_methods_classCTRCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0943387cf1124258389702e0690740fe inherit pub_methods_classCTRCommon"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCTRCommon.html#a0943387cf1124258389702e0690740fe">decrypt</a> (uint8_t *output, const uint8_t *input, size_t len)</td></tr>
<tr class="memdesc:a0943387cf1124258389702e0690740fe inherit pub_methods_classCTRCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Decrypts an input buffer and writes the plaintext to an output buffer. <a href="#a0943387cf1124258389702e0690740fe">More...</a><br/></td></tr>
<tr class="separator:a0943387cf1124258389702e0690740fe inherit pub_methods_classCTRCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac0d6381c02fe2a8a017ad66d006a6ef2 inherit pub_methods_classCTRCommon"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCTRCommon.html#ac0d6381c02fe2a8a017ad66d006a6ef2">clear</a> ()</td></tr>
<tr class="memdesc:ac0d6381c02fe2a8a017ad66d006a6ef2 inherit pub_methods_classCTRCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clears all security-sensitive state from this cipher. <a href="#ac0d6381c02fe2a8a017ad66d006a6ef2">More...</a><br/></td></tr>
<tr class="separator:ac0d6381c02fe2a8a017ad66d006a6ef2 inherit pub_methods_classCTRCommon"><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="inherited"></a>
Additional Inherited Members</h2></td></tr>
<tr class="inherit_header pro_methods_classCTRCommon"><td colspan="2" onclick="javascript:toggleInherit('pro_methods_classCTRCommon')"><img src="closed.png" alt="-"/>&#160;Protected Member Functions inherited from <a class="el" href="classCTRCommon.html">CTRCommon</a></td></tr>
<tr class="memitem:abeb01342f17023e99776001d397c51ff inherit pro_methods_classCTRCommon"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCTRCommon.html#abeb01342f17023e99776001d397c51ff">CTRCommon</a> ()</td></tr>
<tr class="memdesc:abeb01342f17023e99776001d397c51ff inherit pro_methods_classCTRCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a new cipher in <a class="el" href="classCTR.html" title="Implementation of the Counter (CTR) mode for 128-bit block ciphers. ">CTR</a> mode. <a href="#abeb01342f17023e99776001d397c51ff">More...</a><br/></td></tr>
<tr class="separator:abeb01342f17023e99776001d397c51ff inherit pro_methods_classCTRCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6c409c4ec1f99e0cb751196d891dc228 inherit pro_methods_classCTRCommon"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classCTRCommon.html#a6c409c4ec1f99e0cb751196d891dc228">setBlockCipher</a> (<a class="el" href="classBlockCipher.html">BlockCipher</a> *cipher)</td></tr>
<tr class="memdesc:a6c409c4ec1f99e0cb751196d891dc228 inherit pro_methods_classCTRCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the block cipher to use for this <a class="el" href="classCTR.html" title="Implementation of the Counter (CTR) mode for 128-bit block ciphers. ">CTR</a> object. <a href="#a6c409c4ec1f99e0cb751196d891dc228">More...</a><br/></td></tr>
<tr class="separator:a6c409c4ec1f99e0cb751196d891dc228 inherit pro_methods_classCTRCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename T&gt;<br/>
class CTR&lt; T &gt;</h3>
<p>Implementation of the Counter (<a class="el" href="classCTR.html" title="Implementation of the Counter (CTR) mode for 128-bit block ciphers. ">CTR</a>) mode for 128-bit block ciphers. </p>
<p>Counter mode converts a block cipher into a stream cipher. The specific block cipher is passed as the template parameter T and the key is specified via the <a class="el" href="classCTRCommon.html#a79da937dc2c444a174176beab33c055a" title="Sets the key to use for future encryption and decryption operations. ">setKey()</a> function.</p>
<p>Keystream blocks are generated by encrypting an increasing counter value and XOR'ing it with each byte of input. The <a class="el" href="classCTRCommon.html#a201bda584d111552ce8ec09fac759963" title="Encrypts an input buffer and writes the ciphertext to an output buffer. ">encrypt()</a> and <a class="el" href="classCTRCommon.html#a0943387cf1124258389702e0690740fe" title="Decrypts an input buffer and writes the plaintext to an output buffer. ">decrypt()</a> operations are identical.</p>
<p>The template parameter T must be a concrete subclass of <a class="el" href="classBlockCipher.html" title="Abstract base class for block ciphers. ">BlockCipher</a> indicating the specific block cipher to use. For example, the following creates a <a class="el" href="classCTR.html" title="Implementation of the Counter (CTR) mode for 128-bit block ciphers. ">CTR</a> object using <a class="el" href="classAES256.html" title="AES block cipher with 256-bit keys. ">AES256</a> as the underlying cipher:</p>
<div class="fragment"><div class="line"><a class="code" href="classCTR.html">CTR&lt;AES256&gt;</a> ctr;</div>
<div class="line">ctr.<a class="code" href="classCTRCommon.html#a79da937dc2c444a174176beab33c055a">setKey</a>(key, 32);</div>
<div class="line">ctr.<a class="code" href="classCTRCommon.html#aad289af3eb013cb3ffda6d7e8e8b3d04">setIV</a>(iv, 16);</div>
<div class="line">ctr.<a class="code" href="classCTRCommon.html#ae2bc6b33a864412598b426320d853337">setCounterSize</a>(4);</div>
<div class="line">ctr.<a class="code" href="classCTRCommon.html#a201bda584d111552ce8ec09fac759963">encrypt</a>(output, input, len);</div>
</div><!-- fragment --><p>In this example, the last 4 bytes of the IV are incremented to count blocks. The remaining bytes are left unchanged from block to block.</p>
<p>Reference: <a href="http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation">http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation</a></p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classCFB.html" title="Implementation of the Cipher Feedback (CFB) mode for 128-bit block ciphers. ">CFB</a>, <a class="el" href="classOFB.html" title="Implementation of the Output Feedback (OFB) mode for 128-bit block ciphers. ">OFB</a>, <a class="el" href="classCBC.html" title="Implementation of the Cipher Block Chaining (CBC) mode for 128-bit block ciphers. ...">CBC</a> </dd></dl>
<p>Definition at line <a class="el" href="CTR_8h_source.html#l00060">60</a> of file <a class="el" href="CTR_8h_source.html">CTR.h</a>.</p>
</div><hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="CTR_8h_source.html">CTR.h</a></li>
<li><a class="el" href="CTR_8cpp_source.html">CTR.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Nov 3 2017 10:48:53 for ArduinoLibs 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>