Date: Mon, 24 Nov 1997 17:52:02 -0800 (PST)
From: Jan Luehe <Jan.Luehe@Eng>
Subject: Re: Implementing RSA encryption using JDK1.1.3
To: java-security@web2.javasoft.com, HIROEGU@jp.ibm.com
> X-VM-v5-Data: ([nil t nil nil nil nil nil nil nil] ["1870" "Tue" "5"
"August" "1997" "10:26:49" "+0900" "Hiroyuki Eguchi" "HIROEGU@jp.ibm.com" nil
"39" "Implementing RSA encryption using JDK1.1.3" nil nil nil "8" nil nil
(number " " mark "U Hiroyuki Eguchi Aug 5 39/1870 " thread-indent
Hiroyuki:
> Hello,
> I have started implementing my own provider for RSA encryption and
> signatures ( as there will be no international release of JCE) and I am
> having some difficulties. I am trying to implement a method for RSA
> encryption using the PKCS#1 standards. The problem is that the formula
> used in PKCS#1 considers a byte of data to be able to take the value of
> 0-255. Unfortunately, the byte data type provided in Java can take values
> between -128 and 127 only. I have been considering ways of working around
> this problem, as recpmputing the PKCS#1 formulae to work with the byte data
> type in Java, or map the -ve values of the data to the one it should be,
> had the byte data type had a range of 0-255 (for eg. -1 will map to 255).
You might want to use BigInteger for your computations, and use
the
public BigInteger(int signum, byte magnitude[])
constructor for converting a byte value (in the range of
0-255) to a BigInteger.
> I was also wondering what padding scheme is the JCE using for RSA
> encryption/decryption. The only RSA encryption standard that I am aware of
> is the PKCS#1.
JCE does not implement RSA.
PKCS#1 defines one standard padding scheme for RSA encryption, which is
identified by the algorithm identifier "rsaEncryption"
(1.2.840.113549.1.1.1).
You would not need to specify this padding scheme explicitly when requesting
an RSA cipher instance through
Cipher c = Cipher.getInstance("RSA");
The padding mechanism is implied by the algorithm identifier associated
with "RSA".
Jan