2

I tried to use AES/ECB/PKCS7Padding to encrypt a file, but am getting the following exception.

java.security.NoSuchAlgorithmException: Cannot find any provider supporting AES/ECB/PKCS7Padding

Apparently PKCS7Padding is not supported. If I use AES/ECB/PKCS5Padding, then it works fine.

The requirement given to me is that EBC and PKCS7 with padding are to be used.

Someone answered in the below question that "Java is actually performing PKCS #7 padding, but in the JCA specification, PKCS5Padding is the name given"

AES-256 and PKCS7Padding fails in Java

In the below question, someone said that " I will point out that PKCS#5 and PKCS#7 actually specify exactly the same type of padding ..."

java.security.NoSuchAlgorithmException:Cannot find any provider supporting AES/ECB/PKCS7PADDING

What does that mean? AES/ECB/PKCS5Padding and AES/ECB/PKCS7Padding are the same? So both will produce exactly the same encrypted output?

TIA.

Community
  • 1
  • 1
user3573403
  • 1,780
  • 5
  • 38
  • 64
  • 3
    Yes, that is what that means. Technically PKCS5 only supported 64-bit block ciphers, whereas PKCS7 supports 128-bit block ciphers. The padding scheme is essentially the same. When you specify PKCS5Padding you are actually getting PKCS7 padding. – President James K. Polk Jan 22 '15 at 02:34
  • Crypto.SE duplicate: [What is the difference between PKCS#5 padding and PKCS#7 padding](http://crypto.stackexchange.com/questions/9043/what-is-the-difference-between-pkcs5-padding-and-pkcs7-padding) – Artjom B. Jan 22 '15 at 10:35
  • I'm voting to close this question as off-topic because it is about [cryptography](http://crypto.stackexchange.com/). – Artjom B. Jan 22 '15 at 10:36
  • I also need to do another encryption using RSA/ECB/PKCS7Padding. Again, PKCS7Padding is also not supported. I believe the default mode and padding for RSA is RSA/ECB/PKCS1Padding. What can I do? – user3573403 Jan 22 '15 at 10:56

0 Answers0