[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-jce] RSA encryption process truncates some bytes???



IAIK.addAsProvider(false);
Cipher c = Cipher.getInstance("RSA/ECB/NoPadding", "IAIK");
c.init(Cipher.ENCRYPT_MODE, publicKey);
 
// get the array
byte[] buf1 = ...; 
System.err.println(buf1.length); // plain text array size = 202
 
// encrypt
byte[] buf = c.doFinal(buf1);
System.err.println(buf.length); // cipher text array size = 128
 
// start to decrypt (use private key)
c.init(Cipher.DECRYPT_MODE, privateKey);
 
// decrypt the encrypted array
buf1 = c.doFinal(buf);
System.err.println(buf1.length); // recovered plain text array size = 128 != 202 ?????
 

No matter whether I use NoPadding or PKCS1Padding, the cipher text array size(128) is less then plain text array size(202)!!!
 
I think the cipher text array size should be equal to or larger than plain text array size....
 
Why encryption process truncates some bytes of my plain text??? ~~~ > < ~~~