开发者

AES encryption with BouncyCastle: AESEngine, AESFastEngine OR AESLightEngine?

开发者 https://www.devze.com 2023-04-02 10:25 出处:网络
I want to port this simple JAVA example... AES Encryption/Decryption with Bouncycastle Example in J2ME

I want to port this simple JAVA example...

AES Encryption/Decryption with Bouncycastle Example in J2ME

...to C# and have the two following 3 questions:

  1. As I understand, the JAVA example uses AESEngine for encryption/decryption operations. What is the difference between AESEngine and AESFastEngine and AESLightEngine? Unfortunately I don't understand the information given in the documentation: http://www.bouncycastle.org/docs/docs1.6/index.html

  2. I want to use a new encryption-key for every file I encrypt. Which block cipher modes of operation shou开发者_Python百科ld I use: AES.CBC, AES.CFB, AES.ECB OR AES.OFB http://www.bouncycastle.org/docs/docs1.6/index.html

  3. Is my assumption correct that in my case I don't have to use an iv / salt (which means I have to use a static iv?) since I use AES.KeyGen128() for key generation and use it only once?

    http://www.bouncycastle.org/docs/docs1.6/index.html

Hope my questions do not cause too much confusion ;-) I but I appreciate every answer, clarification or feedback you can give me.

Mike


  1. My reading of the doc says that the AESEngine, FastEngine and LightEngine all take different tradeoffs of memory versus speed. You would have to test it yourself to determine if those tradeoffs are even relevant in your scenario.

  2. you will need to read up on the various AES modes. Different modes have different strengths and attributes, which may be more or less applicable or desirable depending on your scenario. So the answer to your question is "it depends."

  3. no. you will need an IV. As far as the salt, it is usually employed with the passphrase to generate the actual encryption key and the IV, often via PKBDF2. That is outside the realm of AES, but it is a typical usage.


Finally you didn't ask, but.... why are you porting that code to C#? .NET has AES encryption built-in. You don't need to port anything, you can just use the .NET base class library. Just ensure you use the same keysize and mode, and make sure your key+iv is the same on each side, and the .NET BCL AES classes will interoperate with the BouncyCastle stuff for J2ME.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号