mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
655 lines
37 KiB
HTML
655 lines
37 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: P521 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">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 Page</span></a></li>
|
|
<li><a href="pages.html"><span>Related 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 List</span></a></li>
|
|
<li><a href="classes.html"><span>Class Index</span></a></li>
|
|
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
|
|
<li><a href="functions.html"><span>Class 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"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </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-static-methods">Static Public Member Functions</a> |
|
|
<a href="classP521-members.html">List of all members</a> </div>
|
|
<div class="headertitle">
|
|
<div class="title">P521 Class Reference</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>Elliptic curve operations with the NIST P-521 curve.
|
|
<a href="classP521.html#details">More...</a></p>
|
|
|
|
<p><code>#include <<a class="el" href="P521_8h_source.html">P521.h</a>></code></p>
|
|
<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:ac2e07ce7e846ba180938b41b4a2ae563"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classP521.html#ac2e07ce7e846ba180938b41b4a2ae563">eval</a> (uint8_t result[132], const uint8_t f[66], const uint8_t point[132])</td></tr>
|
|
<tr class="memdesc:ac2e07ce7e846ba180938b41b4a2ae563"><td class="mdescLeft"> </td><td class="mdescRight">Evaluates the curve function. <a href="#ac2e07ce7e846ba180938b41b4a2ae563">More...</a><br/></td></tr>
|
|
<tr class="separator:ac2e07ce7e846ba180938b41b4a2ae563"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ae04c439804f445535295bf44ae56afbf"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="classP521.html#ae04c439804f445535295bf44ae56afbf">dh1</a> (uint8_t k[132], uint8_t f[66])</td></tr>
|
|
<tr class="memdesc:ae04c439804f445535295bf44ae56afbf"><td class="mdescLeft"> </td><td class="mdescRight">Performs phase 1 of an ECDH key exchange using P-521. <a href="#ae04c439804f445535295bf44ae56afbf">More...</a><br/></td></tr>
|
|
<tr class="separator:ae04c439804f445535295bf44ae56afbf"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a7b9d4f74cc2d71a488a33ab165537491"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classP521.html#a7b9d4f74cc2d71a488a33ab165537491">dh2</a> (const uint8_t k[132], uint8_t f[66])</td></tr>
|
|
<tr class="memdesc:a7b9d4f74cc2d71a488a33ab165537491"><td class="mdescLeft"> </td><td class="mdescRight">Performs phase 2 of an ECDH key exchange using P-521. <a href="#a7b9d4f74cc2d71a488a33ab165537491">More...</a><br/></td></tr>
|
|
<tr class="separator:a7b9d4f74cc2d71a488a33ab165537491"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ab050ceff65e49b646b8157fe1474288a"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="classP521.html#ab050ceff65e49b646b8157fe1474288a">sign</a> (uint8_t signature[132], const uint8_t privateKey[66], const void *message, size_t len, <a class="el" href="classHash.html">Hash</a> *hash=0)</td></tr>
|
|
<tr class="memdesc:ab050ceff65e49b646b8157fe1474288a"><td class="mdescLeft"> </td><td class="mdescRight">Signs a message using a specific P-521 private key. <a href="#ab050ceff65e49b646b8157fe1474288a">More...</a><br/></td></tr>
|
|
<tr class="separator:ab050ceff65e49b646b8157fe1474288a"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ab075909f5cecbb801c6b7c41f20de223"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classP521.html#ab075909f5cecbb801c6b7c41f20de223">verify</a> (const uint8_t signature[132], const uint8_t publicKey[132], const void *message, size_t len, <a class="el" href="classHash.html">Hash</a> *hash=0)</td></tr>
|
|
<tr class="memdesc:ab075909f5cecbb801c6b7c41f20de223"><td class="mdescLeft"> </td><td class="mdescRight">Verifies a signature using a specific P-521 public key. <a href="#ab075909f5cecbb801c6b7c41f20de223">More...</a><br/></td></tr>
|
|
<tr class="separator:ab075909f5cecbb801c6b7c41f20de223"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ae5b727018648e4a165f504024c4ccc45"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="classP521.html#ae5b727018648e4a165f504024c4ccc45">generatePrivateKey</a> (uint8_t privateKey[66])</td></tr>
|
|
<tr class="memdesc:ae5b727018648e4a165f504024c4ccc45"><td class="mdescLeft"> </td><td class="mdescRight">Generates a private key for P-521 signing operations. <a href="#ae5b727018648e4a165f504024c4ccc45">More...</a><br/></td></tr>
|
|
<tr class="separator:ae5b727018648e4a165f504024c4ccc45"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a15ca802e298c7ff3be06924b0edb7daa"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="classP521.html#a15ca802e298c7ff3be06924b0edb7daa">derivePublicKey</a> (uint8_t publicKey[132], const uint8_t privateKey[66])</td></tr>
|
|
<tr class="memdesc:a15ca802e298c7ff3be06924b0edb7daa"><td class="mdescLeft"> </td><td class="mdescRight">Derives the public key from a private key for P-521 signing operations. <a href="#a15ca802e298c7ff3be06924b0edb7daa">More...</a><br/></td></tr>
|
|
<tr class="separator:a15ca802e298c7ff3be06924b0edb7daa"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a5802ebd25142789bb2df930ecd765d39"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classP521.html#a5802ebd25142789bb2df930ecd765d39">isValidPrivateKey</a> (const uint8_t privateKey[66])</td></tr>
|
|
<tr class="memdesc:a5802ebd25142789bb2df930ecd765d39"><td class="mdescLeft"> </td><td class="mdescRight">Validates a private key value to ensure that it is between 1 and q - 1. <a href="#a5802ebd25142789bb2df930ecd765d39">More...</a><br/></td></tr>
|
|
<tr class="separator:a5802ebd25142789bb2df930ecd765d39"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:af0bd7851bb15b737a821320b394aec96"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classP521.html#af0bd7851bb15b737a821320b394aec96">isValidPublicKey</a> (const uint8_t publicKey[132])</td></tr>
|
|
<tr class="memdesc:af0bd7851bb15b737a821320b394aec96"><td class="mdescLeft"> </td><td class="mdescRight">Validates a public key to ensure that it is a valid curve point. <a href="#af0bd7851bb15b737a821320b394aec96">More...</a><br/></td></tr>
|
|
<tr class="separator:af0bd7851bb15b737a821320b394aec96"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a3f045e0b7a483fc557747472ade31298"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classP521.html#a3f045e0b7a483fc557747472ade31298">isValidCurvePoint</a> (const uint8_t point[132])</td></tr>
|
|
<tr class="memdesc:a3f045e0b7a483fc557747472ade31298"><td class="mdescLeft"> </td><td class="mdescRight">Validates a point to ensure that it is on the curve. <a href="#a3f045e0b7a483fc557747472ade31298">More...</a><br/></td></tr>
|
|
<tr class="separator:a3f045e0b7a483fc557747472ade31298"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><p>Elliptic curve operations with the NIST P-521 curve. </p>
|
|
<p>This class supports both ECDH key exchange and ECDSA signatures.</p>
|
|
<dl class="section note"><dt>Note</dt><dd>The public functions in this class need a substantial amount of stack space to store intermediate results while the curve function is being evaluated. About 2k of free stack space is recommended for safety.</dd></dl>
|
|
<p>References: NIST FIPS 186-4, <a href="http://tools.ietf.org/html/rfc6090">RFC 6090</a>, <a href="http://tools.ietf.org/html/rfc6979">RFC 6979</a>, <a href="http://tools.ietf.org/html/rfc6090">RFC 5903</a></p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classCurve25519.html" title="Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19. ">Curve25519</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="P521_8h_source.html#l00030">30</a> of file <a class="el" href="P521_8h_source.html">P521.h</a>.</p>
|
|
</div><h2 class="groupheader">Member Function Documentation</h2>
|
|
<a class="anchor" id="a15ca802e298c7ff3be06924b0edb7daa"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void P521::derivePublicKey </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>publicKey</em>[132], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>privateKey</em>[66] </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>Derives the public key from a private key for P-521 signing operations. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">publicKey</td><td>The public key. </td></tr>
|
|
<tr><td class="paramname">privateKey</td><td>The private key, which is assumed to have been created by <a class="el" href="classP521.html#ae5b727018648e4a165f504024c4ccc45" title="Generates a private key for P-521 signing operations. ">generatePrivateKey()</a>.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classP521.html#ae5b727018648e4a165f504024c4ccc45" title="Generates a private key for P-521 signing operations. ">generatePrivateKey()</a>, <a class="el" href="classP521.html#ab075909f5cecbb801c6b7c41f20de223" title="Verifies a signature using a specific P-521 public key. ">verify()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="P521_8cpp_source.html#l00497">497</a> of file <a class="el" href="P521_8cpp_source.html">P521.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ae04c439804f445535295bf44ae56afbf"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void P521::dh1 </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>k</em>[132], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>f</em>[66] </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>Performs phase 1 of an ECDH key exchange using P-521. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">k</td><td>The key value to send to the other party as part of the exchange. </td></tr>
|
|
<tr><td class="paramname">f</td><td>The generated secret value for this party. This must not be transmitted to any party or stored in permanent storage. It only needs to be kept in memory until <a class="el" href="classP521.html#a7b9d4f74cc2d71a488a33ab165537491" title="Performs phase 2 of an ECDH key exchange using P-521. ">dh2()</a> is called.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>The <em>f</em> value is generated with <a class="el" href="classRNGClass.html#a418a833cf18198fd7e5d6dbd78c99c29">RNG.rand()</a>. It is the caller's responsibility to ensure that the global random number pool has sufficient entropy to generate the 66 bytes of <em>f</em> safely before calling this function.</p>
|
|
<p>The following example demonstrates how to perform a full ECDH key exchange using <a class="el" href="classP521.html#ae04c439804f445535295bf44ae56afbf" title="Performs phase 1 of an ECDH key exchange using P-521. ">dh1()</a> and <a class="el" href="classP521.html#a7b9d4f74cc2d71a488a33ab165537491" title="Performs phase 2 of an ECDH key exchange using P-521. ">dh2()</a>:</p>
|
|
<div class="fragment"><div class="line">uint8_t f[66];</div>
|
|
<div class="line">uint8_t k[132];</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="comment">// Generate the secret value "f" and the public value "k".</span></div>
|
|
<div class="line"><a class="code" href="classP521.html#ae04c439804f445535295bf44ae56afbf">P521::dh1</a>(k, f);</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="comment">// Send "k" to the other party.</span></div>
|
|
<div class="line">...</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="comment">// Read the "k" value that the other party sent to us.</span></div>
|
|
<div class="line">...</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="comment">// Generate the shared secret in "f".</span></div>
|
|
<div class="line"><span class="keywordflow">if</span> (!<a class="code" href="classP521.html#a7b9d4f74cc2d71a488a33ab165537491">P521::dh2</a>(k, f)) {</div>
|
|
<div class="line"> <span class="comment">// The received "k" value was invalid - abort the session.</span></div>
|
|
<div class="line"> ...</div>
|
|
<div class="line">}</div>
|
|
<div class="line"></div>
|
|
<div class="line"><span class="comment">// The "f" value can now be used to generate session keys for encryption.</span></div>
|
|
<div class="line">...</div>
|
|
</div><!-- fragment --><p>Reference: <a href="http://tools.ietf.org/html/rfc6090">RFC 6090</a></p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classP521.html#a7b9d4f74cc2d71a488a33ab165537491" title="Performs phase 2 of an ECDH key exchange using P-521. ">dh2()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="P521_8cpp_source.html#l00208">208</a> of file <a class="el" href="P521_8cpp_source.html">P521.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="a7b9d4f74cc2d71a488a33ab165537491"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool P521::dh2 </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>k</em>[132], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>f</em>[66] </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>Performs phase 2 of an ECDH key exchange using P-521. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">k</td><td>The public key value that was received from the other party as part of the exchange. </td></tr>
|
|
<tr><td class="paramname">f</td><td>On entry, this is the secret value for this party that was generated by <a class="el" href="classP521.html#ae04c439804f445535295bf44ae56afbf" title="Performs phase 1 of an ECDH key exchange using P-521. ">dh1()</a>. On exit, this will be the shared secret.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>Returns true if the key exchange was successful, or false if the <em>k</em> value is invalid.</dd></dl>
|
|
<p>Reference: <a href="http://tools.ietf.org/html/rfc6090">RFC 6090</a></p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classP521.html#ae04c439804f445535295bf44ae56afbf" title="Performs phase 1 of an ECDH key exchange using P-521. ">dh1()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="P521_8cpp_source.html#l00229">229</a> of file <a class="el" href="P521_8cpp_source.html">P521.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ac2e07ce7e846ba180938b41b4a2ae563"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool P521::eval </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>result</em>[132], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>f</em>[66], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>point</em>[132] </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>Evaluates the curve function. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">result</td><td>The result of applying the curve function, which consists of the x and y values of the result point encoded in big-endian order. </td></tr>
|
|
<tr><td class="paramname">f</td><td>The scalar value to multiply by <em>point</em> to create the <em>result</em>. This is assumed to be be a 521-bit number in big-endian order. </td></tr>
|
|
<tr><td class="paramname">point</td><td>The curve point to multiply consisting of the x and y values encoded in big-endian order. If <em>point</em> is NULL, then the generator Gx and Gy values for the curve will be used instead.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>Returns true if <em>f</em> * <em>point</em> could be evaluated, or false if <em>point</em> is not a point on the curve.</dd></dl>
|
|
<p>This function provides access to the raw curve operation for testing purposes. Normally an application would use a higher-level function like <a class="el" href="classP521.html#ae04c439804f445535295bf44ae56afbf" title="Performs phase 1 of an ECDH key exchange using P-521. ">dh1()</a>, <a class="el" href="classP521.html#a7b9d4f74cc2d71a488a33ab165537491" title="Performs phase 2 of an ECDH key exchange using P-521. ">dh2()</a>, <a class="el" href="classP521.html#ab050ceff65e49b646b8157fe1474288a" title="Signs a message using a specific P-521 private key. ">sign()</a>, or <a class="el" href="classP521.html#ab075909f5cecbb801c6b7c41f20de223" title="Verifies a signature using a specific P-521 public key. ">verify()</a>.</p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classP521.html#ae04c439804f445535295bf44ae56afbf" title="Performs phase 1 of an ECDH key exchange using P-521. ">dh1()</a>, <a class="el" href="classP521.html#ab050ceff65e49b646b8157fe1474288a" title="Signs a message using a specific P-521 private key. ">sign()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="P521_8cpp_source.html#l00135">135</a> of file <a class="el" href="P521_8cpp_source.html">P521.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ae5b727018648e4a165f504024c4ccc45"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void P521::generatePrivateKey </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>privateKey</em>[66]</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>Generates a private key for P-521 signing operations. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">privateKey</td><td>The resulting private key.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>The private key is generated with <a class="el" href="classRNGClass.html#a418a833cf18198fd7e5d6dbd78c99c29">RNG.rand()</a>. It is the caller's responsibility to ensure that the global random number pool has sufficient entropy to generate the 521 bits of the key safely before calling this function.</p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classP521.html#a15ca802e298c7ff3be06924b0edb7daa" title="Derives the public key from a private key for P-521 signing operations. ">derivePublicKey()</a>, <a class="el" href="classP521.html#ab050ceff65e49b646b8157fe1474288a" title="Signs a message using a specific P-521 private key. ">sign()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="P521_8cpp_source.html#l00466">466</a> of file <a class="el" href="P521_8cpp_source.html">P521.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="a3f045e0b7a483fc557747472ade31298"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool P521::isValidCurvePoint </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>point</em>[132]</td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Validates a point to ensure that it is on the curve. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">point</td><td>The point to validate. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>Returns true if <em>point</em> is valid and on the curve, false if not.</dd></dl>
|
|
<p>This is a convenience function that calls <a class="el" href="classP521.html#af0bd7851bb15b737a821320b394aec96" title="Validates a public key to ensure that it is a valid curve point. ">isValidPublicKey()</a> as the two operations are equivalent. </p>
|
|
|
|
<p>Definition at line <a class="el" href="P521_8h_source.html#l00051">51</a> of file <a class="el" href="P521_8h_source.html">P521.h</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="a5802ebd25142789bb2df930ecd765d39"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool P521::isValidPrivateKey </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>privateKey</em>[66]</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>Validates a private key value to ensure that it is between 1 and q - 1. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">privateKey</td><td>The private key value to validate. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>Returns true if <em>privateKey</em> is valid, false if not.</dd></dl>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classP521.html#af0bd7851bb15b737a821320b394aec96" title="Validates a public key to ensure that it is a valid curve point. ">isValidPublicKey()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="P521_8cpp_source.html#l00524">524</a> of file <a class="el" href="P521_8cpp_source.html">P521.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="af0bd7851bb15b737a821320b394aec96"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool P521::isValidPublicKey </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>publicKey</em>[132]</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>Validates a public key to ensure that it is a valid curve point. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">publicKey</td><td>The public key value to validate. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>Returns true if <em>publicKey</em> is valid, false if not.</dd></dl>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classP521.html#a5802ebd25142789bb2df930ecd765d39" title="Validates a private key value to ensure that it is between 1 and q - 1. ">isValidPrivateKey()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="P521_8cpp_source.html#l00564">564</a> of file <a class="el" href="P521_8cpp_source.html">P521.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ab050ceff65e49b646b8157fe1474288a"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void P521::sign </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>signature</em>[132], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>privateKey</em>[66], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const void * </td>
|
|
<td class="paramname"><em>message</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t </td>
|
|
<td class="paramname"><em>len</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype"><a class="el" href="classHash.html">Hash</a> * </td>
|
|
<td class="paramname"><em>hash</em> = <code>0</code> </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>Signs a message using a specific P-521 private key. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">signature</td><td>The signature value. </td></tr>
|
|
<tr><td class="paramname">privateKey</td><td>The private key to use to sign the message. </td></tr>
|
|
<tr><td class="paramname">message</td><td>Points to the message to be signed. </td></tr>
|
|
<tr><td class="paramname">len</td><td>The length of the <em>message</em> to be signed. </td></tr>
|
|
<tr><td class="paramname">hash</td><td>The hash algorithm to use to hash the <em>message</em> before signing. If <em>hash</em> is NULL, then the <em>message</em> is assumed to already be a hash value from some previous process.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>This function generates deterministic ECDSA signatures according to RFC 6979. The <em>hash</em> function is used to generate the k value for the signature. If <em>hash</em> is NULL, then <a class="el" href="classSHA512.html" title="SHA-512 hash algorithm. ">SHA512</a> is used. The <em>hash</em> object must be capable of HMAC mode.</p>
|
|
<p>The length of the hashed message must be less than or equal to 64 bytes in size. Longer messages will be truncated to 64 bytes.</p>
|
|
<p>References: <a href="http://tools.ietf.org/html/rfc6090">RFC 6090</a>, <a href="http://tools.ietf.org/html/rfc6979">RFC 6979</a></p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classP521.html#ab075909f5cecbb801c6b7c41f20de223" title="Verifies a signature using a specific P-521 public key. ">verify()</a>, <a class="el" href="classP521.html#ae5b727018648e4a165f504024c4ccc45" title="Generates a private key for P-521 signing operations. ">generatePrivateKey()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="P521_8cpp_source.html#l00276">276</a> of file <a class="el" href="P521_8cpp_source.html">P521.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ab075909f5cecbb801c6b7c41f20de223"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool P521::verify </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>signature</em>[132], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>publicKey</em>[132], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const void * </td>
|
|
<td class="paramname"><em>message</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">size_t </td>
|
|
<td class="paramname"><em>len</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype"><a class="el" href="classHash.html">Hash</a> * </td>
|
|
<td class="paramname"><em>hash</em> = <code>0</code> </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>Verifies a signature using a specific P-521 public key. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">signature</td><td>The signature value to be verified. </td></tr>
|
|
<tr><td class="paramname">publicKey</td><td>The public key to use to verify the signature. </td></tr>
|
|
<tr><td class="paramname">message</td><td>The message whose signature is to be verified. </td></tr>
|
|
<tr><td class="paramname">len</td><td>The length of the <em>message</em> to be verified. </td></tr>
|
|
<tr><td class="paramname">hash</td><td>The hash algorithm to use to hash the <em>message</em> before verification. If <em>hash</em> is NULL, then the <em>message</em> is assumed to already be a hash value from some previous process.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>The length of the hashed message must be less than or equal to 64 bytes in size. Longer messages will be truncated to 64 bytes.</p>
|
|
<dl class="section return"><dt>Returns</dt><dd>Returns true if the <em>signature</em> is valid for <em>message</em>; or false if the <em>publicKey</em> or <em>signature</em> is not valid.</dd></dl>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classP521.html#ab050ceff65e49b646b8157fe1474288a" title="Signs a message using a specific P-521 private key. ">sign()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="P521_8cpp_source.html#l00373">373</a> of file <a class="el" href="P521_8cpp_source.html">P521.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<hr/>The documentation for this class was generated from the following files:<ul>
|
|
<li><a class="el" href="P521_8h_source.html">P521.h</a></li>
|
|
<li><a class="el" href="P521_8cpp_source.html">P521.cpp</a></li>
|
|
</ul>
|
|
</div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Sat Apr 7 2018 02:43:14 for ArduinoLibs by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.6
|
|
</small></address>
|
|
</body>
|
|
</html>
|