Originally posted by: SystemAdmin
Hi, I am facing an issue with return value from method getOutputSize of Cipher class.
byte[] encryptedBytes = Base64.decodeBase64(encryptedStr); Cipher rsaCipher = Cipher.getInstance(
"RSA"); rsaCipher.init(Cipher.DECRYPT_MODE, getPrivateKey()); *
int bufsiz = rsaCipher.getOutputSize(KEYSIZE);*
byte[] aesBytes = Arrays.copyOfRange(encryptedBytes, 0, bufsiz);
byte[] passwdBytes = Arrays.copyOfRange(encryptedBytes, bufsiz, encryptedBytes.length); SecretKey aesKey = getAESKey(rsaCipher.doFinal(aesBytes));
I am getting exception in last line (doFinal method) -
javax.crypto.BadPaddingException: Not PKCS#1 block type 2 or Zero padding This because of the value of bufsiz is 257. If I change this to 256 in debug mode, it execute successfully.
This code is working fine on WIndows, Solaris. Is this known issue in AIX ?
Can someone help ?
#AIX-Forum