From c0470980ded9ba4e95b679fd0a670e1bbb452a21 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Sun, 19 Apr 2015 15:26:27 +1000 Subject: [PATCH] Crypto performance figures for Arduino Due --- doc/crypto.dox | 45 ++++++++++++++++++++++++++++++++ libraries/Crypto/BigNumberUtil.h | 7 +++++ 2 files changed, 52 insertions(+) diff --git a/doc/crypto.dox b/doc/crypto.dox index 2aef5ed6..bd71e448 100644 --- a/doc/crypto.dox +++ b/doc/crypto.dox @@ -58,6 +58,8 @@ speed is critical but exact bit-compatibility of hash values is not. \section crypto_performance Performance +\subsection crypto_performance_avr 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: @@ -105,4 +107,47 @@ 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. +\subsection crypto_performance_arm Performance on ARM + +All figures are for the Arduino Due running at 84 MHz: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Encryption AlgorithmEncryption (per byte)Decryption (per byte)Key SetupState Size (bytes)
AES128 (ECB mode)6.65us11.00us35.15us220
AES192 (ECB mode)8.02us13.31us36.59us252
AES256 (ECB mode)9.39us15.6350.19us284
ChaCha (20 rounds)0.87us0.88us4.96us136
ChaCha (12 rounds)0.70us0.71us4.96us136
ChaCha (8 rounds)0.62us0.62us4.96us136
AEAD AlgorithmEncryption (per byte)Decryption (per byte)Key SetupState Size (bytes)
ChaChaPoly1.66us1.66us45.02us280
GCM<AES128>11.01us10.92us247.90us344
GCM<AES192>12.40us12.31us294.07us376
GCM<AES256>13.73us13.64us347.40us408
Hash AlgorithmHashing (per byte)Finalization State Size (bytes)
SHA10.94us62.55us 112
SHA2561.15us76.60us 120
SHA5122.87us370.37us 224
SHA3_2565.36us697.65us 424
SHA3_5129.89us697.81us 424
BLAKE2s0.76us50.88us 184
BLAKE2b1.33us170.93us 352
Authentication AlgorithmHashing (per byte)FinalizationKey SetupState Size (bytes)
SHA1 (HMAC mode)0.94us193.92us65.09us112
SHA256 (HMAC mode)1.15us238.98us80.44us120
BLAKE2s (HMAC mode)0.76us165.64us59.92us184
Poly13050.85us19.25us2.35us96
GHASH4.37us1.50us4.37us36
Public Key OperationTime (per operation)Comment
Curve25519::eval()103msRaw curve evaluation
Curve25519::dh1()103msFirst half of Diffie-Hellman key agreement
Curve25519::dh2()104msSecond half of Diffie-Hellman key agreement
Ed25519::sign()195msDigital signature generation
Ed25519::verify()306msDigital signature verification
Ed25519::derivePublicKey()194msDerive a public key from a private key
*/ diff --git a/libraries/Crypto/BigNumberUtil.h b/libraries/Crypto/BigNumberUtil.h index 286ebd81..83f6d63f 100644 --- a/libraries/Crypto/BigNumberUtil.h +++ b/libraries/Crypto/BigNumberUtil.h @@ -28,9 +28,16 @@ // Define exactly one of these to 1 to set the size of the basic limb type. // 16-bit limbs seem to give the best performance on 8-bit AVR micros. +#if defined(__AVR__) #define BIGNUMBER_LIMB_8BIT 0 #define BIGNUMBER_LIMB_16BIT 1 #define BIGNUMBER_LIMB_32BIT 0 +#else +// On all other platforms, assume 32-bit is best (e.g. ARM). +#define BIGNUMBER_LIMB_8BIT 0 +#define BIGNUMBER_LIMB_16BIT 0 +#define BIGNUMBER_LIMB_32BIT 1 +#endif // Define the limb types to use on this platform. #if BIGNUMBER_LIMB_8BIT