mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
311 lines
19 KiB
HTML
311 lines
19 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: Curve25519 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 Page</span></a></li>
|
|
<li><a href="pages.html"><span>Related 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 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>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><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="#friends">Friends</a> |
|
|
<a href="classCurve25519-members.html">List of all members</a> </div>
|
|
<div class="headertitle">
|
|
<div class="title">Curve25519 Class Reference</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19.
|
|
<a href="classCurve25519.html#details">More...</a></p>
|
|
|
|
<p><code>#include <<a class="el" href="Curve25519_8h_source.html">Curve25519.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:a2e4b7dd83a019b32c76584c99bfda21a"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classCurve25519.html#a2e4b7dd83a019b32c76584c99bfda21a">eval</a> (uint8_t result[32], const uint8_t s[32], const uint8_t x[32])</td></tr>
|
|
<tr class="memdesc:a2e4b7dd83a019b32c76584c99bfda21a"><td class="mdescLeft"> </td><td class="mdescRight">Evaluates the raw <a class="el" href="classCurve25519.html" title="Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19. ">Curve25519</a> function. <a href="#a2e4b7dd83a019b32c76584c99bfda21a">More...</a><br/></td></tr>
|
|
<tr class="separator:a2e4b7dd83a019b32c76584c99bfda21a"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a2b6911583d17ea9a36bbbb40d58b3d89"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="classCurve25519.html#a2b6911583d17ea9a36bbbb40d58b3d89">dh1</a> (uint8_t k[32], uint8_t f[32])</td></tr>
|
|
<tr class="memdesc:a2b6911583d17ea9a36bbbb40d58b3d89"><td class="mdescLeft"> </td><td class="mdescRight">Performs phase 1 of a Diffie-Hellman key exchange using <a class="el" href="classCurve25519.html" title="Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19. ">Curve25519</a>. <a href="#a2b6911583d17ea9a36bbbb40d58b3d89">More...</a><br/></td></tr>
|
|
<tr class="separator:a2b6911583d17ea9a36bbbb40d58b3d89"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a14022d6ac68ec691ffb0247275078ab9"><td class="memItemLeft" align="right" valign="top">static bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classCurve25519.html#a14022d6ac68ec691ffb0247275078ab9">dh2</a> (uint8_t k[32], uint8_t f[32])</td></tr>
|
|
<tr class="memdesc:a14022d6ac68ec691ffb0247275078ab9"><td class="mdescLeft"> </td><td class="mdescRight">Performs phase 2 of a Diffie-Hellman key exchange using <a class="el" href="classCurve25519.html" title="Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19. ">Curve25519</a>. <a href="#a14022d6ac68ec691ffb0247275078ab9">More...</a><br/></td></tr>
|
|
<tr class="separator:a14022d6ac68ec691ffb0247275078ab9"><td class="memSeparator" colspan="2"> </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:ad0bf073aaa9d8f4d0ad84003096d7990"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ad0bf073aaa9d8f4d0ad84003096d7990"></a>
|
|
class </td><td class="memItemRight" valign="bottom"><b>Ed25519</b></td></tr>
|
|
<tr class="separator:ad0bf073aaa9d8f4d0ad84003096d7990"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><p>Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19. </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 1k of free stack space is recommended for safety.</dd></dl>
|
|
<p>References: <a href="http://cr.yp.to/ecdh.html,">http://cr.yp.to/ecdh.html,</a> <a href="http://tools.ietf.org/html/rfc7748">RFC 7748</a></p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classEd25519.html" title="Digital signatures based on the elliptic curve modulo 2^255 - 19. ">Ed25519</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="Curve25519_8h_source.html#l00030">30</a> of file <a class="el" href="Curve25519_8h_source.html">Curve25519.h</a>.</p>
|
|
</div><h2 class="groupheader">Member Function Documentation</h2>
|
|
<a class="anchor" id="a2b6911583d17ea9a36bbbb40d58b3d89"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void Curve25519::dh1 </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>k</em>[32], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>f</em>[32] </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 a Diffie-Hellman key exchange using <a class="el" href="classCurve25519.html" title="Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19. ">Curve25519</a>. </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="classCurve25519.html#a14022d6ac68ec691ffb0247275078ab9" title="Performs phase 2 of a Diffie-Hellman key exchange using Curve25519. ">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 32 bytes of <em>f</em> safely before calling this function.</p>
|
|
<p>The following example demonstrates how to perform a full Diffie-Hellman key exchange using <a class="el" href="classCurve25519.html#a2b6911583d17ea9a36bbbb40d58b3d89" title="Performs phase 1 of a Diffie-Hellman key exchange using Curve25519. ">dh1()</a> and <a class="el" href="classCurve25519.html#a14022d6ac68ec691ffb0247275078ab9" title="Performs phase 2 of a Diffie-Hellman key exchange using Curve25519. ">dh2()</a>:</p>
|
|
<div class="fragment"><div class="line">uint8_t f[32];</div>
|
|
<div class="line">uint8_t k[32];</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="classCurve25519.html#a2b6911583d17ea9a36bbbb40d58b3d89">Curve25519::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 "k" using the previous secret value "f".</span></div>
|
|
<div class="line"><span class="keywordflow">if</span> (!<a class="code" href="classCurve25519.html#a14022d6ac68ec691ffb0247275078ab9">Curve25519::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 "k" 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/rfc7748">RFC 7748</a></p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classCurve25519.html#a14022d6ac68ec691ffb0247275078ab9" title="Performs phase 2 of a Diffie-Hellman key exchange using Curve25519. ">dh2()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="Curve25519_8cpp_source.html#l00245">245</a> of file <a class="el" href="Curve25519_8cpp_source.html">Curve25519.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="a14022d6ac68ec691ffb0247275078ab9"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool Curve25519::dh2 </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>k</em>[32], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>f</em>[32] </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 a Diffie-Hellman key exchange using <a class="el" href="classCurve25519.html" title="Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19. ">Curve25519</a>. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">k</td><td>On entry, this is the key value that was received from the other party as part of the exchange. On exit, this will be the shared secret. </td></tr>
|
|
<tr><td class="paramname">f</td><td>The secret value for this party that was generated by <a class="el" href="classCurve25519.html#a2b6911583d17ea9a36bbbb40d58b3d89" title="Performs phase 1 of a Diffie-Hellman key exchange using Curve25519. ">dh1()</a>. The <em>f</em> value will be destroyed by this function.</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/rfc7748">RFC 7748</a></p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classCurve25519.html#a2b6911583d17ea9a36bbbb40d58b3d89" title="Performs phase 1 of a Diffie-Hellman key exchange using Curve25519. ">dh1()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="Curve25519_8cpp_source.html#l00283">283</a> of file <a class="el" href="Curve25519_8cpp_source.html">Curve25519.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="a2e4b7dd83a019b32c76584c99bfda21a"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">bool Curve25519::eval </td>
|
|
<td>(</td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>result</em>[32], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>s</em>[32], </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const uint8_t </td>
|
|
<td class="paramname"><em>x</em>[32] </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 raw <a class="el" href="classCurve25519.html" title="Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19. ">Curve25519</a> function. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">result</td><td>The result of evaluating the curve function. </td></tr>
|
|
<tr><td class="paramname">s</td><td>The S parameter to the curve function. </td></tr>
|
|
<tr><td class="paramname">x</td><td>The X(Q) parameter to the curve function. If this pointer is NULL then the value 9 is used for <em>x</em>.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<p>This function is provided to assist with implementating other algorithms with the curve. Normally applications should use <a class="el" href="classCurve25519.html#a2b6911583d17ea9a36bbbb40d58b3d89" title="Performs phase 1 of a Diffie-Hellman key exchange using Curve25519. ">dh1()</a> and <a class="el" href="classCurve25519.html#a14022d6ac68ec691ffb0247275078ab9" title="Performs phase 2 of a Diffie-Hellman key exchange using Curve25519. ">dh2()</a> directly instead.</p>
|
|
<dl class="section return"><dt>Returns</dt><dd>Returns true if the function was evaluated; false if <em>x</em> is not a proper member of the field modulo (2^255 - 19).</dd></dl>
|
|
<p>Reference: <a href="http://tools.ietf.org/html/rfc7748">RFC 7748</a></p>
|
|
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="classCurve25519.html#a2b6911583d17ea9a36bbbb40d58b3d89" title="Performs phase 1 of a Diffie-Hellman key exchange using Curve25519. ">dh1()</a>, <a class="el" href="classCurve25519.html#a14022d6ac68ec691ffb0247275078ab9" title="Performs phase 2 of a Diffie-Hellman key exchange using Curve25519. ">dh2()</a> </dd></dl>
|
|
|
|
<p>Definition at line <a class="el" href="Curve25519_8cpp_source.html#l00080">80</a> of file <a class="el" href="Curve25519_8cpp_source.html">Curve25519.cpp</a>.</p>
|
|
|
|
</div>
|
|
</div>
|
|
<hr/>The documentation for this class was generated from the following files:<ul>
|
|
<li><a class="el" href="Curve25519_8h_source.html">Curve25519.h</a></li>
|
|
<li><a class="el" href="Curve25519_8cpp_source.html">Curve25519.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  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.6
|
|
</small></address>
|
|
</body>
|
|
</html>
|