Java Encryption NoSuchAlgorithmException

D

DougJrs

I am attempting to encrypt and decrypt data using the bouncycastle JCE
provider. I get this exception when I try to use it:
java.security.NoSuchAlgorithmException: Cannot find any provider
supporting RSA/ECB/PKCS1Padding
at javax.crypto.Cipher.getInstance(DashoA12275)
at jsp_servlet.__headers._jspService(headers.jsp:46)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl
$ServletInvocationAction.run(ServletStubImpl.java:1072)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:
465)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:
526)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:
348)
at weblogic.servlet.internal.WebAppServletContext
$ServletInvocationAction.run(WebAppServletContext.java:6981)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:
321)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
121)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:
3892)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:
2766)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)






My Code looks like this:
RSAEncryptUtil cipher = new RSAEncryptUtil();

KeyPair key;
key = cipher.generateKey();

String TestMessage = "This is the message!!";


byte[] cipherText = null;
// get an RSA cipher object and print the provider
Cipher cipher2 = Cipher.getInstance("RSA/ECB/PKCS1Padding");
out.println("\nProvider is: " + cipher2.getProvider().getInfo());
out.println("\nStart encryption with public key");




Can anyone point out what I am doing wrong?

Thanks,
Doug
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

DougJrs said:
I am attempting to encrypt and decrypt data using the bouncycastle JCE
provider. I get this exception when I try to use it:
java.security.NoSuchAlgorithmException: Cannot find any provider
supporting RSA/ECB/PKCS1Padding
at javax.crypto.Cipher.getInstance(DashoA12275)
My Code looks like this:
Cipher cipher2 = Cipher.getInstance("RSA/ECB/PKCS1Padding");
Can anyone point out what I am doing wrong?

Try inserting a line:

Security.addProvider(new
org.bouncycastle.jce.provider.BouncyCastleProvider());

before your code.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top