mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
72 lines
3.7 KiB
Plaintext
72 lines
3.7 KiB
Plaintext
/*
|
|
* Copyright (C) 2015 Southern Storm Software, Pty Ltd.
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included
|
|
* in all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
\file crypto.dox
|
|
\page crypto Cryptographic Library
|
|
|
|
\section crypto_algorithms Supported Algorithms
|
|
|
|
\li Block ciphers: AES128, AES192, AES256
|
|
\li Block cipher modes: CTR, CFB, CBC, OFB
|
|
\li Stream ciphers: ChaCha, Arcfour
|
|
\li Hash algorithms: SHA1, SHA256
|
|
|
|
All cryptographic algorithms have been optimized for 8-bit Arduino platforms
|
|
like the Uno. Memory usage is also reduced, particularly for SHA1 and SHA256
|
|
which save 256 and 192 bytes respectively over traditional implementations.
|
|
For other algorithms, static sbox tables and the like are placed into
|
|
program memory to further reduce data memory usage.
|
|
|
|
ChaCha with 20 rounds and 256-bit keys is the recommended
|
|
symmetric encryption algorithm because it is twice as fast as AES128,
|
|
constant-time, and much more secure. AES128, AES192, AES256, and Arcfour
|
|
are provided for use in applications where compatibility with other systems
|
|
is desirable.
|
|
|
|
\section crypto_examples Examples
|
|
|
|
TBD
|
|
|
|
\section crypto_performance Performance
|
|
|
|
All figures are for the Arduino Uno running at 16 MHz:
|
|
|
|
<table>
|
|
<tr><td>Algorithm</td><td>Encryption / Hashing (per byte)</td><td>Decryption (per byte)</td><td>Key Setup</td><td>State Size (bytes)</td></tr>
|
|
<tr><td>AES128 (ECB mode)</td><td align="right">36.90us</td><td align="right">66.48us</td><td align="right">160.00us</td><td align="right">208</td></tr>
|
|
<tr><td>AES192 (ECB mode)</td><td align="right">44.20us</td><td align="right">80.35us</td><td align="right">166.54us</td><td align="right">240</td></tr>
|
|
<tr><td>AES256 (ECB mode)</td><td align="right">51.50us</td><td align="right">94.22us</td><td align="right">227.97us</td><td align="right">272</td></tr>
|
|
<tr><td>Arcfour</td><td align="right">2.98us</td><td align="right">2.98us</td><td align="right">601.34us</td><td align="right">258</td></tr>
|
|
<tr><td>ChaCha (20 rounds)</td><td align="right">14.87us</td><td align="right">14.88us</td><td align="right">43.74us</td><td align="right">130</td></tr>
|
|
<tr><td>ChaCha (12 rounds)</td><td align="right">10.38us</td><td align="right">10.38us</td><td align="right">43.74us</td><td align="right">130</td></tr>
|
|
<tr><td>ChaCha (8 rounds)</td><td align="right">8.13us</td><td align="right">8.14us</td><td align="right">43.74us</td><td align="right">130</td></tr>
|
|
<tr><td>SHA1</td><td align="right">21.90us</td><td> </td><td align="right"> </td><td align="right">94</td></tr>
|
|
<tr><td>SHA256</td><td align="right">43.85us</td><td> </td><td align="right"> </td><td align="right">106</td></tr>
|
|
</table>
|
|
|
|
Where a cipher supports more than one key size (such as ChaCha and Arcfour),
|
|
the values are typically almost identical for 128-bit and 256-bit keys so only
|
|
the maximum is shown above.
|
|
|
|
*/
|