Java Encryption NoSuchAlgorithmException

Discussion in 'Java' started by DougJrs, Apr 2, 2007.

  1. DougJrs

    DougJrs Guest

    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
     
    DougJrs, Apr 2, 2007
    #1
    1. Advertising

  2. DougJrs wrote:
    > 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
     
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=, Apr 3, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Fiske
    Replies:
    0
    Views:
    464
    Daniel Fiske
    Aug 29, 2003
  2. Derek
    Replies:
    0
    Views:
    582
    Derek
    Apr 3, 2004
  3. Andy Fish

    dummies guide to java encryption

    Andy Fish, Jun 21, 2004, in forum: Java
    Replies:
    2
    Views:
    10,358
    Roedy Green
    Jun 21, 2004
  4. Timo Nentwig

    JCE: NoSuchAlgorithmException

    Timo Nentwig, Dec 14, 2004, in forum: Java
    Replies:
    0
    Views:
    445
    Timo Nentwig
    Dec 14, 2004
  5. Replies:
    0
    Views:
    2,788
Loading...

Share This Page