ArduinoLibs
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Cryptographic Library

Supported Algorithms

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.

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.

Performance

All figures are for the Arduino Uno running at 16 MHz. Figures for the Ardunino Mega 2560 running at 16 MHz are similar:

AlgorithmEncryption / Hashing (per byte)Decryption (per byte)Key SetupState Size (bytes)
AES128 (ECB mode)36.90us66.48us160.00us208
AES192 (ECB mode)44.20us80.35us166.54us240
AES256 (ECB mode)51.50us94.22us227.97us272
ChaCha (20 rounds)14.87us14.88us43.74us130
ChaCha (12 rounds)10.38us10.38us43.74us130
ChaCha (8 rounds)8.13us8.14us43.74us130
SHA121.90us93
SHA25643.85us105
SHA512123.24us209
SHA3_256121.69us403
SHA3_512229.12us403
BLAKE2s18.54us169
BLAKE2b50.58us337

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.

Public key algorithms have the following results on an Arduino Uno:

AlgorithmOperationTimeComment
Curve25519eval()3738 msRaw curve evaluation
Curve25519dh1()3740 msFirst half of Diffie-Hellman key agreement
Curve25519dh2()3738 msSecond half of Diffie-Hellman key agreement