AES / CBC加密和解密之间的速度差异? [英] Speed difference between AES/CBC encryption and decryption?

查看:1356
本文介绍了AES / CBC加密和解密之间的速度差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,理论上AES / CBC解密比AES / CBC加密要慢些以下条件:




  • 32字节(256位)的加密密钥;

  • 16字节(128位)的块大小。



我想知道我的一个实现的解密速度是不是异常慢。我已经对不同大小的随机存储器块进行了一些测试。结果如下:



64B:





64KB: / p>



10MB - 520MB:





所有数据都存储在系统的内部存储器中。应用程序自动生成要加密的数据。虚拟内存在测试PC上被禁用,因此不会有任何I / O调用。



在分析表格时,加密和解密之间的区别是否意味着我的实现异常缓慢?我做错了吗?



更新:




  • 这个测试在另一个pc上执行;

  • 这个测试用随机数据执行;

  • 加密++用于AES / CBC加密,解密。



解密实现如下:

  CryptoPP :: AES ::解密aesDecryption(aesKey,ENCRYPTION_KEY_SIZE_AES); 
CryptoPP :: CBC_Mode_ExternalCipher ::解密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字节块添加结果


解决方案

理论上AES解密速度提高了30%。这是Rijndael系统的财产。



资料来源: http://www4.ncsu.edu/~hartwig/Teaching/437/aes.pdf


I am wondering, theoretically, how much slower would AES/CBC decryption be compared to AES/CBC encryption with the following conditions:

  • Encryption key of 32 bytes (256 bits);
  • A blocksize of 16 bytes (128 bits).

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:

64B:

64KB:

10MB – 520MB:

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.

When analyzing the table, does the difference between encryption and decryption imply that my implementation is abnormally slow? Have I done something wrong?

Update:

  • This test is executed on another pc;
  • This test is executed with random data;
  • Crypto++ is used for the AES/CBC encryption and decryption.

The decryption implementation is as follows:

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(); 

Update 2:

  • Added result for 64 byte blocks

解决方案

Theoretically, AES decryption is 30% slower. This is a property of Rijndael systems in general.

Source: http://www4.ncsu.edu/~hartwig/Teaching/437/aes.pdf

这篇关于AES / CBC加密和解密之间的速度差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆