Looking for RSA implementation using Java

I am looking for RSA implemetation using Java . Can any one help me in finding one that I should be able to use out of the box .?Apart from that I also want to just port the encryption logic from java to java script. So if I get the same solution in java script than nothing like it .
[291 byte] By [subhrajyotia] at [2007-11-27 7:58:41]
# 1

> I am looking for RSA implemetation using Java .

The JCE in JRE1.5 and later has build in RSA. If you are using earlier that 1.5 then you could use BpouncyCastle provider.

> Can

> any one help me in finding one that I should be able

> to use out of the box .?

You can use the JCE in 1.5 and later or the BouncyCastle provider 'out of the box'.

> Apart from that I also want

> to just port the encryption logic from java to java

> script. So if I get the same solution in java script

> than nothing like it .

There are Javascript implementations of RSA but you almost certainly won't be able to use them 'out of the box' to interact with your Java code.

It sounds to me like you have a design problem if you are thinking of encrypting in Javascript and then decrypting in Java. Consider using HTTPS/SSL.

sabre150a at 2007-7-12 19:40:39 > top of Java-index,Security,Cryptography...
# 2
Thanks for your quick reply . You said "There are Javascript implementations of RSA but you almost certainly won't be able to use them 'out of the box' to interact with your Java code." What is the reason you say so ?
subhrajyotia at 2007-7-12 19:40:39 > top of Java-index,Security,Cryptography...
# 3

> Thanks for your quick reply . You said "There are

> Javascript implementations of RSA but you almost

> certainly won't be able to use them 'out of the box'

> to interact with your Java code." What is the reason

> you say so ?

1) The key format may be different.

2) The data format accepted may be different.

3) The padding mode may be different.

sabre150a at 2007-7-12 19:40:39 > top of Java-index,Security,Cryptography...
# 4

Yes I also agree to your reasons. But I want to give it a try . I have downloaded the BouncyCastle provider from bouncycastle.org and have been able to run the following progam successfully (which lists out the the name of the BouncyCastle Provider)which incidentally i found in one of the Java forums :

public class ProviderInformation {

public static void main(String[] args) {

Provider[] providers = Security.getProviders();

for (int i = 0; i < providers.length; i++) {

Provider provider = providers;

System.out.println("Provider name: " + provider.getName());

System.out.println("Provider information: " + provider.getInfo());

System.out.println("Provider version: " + provider.getVersion());

Set entries = provider.entrySet();

Iterator iterator = entries.iterator();

while (iterator.hasNext()) {

System.out.println("Property entry: " + iterator.next());

}

}

}

}

But I need a Test class to test the RSA algo which comes with this provider . Basically I just want to ensure that the plain text is encrypted and then from the cipher text , I get back the plain text.Can someone point me to the location where I can find a test program like this ?

subhrajyotia at 2007-7-12 19:40:39 > top of Java-index,Security,Cryptography...
# 5

>}

> ut I need a Test class to test the RSA algo which

> comes with this provider . Basically I just want to

> ensure that the plain text is encrypted and then from

> the cipher text , I get back the plain text.Can

> someone point me to the location where I can find a

> test program like this ?

Sorry - I have RSA test code but I no longer publish full examples on this site. I found that people were just using it blindly without trying to understand what they were doing.

sabre150a at 2007-7-12 19:40:39 > top of Java-index,Security,Cryptography...
# 6
I see the reason why you don't want to publish it publicly. Can you send an email to me because I am in need of the same ?
subhrajyotia at 2007-7-12 19:40:39 > top of Java-index,Security,Cryptography...
# 7
> I see the reason why you don't want to publish it> publicly. Can you send an email to me because I am in> need of the same ?Sorry! No!
sabre150a at 2007-7-12 19:40:39 > top of Java-index,Security,Cryptography...