1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00
arduinolibs/classGCM.html
Rhys Weatherley c74770a343 Update docs
2016-02-14 07:48:23 +10:00

232 lines
28 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: GCM&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>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><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="classGCM-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">GCM&lt; T &gt; Class Template Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>Implementation of the Galois Counter Mode (<a class="el" href="classGCM.html" title="Implementation of the Galois Counter Mode (GCM). ">GCM</a>).
<a href="classGCM.html#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="GCM_8h_source.html">GCM.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for GCM&lt; T &gt;:</div>
<div class="dyncontent">
<div class="center">
<img src="classGCM.png" usemap="#GCM&lt; T &gt;_map" alt=""/>
<map id="GCM&lt; T &gt;_map" name="GCM&lt; T &gt;_map">
<area href="classGCMCommon.html" title="Concrete base class to assist with implementing GCM for 128-bit block ciphers. " alt="GCMCommon" shape="rect" coords="0,112,127,136"/>
<area href="classAuthenticatedCipher.html" title="Abstract base class for authenticated ciphers. " alt="AuthenticatedCipher" shape="rect" coords="0,56,127,80"/>
<area href="classCipher.html" title="Abstract base class for stream ciphers. " alt="Cipher" shape="rect" coords="0,0,127,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:acbef04a5593177aabf19df538ad3def7"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="acbef04a5593177aabf19df538ad3def7"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCM.html#acbef04a5593177aabf19df538ad3def7">GCM</a> ()</td></tr>
<tr class="memdesc:acbef04a5593177aabf19df538ad3def7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a new <a class="el" href="classGCM.html" title="Implementation of the Galois Counter Mode (GCM). ">GCM</a> object for the block cipher T. <br/></td></tr>
<tr class="separator:acbef04a5593177aabf19df538ad3def7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classGCMCommon"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classGCMCommon')"><img src="closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="classGCMCommon.html">GCMCommon</a></td></tr>
<tr class="memitem:a0d3e1525d91adbbdcd5ac27793817112 inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0d3e1525d91adbbdcd5ac27793817112"></a>
virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a0d3e1525d91adbbdcd5ac27793817112">~GCMCommon</a> ()</td></tr>
<tr class="memdesc:a0d3e1525d91adbbdcd5ac27793817112 inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroys this cipher object after clearing sensitive information. <br/></td></tr>
<tr class="separator:a0d3e1525d91adbbdcd5ac27793817112 inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a134ba35e740a18bee3c45502b4149eae inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a134ba35e740a18bee3c45502b4149eae">keySize</a> () const </td></tr>
<tr class="memdesc:a134ba35e740a18bee3c45502b4149eae inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Default size of the key for this cipher, in bytes. <a href="#a134ba35e740a18bee3c45502b4149eae">More...</a><br/></td></tr>
<tr class="separator:a134ba35e740a18bee3c45502b4149eae inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a01cff072505e861fd20f6cfee1e10fb2 inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a01cff072505e861fd20f6cfee1e10fb2">ivSize</a> () const </td></tr>
<tr class="memdesc:a01cff072505e861fd20f6cfee1e10fb2 inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Size of the initialization vector for this cipher, in bytes. <a href="#a01cff072505e861fd20f6cfee1e10fb2">More...</a><br/></td></tr>
<tr class="separator:a01cff072505e861fd20f6cfee1e10fb2 inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a935f343858e98ee331706daf43e34805 inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a935f343858e98ee331706daf43e34805">tagSize</a> () const </td></tr>
<tr class="memdesc:a935f343858e98ee331706daf43e34805 inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the size of the authentication tag. <a href="#a935f343858e98ee331706daf43e34805">More...</a><br/></td></tr>
<tr class="separator:a935f343858e98ee331706daf43e34805 inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a397c5dddde828c59eb63367385aec562 inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a397c5dddde828c59eb63367385aec562">setKey</a> (const uint8_t *key, size_t len)</td></tr>
<tr class="memdesc:a397c5dddde828c59eb63367385aec562 inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the key to use for future encryption and decryption operations. <a href="#a397c5dddde828c59eb63367385aec562">More...</a><br/></td></tr>
<tr class="separator:a397c5dddde828c59eb63367385aec562 inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2545135fe42c832e40e057b603824524 inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a2545135fe42c832e40e057b603824524">setIV</a> (const uint8_t *iv, size_t len)</td></tr>
<tr class="memdesc:a2545135fe42c832e40e057b603824524 inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the initialization vector to use for future encryption and decryption operations. <a href="#a2545135fe42c832e40e057b603824524">More...</a><br/></td></tr>
<tr class="separator:a2545135fe42c832e40e057b603824524 inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a01ac69afe3d9fc4d72b2ea5dc242e55c inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a01ac69afe3d9fc4d72b2ea5dc242e55c">encrypt</a> (uint8_t *output, const uint8_t *input, size_t len)</td></tr>
<tr class="memdesc:a01ac69afe3d9fc4d72b2ea5dc242e55c inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Encrypts an input buffer and writes the ciphertext to an output buffer. <a href="#a01ac69afe3d9fc4d72b2ea5dc242e55c">More...</a><br/></td></tr>
<tr class="separator:a01ac69afe3d9fc4d72b2ea5dc242e55c inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a60912d3ab5766aa68dc9b3111ac2c0d7 inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a60912d3ab5766aa68dc9b3111ac2c0d7">decrypt</a> (uint8_t *output, const uint8_t *input, size_t len)</td></tr>
<tr class="memdesc:a60912d3ab5766aa68dc9b3111ac2c0d7 inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Decrypts an input buffer and writes the plaintext to an output buffer. <a href="#a60912d3ab5766aa68dc9b3111ac2c0d7">More...</a><br/></td></tr>
<tr class="separator:a60912d3ab5766aa68dc9b3111ac2c0d7 inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad926e980ae2d61c10c9bf82813154a25 inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#ad926e980ae2d61c10c9bf82813154a25">addAuthData</a> (const void *data, size_t len)</td></tr>
<tr class="memdesc:ad926e980ae2d61c10c9bf82813154a25 inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Adds extra data that will be authenticated but not encrypted. <a href="#ad926e980ae2d61c10c9bf82813154a25">More...</a><br/></td></tr>
<tr class="separator:ad926e980ae2d61c10c9bf82813154a25 inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a444634bd4469bb5d404ac882d1d8fdf4 inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a444634bd4469bb5d404ac882d1d8fdf4">computeTag</a> (void *tag, size_t len)</td></tr>
<tr class="memdesc:a444634bd4469bb5d404ac882d1d8fdf4 inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Finalizes the encryption process and computes the authentication tag. <a href="#a444634bd4469bb5d404ac882d1d8fdf4">More...</a><br/></td></tr>
<tr class="separator:a444634bd4469bb5d404ac882d1d8fdf4 inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a70229be2fe2274c4109fe7511481075a inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a70229be2fe2274c4109fe7511481075a">checkTag</a> (const void *tag, size_t len)</td></tr>
<tr class="memdesc:a70229be2fe2274c4109fe7511481075a inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Finalizes the decryption process and checks the authentication tag. <a href="#a70229be2fe2274c4109fe7511481075a">More...</a><br/></td></tr>
<tr class="separator:a70229be2fe2274c4109fe7511481075a inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a06868ebd67a571aa68d88d5d072cece9 inherit pub_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a06868ebd67a571aa68d88d5d072cece9">clear</a> ()</td></tr>
<tr class="memdesc:a06868ebd67a571aa68d88d5d072cece9 inherit pub_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Clears all security-sensitive state from this cipher. <a href="#a06868ebd67a571aa68d88d5d072cece9">More...</a><br/></td></tr>
<tr class="separator:a06868ebd67a571aa68d88d5d072cece9 inherit pub_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classAuthenticatedCipher"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classAuthenticatedCipher')"><img src="closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="classAuthenticatedCipher.html">AuthenticatedCipher</a></td></tr>
<tr class="memitem:a0b1c0210ecb9d374d09b5b62a5140ba2 inherit pub_methods_classAuthenticatedCipher"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a0b1c0210ecb9d374d09b5b62a5140ba2"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classAuthenticatedCipher.html#a0b1c0210ecb9d374d09b5b62a5140ba2">AuthenticatedCipher</a> ()</td></tr>
<tr class="memdesc:a0b1c0210ecb9d374d09b5b62a5140ba2 inherit pub_methods_classAuthenticatedCipher"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a new authenticated cipher. <br/></td></tr>
<tr class="separator:a0b1c0210ecb9d374d09b5b62a5140ba2 inherit pub_methods_classAuthenticatedCipher"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae52a07be5b7265ea5898529ec21a79e4 inherit pub_methods_classAuthenticatedCipher"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae52a07be5b7265ea5898529ec21a79e4"></a>
virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classAuthenticatedCipher.html#ae52a07be5b7265ea5898529ec21a79e4">~AuthenticatedCipher</a> ()</td></tr>
<tr class="memdesc:ae52a07be5b7265ea5898529ec21a79e4 inherit pub_methods_classAuthenticatedCipher"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroys this authenticated cipher. <br/></td></tr>
<tr class="separator:ae52a07be5b7265ea5898529ec21a79e4 inherit pub_methods_classAuthenticatedCipher"><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_classGCMCommon"><td colspan="2" onclick="javascript:toggleInherit('pro_methods_classGCMCommon')"><img src="closed.png" alt="-"/>&#160;Protected Member Functions inherited from <a class="el" href="classGCMCommon.html">GCMCommon</a></td></tr>
<tr class="memitem:a1b05ff393e8c20db30cb991e875aab19 inherit pro_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a1b05ff393e8c20db30cb991e875aab19">GCMCommon</a> ()</td></tr>
<tr class="memdesc:a1b05ff393e8c20db30cb991e875aab19 inherit pro_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs a new cipher in <a class="el" href="classGCM.html" title="Implementation of the Galois Counter Mode (GCM). ">GCM</a> mode. <a href="#a1b05ff393e8c20db30cb991e875aab19">More...</a><br/></td></tr>
<tr class="separator:a1b05ff393e8c20db30cb991e875aab19 inherit pro_methods_classGCMCommon"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7abd3044862f8634f3b176aafa779ba2 inherit pro_methods_classGCMCommon"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classGCMCommon.html#a7abd3044862f8634f3b176aafa779ba2">setBlockCipher</a> (<a class="el" href="classBlockCipher.html">BlockCipher</a> *cipher)</td></tr>
<tr class="memdesc:a7abd3044862f8634f3b176aafa779ba2 inherit pro_methods_classGCMCommon"><td class="mdescLeft">&#160;</td><td class="mdescRight">Sets the block cipher to use for this <a class="el" href="classGCM.html" title="Implementation of the Galois Counter Mode (GCM). ">GCM</a> object. <a href="#a7abd3044862f8634f3b176aafa779ba2">More...</a><br/></td></tr>
<tr class="separator:a7abd3044862f8634f3b176aafa779ba2 inherit pro_methods_classGCMCommon"><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 GCM&lt; T &gt;</h3>
<p>Implementation of the Galois Counter Mode (<a class="el" href="classGCM.html" title="Implementation of the Galois Counter Mode (GCM). ">GCM</a>). </p>
<p><a class="el" href="classGCM.html" title="Implementation of the Galois Counter Mode (GCM). ">GCM</a> mode converts a block cipher into an authenticated cipher that uses the block cipher T to encrypt and <a class="el" href="classGHASH.html" title="Implementation of the GHASH message authenticator. ">GHASH</a> to authenticate.</p>
<p>The size of the key is determined by the underlying block cipher T. The IV is recommended to be 96 bits (12 bytes) in length, but other lengths are supported as well. The default <a class="el" href="classGCMCommon.html#a935f343858e98ee331706daf43e34805" title="Returns the size of the authentication tag. ">tagSize()</a> is 128 bits (16 bytes) but the <a class="el" href="classGCM.html" title="Implementation of the Galois Counter Mode (GCM). ">GCM</a> specification does allow other tag sizes: 32, 64, 96, 104, 112, 120, or 128 bits (4, 8, 12, 13, 14, 15, or 16 bytes).</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. The block cipher must have a block size of 128 bits. For example, the following creates a <a class="el" href="classGCM.html" title="Implementation of the Galois Counter Mode (GCM). ">GCM</a> object using <a class="el" href="classAES256.html" title="AES block cipher with 256-bit keys. ">AES256</a> as the underlying cipher and then uses it to encrypt and authenticate a <code>plaintext</code> block:</p>
<div class="fragment"><div class="line"><a class="code" href="classGCM.html">GCM&lt;AES256&gt;</a> gcm;</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#a397c5dddde828c59eb63367385aec562">setKey</a>(key, <span class="keyword">sizeof</span>(key));</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#a2545135fe42c832e40e057b603824524">setIV</a>(iv, <span class="keyword">sizeof</span>(iv));</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#ad926e980ae2d61c10c9bf82813154a25">addAuthData</a>(adata, <span class="keyword">sizeof</span>(adata));</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#a01ac69afe3d9fc4d72b2ea5dc242e55c">encrypt</a>(ciphertext, plaintext, <span class="keyword">sizeof</span>(plaintext));</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#a444634bd4469bb5d404ac882d1d8fdf4">computeTag</a>(tag, <span class="keyword">sizeof</span>(tag));</div>
</div><!-- fragment --><p>The decryption process is almost identical to convert a <code>ciphertext</code> and <em>tag</em> back into plaintext and then check the tag:</p>
<div class="fragment"><div class="line"><a class="code" href="classGCM.html">GCM&lt;AES256&gt;</a> gcm;</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#a397c5dddde828c59eb63367385aec562">setKey</a>(key, <span class="keyword">sizeof</span>(key));</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#a2545135fe42c832e40e057b603824524">setIV</a>(iv, <span class="keyword">sizeof</span>(iv));</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#ad926e980ae2d61c10c9bf82813154a25">addAuthData</a>(adata, <span class="keyword">sizeof</span>(adata));</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#a60912d3ab5766aa68dc9b3111ac2c0d7">decrypt</a>(ciphertext, plaintext, <span class="keyword">sizeof</span>(plaintext));</div>
<div class="line"><span class="keywordflow">if</span> (!gcm.<a class="code" href="classGCMCommon.html#a70229be2fe2274c4109fe7511481075a">checkTag</a>(tag, <span class="keyword">sizeof</span>(tag))) {</div>
<div class="line"> <span class="comment">// The data was invalid - do not use it.</span></div>
<div class="line"> ...</div>
<div class="line">}</div>
</div><!-- fragment --><p>The <a class="el" href="classGCM.html" title="Implementation of the Galois Counter Mode (GCM). ">GCM</a> class can also be used to implement GMAC message authentication by omitting the plaintext:</p>
<div class="fragment"><div class="line"><a class="code" href="classGCM.html">GCM&lt;AES256&gt;</a> gcm;</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#a397c5dddde828c59eb63367385aec562">setKey</a>(key, <span class="keyword">sizeof</span>(key));</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#a2545135fe42c832e40e057b603824524">setIV</a>(iv, <span class="keyword">sizeof</span>(iv));</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#ad926e980ae2d61c10c9bf82813154a25">addAuthData</a>(adata1, <span class="keyword">sizeof</span>(adata1));</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#ad926e980ae2d61c10c9bf82813154a25">addAuthData</a>(adata2, <span class="keyword">sizeof</span>(adata1));</div>
<div class="line">...</div>
<div class="line">gcm.addAuthData(adataN, <span class="keyword">sizeof</span>(adataN));</div>
<div class="line">gcm.<a class="code" href="classGCMCommon.html#a444634bd4469bb5d404ac882d1d8fdf4">computeTag</a>(tag, <span class="keyword">sizeof</span>(tag));</div>
</div><!-- fragment --><p>References: <a href="http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf">NIST SP 800-38D</a>, <a href="http://en.wikipedia.org/wiki/Galois/Counter_Mode">http://en.wikipedia.org/wiki/Galois/Counter_Mode</a></p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classGCMCommon.html" title="Concrete base class to assist with implementing GCM for 128-bit block ciphers. ">GCMCommon</a>, <a class="el" href="classGHASH.html" title="Implementation of the GHASH message authenticator. ">GHASH</a> </dd></dl>
<p>Definition at line <a class="el" href="GCM_8h_source.html#l00071">71</a> of file <a class="el" href="GCM_8h_source.html">GCM.h</a>.</p>
</div><hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="GCM_8h_source.html">GCM.h</a></li>
<li><a class="el" href="GCM_8cpp_source.html">GCM.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Feb 14 2016 07:48:07 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>