Is It Ever Recommended To Use The ECB Cipher Mode?

梦想的初衷 提交于 2021-01-27 14:11:26

问题


Judging from this Wikipedia article on cipher modes and other things I've heard about ECB, it's a big no-no and can leak information about your encrypted data. However, there are still plenty of examples out there on the 'net that utilize ECB:

  • One of the top Google results for a Triple DES sample in .NET
  • One of the answers to this question

Is it ever acceptable or advantageous to use ECB?

If the data is very small (one block) and you're using both a salt and an IV, is it OK? If so, where is the threshold when you stop using it?


回答1:


If the data is very small (one block) and you're using both a salt and an IV, is it OK?

Yes

If so, where is the threshold when you stop using it?

Two blocks. There isn't any practical reason to use ECB, the only reason it exists is because it's a simple example of how to use a block cipher.




回答2:


This is better asked on crypto, but I'll answer anyway. ECB blockcipher is best used on randomized data, where there is no link between any of the plain text blocks. In practice, only randomized secret keys without any additional data and challenges fit that bill. Single block ECB is the same as single block CBC, with a fixed IV. It's fine as long as you don't reuse the key for other data. Most of the time it pays to simply go for CBC or, even better, GCM.



来源:https://stackoverflow.com/questions/9039617/is-it-ever-recommended-to-use-the-ecb-cipher-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!