What are the cipher padding strings in java

守給你的承諾、 提交于 2019-12-17 18:27:27

问题


Everyone talks about the padding schemes in ciphers but what are the actual strings one needs to pass in to the cipher? I don't care if they are symmetric or asymmetric, I just want a list of the possible values.


回答1:


There are many types of padding, PKCS-7, Zero, ISO 10126, ANSI X.923, etc.
I suggest you read up on padding since you seem not to fully understand the concept.

Then there's the possibility you are referring to cryptographic salt.

Edit
Every implementation of the Java platform is required to support the following standard Cipher transformations with the keysizes in parentheses:

  • AES/CBC/NoPadding (128)
  • AES/CBC/PKCS5Padding (128)
  • AES/ECB/NoPadding (128)
  • AES/ECB/PKCS5Padding (128)
  • DES/CBC/NoPadding (56)
  • DES/CBC/PKCS5Padding (56)
  • DES/ECB/NoPadding (56)
  • DES/ECB/PKCS5Padding (56)
  • DESede/CBC/NoPadding (168)
  • DESede/CBC/PKCS5Padding (168)
  • DESede/ECB/NoPadding (168)
  • DESede/ECB/PKCS5Padding (168)
  • RSA/ECB/PKCS1Padding (1024, 2048)
  • RSA/ECB/OAEPWithSHA-1AndMGF1Padding (1024, 2048)
  • RSA/ECB/OAEPWithSHA-256AndMGF1Padding (1024, 2048)

You can find a list here.

Edit 2
You can find the Bouncy Castle specification here. It lists all available padding schemes.




回答2:


Block cyphers need padding, stream cyphers don't. Block cyphers need padding because they encrypt whole blocks, and your message may not exactly match a whole number of blocks. Padding is used to extend the message length to the next block boundary.

See the Wikipedia article on Cryptographic padding for a lot of detail.

For most purposes PKCS#7 (aka PKCS#5) padding is used: n bytes, all of value n:

01
02 02
03 03 03
...
10 10 10 10 ... 10 10


来源:https://stackoverflow.com/questions/10935068/what-are-the-cipher-padding-strings-in-java

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