ArduinoLibs
|
Supported Algorithms
- Block ciphers: AES128, AES192, AES256, Speck
- Block cipher modes: CTR, CFB, CBC, OFB, GCM
- Stream ciphers: ChaCha
- Authenticated encryption with associated data (AEAD): ChaChaPoly, GCM
- Hash algorithms: SHA1, SHA256, SHA512, SHA3_256, SHA3_512, BLAKE2s, BLAKE2b (regular and HMAC modes)
- Message authenticators: Poly1305, GHASH
- Public key algorithms: Curve25519, Ed25519
- Random number generation: RNG, TransistorNoiseSource, RingOscillatorNoiseSource
All cryptographic algorithms have been optimized for 8-bit Arduino platforms like the Uno. Memory usage is also reduced, particularly for SHA1, SHA256, and SHA512 which save 256, 192, and 512 bytes respectively over traditional implementations. For all 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, and AES256 are provided for use in applications where compatibility with other systems is desirable.
If code size is an issue for your application (for example on very low end Arduino variants), then Speck on AVR is less than half the code size of ChaCha, at the cost of more data memory for the state and longer key setup times. The SpeckLowMemory class is even smaller at the cost of some performance when encrypting.
BLAKE2s and BLAKE2b are variations on the ChaCha stream cipher, designed for hashing, with 256-bit and 512-bit hash outputs respectively. They are intended as high performance replacements for SHA256 and SHA512 for when speed is critical but exact bit-compatibility of hash values is not.
Examples and other topics
Performance
Performance on AVR
All figures are for the Arduino Uno running at 16 MHz. Figures for the Ardunino Mega 2560 running at 16 MHz are similar:
Encryption Algorithm | Encryption (per byte) | Decryption (per byte) | Key Setup | State Size (bytes) |
AES128 (ECB mode) | 36.90us | 66.48us | 160.00us | 213 |
AES192 (ECB mode) | 44.20us | 80.35us | 166.54us | 245 |
AES256 (ECB mode) | 51.50us | 94.22us | 227.97us | 277 |
ChaCha (20 rounds) | 14.87us | 14.88us | 43.74us | 132 |
ChaCha (12 rounds) | 10.38us | 10.38us | 43.74us | 132 |
ChaCha (8 rounds) | 8.13us | 8.14us | 43.74us | 132 |
Speck (128-bit key, ECB mode) | 10.72us | 11.09us | 287.02us | 275 |
Speck (192-bit key, ECB mode) | 11.03us | 11.42us | 298.21us | 275 |
Speck (256-bit key, ECB mode) | 11.35us | 11.74us | 309.66us | 275 |
SpeckLowMemory (128-bit key, ECB mode) | 35.25us | 10.22us | 35 | |
SpeckLowMemory (192-bit key, ECB mode) | 36.56us | 13.62us | 35 | |
SpeckLowMemory (256-bit key, ECB mode) | 37.87us | 16.89us | 35 | |
AEAD Algorithm | Encryption (per byte) | Decryption (per byte) | Key Setup | State Size (bytes) |
ChaChaPoly | 41.23us | 41.23us | 902.55us | 255 |
GCM<AES128> | 186.47us | 186.42us | 1388.43us | 316 |
GCM<AES192> | 194.17us | 193.72us | 1628.67us | 348 |
GCM<AES256> | 201.47us | 201.02us | 1923.78us | 380 |
Hash Algorithm | Hashing (per byte) | Finalization | State Size (bytes) | |
SHA1 | 21.90us | 1423.28us | 95 | |
SHA256 | 43.85us | 2841.04us | 107 | |
SHA512 | 122.82us | 15953.42us | 211 | |
SHA3_256 | 121.69us | 16486.33us | 405 | |
SHA3_512 | 229.12us | 16502.34us | 405 | |
BLAKE2s | 18.54us | 1200.06us | 171 | |
BLAKE2b | 50.70us | 6515.87us | 339 | |
Authentication Algorithm | Hashing (per byte) | Finalization | Key Setup | State Size (bytes) |
SHA1 (HMAC mode) | 21.90us | 4296.33us | 1420.24us | 95 |
SHA256 (HMAC mode) | 43.85us | 8552.61us | 2836.49us | 107 |
BLAKE2s (HMAC mode) | 18.54us | 3649.98us | 1214.81us | 171 |
Poly1305 | 26.29us | 486.15us | 17.26us | 87 |
GHASH | 148.14us | 17.09us | 21.87us | 33 |
Public Key Operation | Time (per operation) | Comment | ||
Curve25519::eval() | 3119ms | Raw curve evaluation | ||
Curve25519::dh1() | 3121ms | First half of Diffie-Hellman key agreement | ||
Curve25519::dh2() | 3120ms | Second half of Diffie-Hellman key agreement | ||
Ed25519::sign() | 5688ms | Digital signature generation | ||
Ed25519::verify() | 9030ms | Digital signature verification | ||
Ed25519::derivePublicKey() | 5642ms | Derive a public key from a private key |
Where a cipher supports more than one key size (such as ChaCha), the values are typically almost identical for 128-bit and 256-bit keys so only the maximum is shown above.
Performance on ARM
All figures are for the Arduino Due running at 84 MHz:
Encryption Algorithm | Encryption (per byte) | Decryption (per byte) | Key Setup | State Size (bytes) |
AES128 (ECB mode) | 6.65us | 11.00us | 35.15us | 220 |
AES192 (ECB mode) | 8.02us | 13.31us | 36.59us | 252 |
AES256 (ECB mode) | 9.39us | 15.63 | 50.19us | 284 |
ChaCha (20 rounds) | 0.87us | 0.88us | 4.96us | 136 |
ChaCha (12 rounds) | 0.70us | 0.71us | 4.96us | 136 |
ChaCha (8 rounds) | 0.62us | 0.62us | 4.96us | 136 |
Speck (128-bit key, ECB mode) | 0.97us | 0.96us | 36.80us | 288 |
Speck (192-bit key, ECB mode) | 1.00us | 0.98us | 38.14us | 288 |
Speck (256-bit key, ECB mode) | 1.03us | 1.01us | 39.31us | 288 |
SpeckLowMemory (128-bit key, ECB mode) | 2.72us | 1.47us | 48 | |
SpeckLowMemory (192-bit key, ECB mode) | 2.81us | 1.54us | 48 | |
SpeckLowMemory (256-bit key, ECB mode) | 2.90us | 1.83us | 48 | |
AEAD Algorithm | Encryption (per byte) | Decryption (per byte) | Key Setup | State Size (bytes) |
ChaChaPoly | 1.66us | 1.66us | 45.02us | 280 |
GCM<AES128> | 11.01us | 10.92us | 247.90us | 344 |
GCM<AES192> | 12.40us | 12.31us | 294.07us | 376 |
GCM<AES256> | 13.73us | 13.64us | 347.40us | 408 |
Hash Algorithm | Hashing (per byte) | Finalization | State Size (bytes) | |
SHA1 | 0.94us | 62.55us | 112 | |
SHA256 | 1.15us | 76.60us | 120 | |
SHA512 | 2.87us | 370.37us | 224 | |
SHA3_256 | 5.36us | 697.65us | 424 | |
SHA3_512 | 9.89us | 697.81us | 424 | |
BLAKE2s | 0.76us | 50.88us | 184 | |
BLAKE2b | 1.33us | 170.93us | 352 | |
Authentication Algorithm | Hashing (per byte) | Finalization | Key Setup | State Size (bytes) |
SHA1 (HMAC mode) | 0.94us | 193.92us | 65.09us | 112 |
SHA256 (HMAC mode) | 1.15us | 238.98us | 80.44us | 120 |
BLAKE2s (HMAC mode) | 0.76us | 165.64us | 59.92us | 184 |
Poly1305 | 0.85us | 19.25us | 2.35us | 96 |
GHASH | 4.37us | 1.50us | 4.37us | 36 |
Public Key Operation | Time (per operation) | Comment | ||
Curve25519::eval() | 103ms | Raw curve evaluation | ||
Curve25519::dh1() | 103ms | First half of Diffie-Hellman key agreement | ||
Curve25519::dh2() | 104ms | Second half of Diffie-Hellman key agreement | ||
Ed25519::sign() | 195ms | Digital signature generation | ||
Ed25519::verify() | 306ms | Digital signature verification | ||
Ed25519::derivePublicKey() | 194ms | Derive a public key from a private key |
Generated on Fri Dec 18 2015 05:39:07 for ArduinoLibs by 1.8.6