mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
111 lines
8.7 KiB
HTML
111 lines
8.7 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: Using the cryptography library with ESP8266</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 class="current"><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><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>
|
|
<!-- 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="headertitle">
|
|
<div class="title">Using the cryptography library with ESP8266 </div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="textblock"><p>This library has been tested with ESP8266-based Arduino devices. Some people have had problems with earlier versions of the library, some of which have been fixed in the library and some of which need to be dealt with in the calling application.</p>
|
|
<p>This page describes the common problems that have been encountered and some suggested work arounds.</p>
|
|
<h1><a class="anchor" id="crypto_esp_progmem"></a>
|
|
Program memory</h1>
|
|
<p>Earlier versions of the Arduino toolchain for ESP8266 had issues with program memory accesses. This example is from the <a class="el" href="classCurve25519.html" title="Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19. ">Curve25519</a> code:</p>
|
|
<div class="fragment"><div class="line">uint8_t check = (pgm_read_byte(point + 31) ^ k[31]) & 0x7F;</div>
|
|
</div><!-- fragment --><p>This would cause crashes. Rewriting the code as follows would help:</p>
|
|
<div class="fragment"><div class="line">uint8_t check = (pgm_read_byte(&(point[31])) ^ k[31]) & 0x7F;</div>
|
|
</div><!-- fragment --><p>Note how a pointer operation (<code>point + 31</code>) was changed into an array operation (<code>&(point[31])</code>). Logically these two should be equivalent but earlier compilers somehow compiled the pointer-using code incorrectly.</p>
|
|
<p>This problem appears to have been fixed in more recent versions of the compiler so the first thing to try is to update your toolchain. Otherwise you may need to change more program memory accesses to get the library to work. Merge requests welcome.</p>
|
|
<h1><a class="anchor" id="crypto_esp_watchdog"></a>
|
|
Watchdog</h1>
|
|
<p>The most common reason why the cryptography code "fails" on ESP8266 is because of the system watchdog. By default the software watchdog on the ESP8266 will fire off after about 3 seconds and the hardware watchdog will fire off after about 8 seconds if the software watchdog was disabled.</p>
|
|
<p>Some of the example programs in the cryptography library can take a long time to run through all the tests, which makes watchdog failure very likely. User application code can have the same problem.</p>
|
|
<p>If you see the message <code>"Soft WDT reset"</code> then this is probably the cause. However disabling the software watchdog with either <code>wdt_disable()</code> or <code>ESP.wdtDisable()</code> will only shift the problem to later when the hardware watchdog fires off.</p>
|
|
<p>The macro crypto_feed_watchdog() in <a class="el" href="Crypto_8h_source.html">Crypto.h</a> has been added to the library. If you call it at regular intervals and before or after cryptography operations then it should reduce the watchdog reset problem. It is safe to use this macro on non-ESP8266 platforms where it will define away to nothing.</p>
|
|
<p>The example programs have been modified to feed the watchdog regularly during the testing process. And long-running public key functions in classes like <a class="el" href="classCurve25519.html" title="Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19. ">Curve25519</a> and <a class="el" href="classP521.html" title="Elliptic curve operations with the NIST P-521 curve. ">P521</a> will feed the watchdog while the curves are being evaluated. But you still may need to call crypto_feed_watchdog() from your own code to keep the watchdog happy.</p>
|
|
<h1><a class="anchor" id="crypto_esp_stack"></a>
|
|
Stack space</h1>
|
|
<p>Another problem occurred in the <a class="el" href="classNewHope.html" title="NewHope post-quantum key exchange algorithm. ">NewHope</a> implementation due to lack of stack space. <a class="el" href="classNewHope.html" title="NewHope post-quantum key exchange algorithm. ">NewHope</a> was putting so much data on the stack that it caused a stack overflow and an exception. <a class="el" href="classNewHope.html" title="NewHope post-quantum key exchange algorithm. ">NewHope</a> has been modified to move the state to the heap on ESP8266 to get it off the stack.</p>
|
|
<p>It is possible that your own application may have similar issues if you are allocating cryptographic objects on the stack. Recommend that you move data into global data space or to the heap to work around this problem. </p>
|
|
</div></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>
|