JDK-8076969 : PKCS5Padding and PKCS7Padding name conventions
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.crypto
  • Priority: P3
  • Status: Resolved
  • Resolution: Won't Fix
  • Submitted: 2015-04-03
  • Updated: 2016-06-18
  • Resolved: 2016-06-13
Description
PKCS5Padding by definition is for ciphers that have a blocksize of 8 bytes.  PKCS7Padding is for blocksizes that are 1 to 255 bytes.  Technically our use of PKCS5Padding is incorrect for ciphers like AES.  Though PKCS5Padding has been in use forever in JCE and with very sporadic objections, it would be proper to use the correct naming convention.

The plan is to add and document by default the ciphers with PKCS7Padding naming.   PKCS5Padding naming will continue to work given the long history of use and there are no plans to deprecate the naming.
Comments
Please reconsider reopening this issue.
18-06-2016

I and others have run in to it as well. Changing the implementation for AES/CBC/pkcs5padding would be wrong but there doesn't seem to be any downside to adding an alias to AES/CBC/pkcs7padding http://stackoverflow.com/questions/25942165/aes-256-and-pkcs7padding-fails-in-java http://stackoverflow.com/questions/20770072/aes-cbc-pkcs5padding-vs-aes-cbc-pkcs7padding-with-256-key-size-performance-java There is also the compatibility issue with other providers (Bouncy Castle), implementations (Android) and platforms (C#/.NET) which get it correct. It will always seem weird to use require use of different algorithm names in interoperability situations. https://social.msdn.microsoft.com/Forums/en-US/09fef7b7-b568-4895-8e52-f386be80aa2d/pkcs7-padding-in-net-vs-pkcs5-padding-in-java?forum=csharpgeneral
18-06-2016

Aside from the person who prompted the filing of this bug, there is no one that seems to care that PKCS5 and PKCS7 are used incorrectly. If there was a ground swell of support, I would change this, but with hearing more feedback about this being important, it's not worth fixing after so many years of being technically incorrect.
13-06-2016