Speed ​​difference between AES / CBC encryption and decryption?

I'm wondering, theoretically, how much slower it will be to decrypt AES / CBC decryption with AES / CBC encryption with the following conditions:

  • Encryption key 32 bytes (256 bits);
  • Lock by 16 bytes (128 bits).

The reason I'm asking is because I want to know if the decryption speed of the implementation that I have is not abnormally slow. I conducted several tests on random memory blocks of different sizes. The results are as follows:

64B:

enter image description here

64Kb:

enter image description here

10 MB - 520 MB:

enter image description here

All data was stored in the internal memory of my system. The application generates data for encryption on its own. Virtual memory is disabled on the test PC so that there are no I / O calls.

, ? - ?

Update:

  • ;
  • ;
  • Crypto ++ AES/CBC.

:

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<const unsigned char*>(ciphertext), cipherSize);
stfDecryptor.MessageEnd();

*dataOutputSize = decSink->TotalPutLength(); 

2:

  • 64 .
+4
3

, . , , , . AES , CBC , . , :

enter image description here

+2

, ? - ?

. @JamesKPolk - . -, CTR, CBC. . SUPERCOP. (cpb) . "9 /" .

-, . , 9 / 6,5 / . iCore-, Core-i5, 2,7 , CBC 2,5 3,0 cpb, 980 / 1 /. Core2 Duo, 2.0 , , . Core 2 14,5 cpb 130 /.

-, . , ; . , , ArraySource StreamTransformationFilter. , AES . , ProcessBlock ProcessString.

CryptoPP::AES::Decryption aesDecryption(aesKey, ENCRYPTION_KEY_SIZE_AES);
CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, aesIv);
...

-, Crypto ++ Benchmarks . , . , .

AutoSeededRandomPool prng;
SecByteBlock key(16);
prng.GenerateBlock(key, key.size());

CTR_Mode<AES>::Encryption cipher;
cipher.SetKeyWithIV(key, key.size(), key);

const int BUF_SIZE = RoundUpToMultipleOf(2048U,
    dynamic_cast<StreamTransformation&>(cipher).OptimalBlockSize());

AlignedSecByteBlock buf(BUF_SIZE);
prng.GenerateBlock(buf, buf.size());

const double runTimeInSeconds = 3.0;
const double cpuFreq = 2.7 * 1000 * 1000 * 1000;
double elapsedTimeInSeconds;
unsigned long i=0, blocks=1;

ThreadUserTimer timer;
timer.StartTimer();

do
{
    blocks *= 2;
    for (; i<blocks; i++)
        cipher.ProcessString(buf, BUF_SIZE);
    elapsedTimeInSeconds = timer.ElapsedTimeAsDouble();
}
while (elapsedTimeInSeconds < runTimeInSeconds);

const double bytes = static_cast<double>(BUF_SIZE) * blocks;
const double ghz = cpuFreq / 1000 / 1000 / 1000;
const double mbs = bytes / 1024 / 1024 / elapsedTimeInSeconds;
const double cpb = elapsedTimeInSeconds * cpuFreq / bytes;

std::cout << cipher.AlgorithmName() << " benchmarks..." << std::endl;
std::cout << "  " << ghz << " GHz cpu frequency"  << std::endl;
std::cout << "  " << cpb << " cycles per byte (cpb)" << std::endl;
std::cout << "  " << mbs << " MiB per second (MiB)" << std::endl;

Core-i5 6400 2,7 :

$ ./bench.exe
AES/CTR benchmarks...
  2.7 GHz cpu frequency
  0.58228 cycles per byte (cpb)
  4422.13 MiB per second (MiB)

-, 64- :

const int BUF_SIZE = 64;
unsigned int blocks = 0;
...

do
{
    blocks++;
    cipher.ProcessString(buf, BUF_SIZE);
    elapsedTimeInSeconds = timer.ElapsedTimeAsDouble();
}
while (elapsedTimeInSeconds < runTimeInSeconds);

3,4 cpb 760 / Core-i5 6400 2,7 64- . , (?) .

$ ./bench.exe
AES/CTR benchmarks...
  2.7 GHz cpu frequency
  3.39823 cycles per byte (cpb)
  757.723 MiB per second (MiB)

-, / . governor.sh, Linux. TestScript/.

-, CTR :

CTR_Mode<AES>::Decryption cipher;
cipher.SetKeyWithIV(key, key.size(), key);

​​ :

$ ./bench.exe
AES/CTR benchmarks...
  2.7 GHz cpu frequency
  0.579923 cycles per byte (cpb)
  4440.11 MiB per second (MiB)

Eigth, . .

Beaglebone, 980 , , . Beaglebone 40 cpb 20 MB/s, C/++; A-32.


:

  • CTR .
  • CTR , .
  • , .

, .

, - , Crypto ++, .

+1

All Articles