On Fri, Jan 30, 2026 at 10:11 PM Tenay Lowden <[email protected]> wrote:
>
> Any methods to verify if it's PKCS7 vs PKCS5? Like how they did it here:
> https://stackoverflow.com/questions/67891550/detect-if-a-text-encrypted-using-aes-cbc-is-padded-or-not
>

Thanks, Tenay,
That particular post seems to be indicating what I mentioned before,
that Java's PKCS5 padding is actually PKCS7 padding - it was just
implemented when it was PKCS5 and never changed to be PKCS7. I suppose
I could change the Java code to decrypt using NoPadding and see what
happens.

I have verified that the encrypted data is actually padded - the
length of the data before running it through the JS encrypt function
is 503 bytes, the length of the encrypted data is 512 bytes. So, that
part seems to be working as expected, and I would guess it is properly
padding as PKCS7 since that's what JavaScript implements. That also
makes me think that the padding exception may either be due to
something else - mismatched encryption key or some issue encoding the
data from encrypted to Base64. Even if Java did PKCS5 instead of
PKCS7, 503 bytes padded to 512 is still a multiple of 64-bit block
size, so I'd think that would still be valid? Anyway, I'll keep
hacking away at it and figure out what I'm doing wrong...

-Nick

Reply via email to