title: Speed difference between AES/CBC encryption and decryption?
body: <p>I am wondering, theoretically, how much slower would AES/CBC decryption be compared to AES/CBC encryption with the following conditions:</p>
  
  <ul>
  <li>Encryption key of 32 bytes (256 bits); </li>
  <li>A blocksize of 16 bytes (128 bits).</li>
  </ul>
  
  <p>The reason that I ask is that I want to know if the decryption speed of an implementation that I have is not abnormally slow. I have done some tests on random memory blocks of different sizes. The results are as follows:</p>
  
  <p><em>64B:</em></p>
  
  <p><img src="https://i.stack.imgur.com/eq8Nh.png" alt="enter image description here"></p>
  
  <p><em>64KB:</em></p>
  
  <p><img src="https://i.stack.imgur.com/fzZL2.png" alt="enter image description here"></p>
  
  <p><em>10MB – 520MB:</em></p>
  
  <p><img src="https://i.stack.imgur.com/7Tuh3.png" alt="enter image description here"></p>
  
  <p>All data was stored on the internal memory of my system. The application generates the data to encrypt by itself. Virtual memory is disabled on the test PC so that there would not be any I/O calls. </p>
  
  <p>When analyzing the table, does the difference between encryption and decryption imply that my implementation is abnormally slow? Have I done something wrong?</p>
  
  <p><strong>Update:</strong></p>
  
  <ul>
  <li>This test is executed on another pc;</li>
  <li>This test is executed with random data;</li>
  <li>Crypto++ is used for the AES/CBC encryption and decryption.</li>
  </ul>
  
  <p>The decryption implementation is as follows:</p>
  
  <pre><code>CryptoPP::AES::Decryption aesDecryption(aesKey, ENCRYPTION_KEY_SIZE_AES);
  CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, aesIv);
  
  CryptoPP::ArraySink * decSink = new CryptoPP::ArraySink(data, dataSizeMax);
  CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, decSink);
  stfDecryptor.Put(reinterpret_cast&lt;const unsigned char*&gt;(ciphertext), cipherSize);
  stfDecryptor.MessageEnd();
  
  *dataOutputSize = decSink-&gt;TotalPutLength(); 
  </code></pre>
  
  <p><strong>Update 2:</strong></p>
  
  <ul>
  <li>Added result for 64 byte blocks</li>
  </ul>