• Post Reply Bookmark Topic Watch Topic
  • New Topic

Default RSA padding in SUN JCE/Oracle JCE  RSS feed

 
sammaiah kyatham
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Could you help me to point out what is the default RSA padding.

Precisely, if I create cipher instance as below, sure java is using some sort of padding as encrypted text bytes length always shows 256 bytes for 2048 RSA key irrespective of plain text is one characters or 10 characters.



I wanted to know what is default padding java use internally if no padding is specified in Cipher.getInstance("RSA"). is that PKCS#1 v 1.5?


Thanks,
Sam
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When no padding or block mode are specified the default is "RSA/ECB/PKCS1Padding". PKCS1Padding takes a minimum of 11 bytes and takes the cleartext length to the length of the modulus. When used to encrypt the padding has a header and footer with a filler of random bytes. When used to create a signature the filler is non-random bytes. I can't remember the detail of the padding but I'm sure Google will find it. You can specify RSA/ECB/NoPadding but this is generally considered insecure since encryption of a short cleartext can allow a simple brute force attack to reveal the private key exponent.
 
sammaiah kyatham
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Richard. It helped me.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sammaiah kyatham wrote:Thank you, Richard.


You are welcome.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!