Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I am trying to find how much time an AES encryption and decryption takes for a given amount of data and key. In all the cases encryption takes way lesser processing time than decryption. I tried to get this answer somewhere else but can't find. May I know why does decryption takes a lot more time than encryption for AES 128/256 bit?

I am trying to implement a simple AES encryption in Arduino UNO. I use micros() to measure the time it takes to encrypt or decrypt.

Here is what I did for encryption:

Serial.print("Encrypted: ");
unsigned long start1 = micros();
String enc = aes_encrypt("this is data source","this is key");
unsigned long start2 = micros();
unsigned long diff1 = start2 - start1;
Serial.print("Time to encrypt the data: ");
Serial.println(" microseconds");
share|improve this question
This is going to depend extremely highly on your implementation, choice of mode, etc. There is not enough information in the question to provide an answer. –  Stephen Touset Mar 13 '14 at 20:39
Thanks @StephenTouset, tried to add some more info if it helps. –  Bee Mar 13 '14 at 21:07
The edit doesn't seem to actually provide any information about the actual library or the encryption mode you're using. –  Stephen Touset Mar 13 '14 at 21:13
Can you include a link to the library you're using? –  CodesInChaos Feb 11 at 21:18
I'm voting to close this question as off-topic because it's really a question about a specific AES implementation, not AES in general –  poncho Feb 18 at 14:57

1 Answer 1

As the commenters have said, it is impossible to answer without many more details about your particular implementation, but here is some background on Rijndael (pronounced 'rain-doll') that might help. Rijndael is the family of ciphers on which AES is based. AES is defined as Rijndael[1] with a block size of 128 bits and key lengths of 128, 192 and 256 bits.

Back in 1999, when the winner of the AES had not been chosen yet, Bruce Schneier published a paper[2] on performance of the proposed ciphers. The Pentium Pro CPU was a high end processor back then. On page seven of his report he states:

Rijndael is another variant of Square: a fast cipher that works very well across all platforms. It boasts a clean mathematical structure involving only table lookup and XOR operations. Although the encryption and decryption algorithms are not exactly identical, their general structure and performance are virtually indistinguishable.

Rijndael’s assembly language on both the Pentium and Pentium Pro processors is about 300 clocks per block. Unlike RC6 and Mars, there are no known CPU platforms (8-bit or 32-bit) on which Rijndael’s relative performance would be unduly negatively affected or on which timing attacks would be possible.

According to this, one of the algorithm's advantages is its resistance to timing attacks. This would definitely have been a factor in the decision to select Rijndael as the current AES.

Later, though, discussing performance on 8-bit smart cards, which I read as computing platforms with very restricted resources, he says about Rijndael:

Perhaps the only negative comment about Rijndael on smart cards is that the performance numbers in the paper do not include a decryption function. Including decryption would increase the code size somewhat (probably between 512 and 1024 bytes), and decryption speed would be slower (possibly twice as slow) than encryption speed due to the coefficients of the inverse MDS matrix.

Again, without details about your implementation, it is impossible to know what the cause of the discrepancy is. There is strong evidence pointing to the fact that encryption and decryption for a given key should take about the same time, but the Arduino UNO has an 8-bit RISC processor and even though it has 2K of memory, it can only consume it 8 bits at a time. You could be experiencing the same theoretical problem Schneier described.

[1] https://en.wikipedia.org/wiki/Advanced_Encryption_Standard - Check the section called Description of the cipher.

[2] https://www.schneier.com/paper-aes-performance.pdf

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.