Home > Archive > Java Security > April 2006 > no such algorithm: SHA-1 for provider BC
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
no such algorithm: SHA-1 for provider BC
|
|
| fealfu@gmail.com 2006-04-21, 4:06 am |
| I=B4m trying to verify a signature made in Firefox with
windows.crypto.signText and the same text signed in Internet Explorer
with Capicom.
My problem is in Tomcat when I try validate this signature.
I always obtain a "NoSuchAlgorithmException", my code is very simple.
Code is not perfect, but it was only a first version.
Can somebody tell me why I obtain that error? What is wrong in my code?
verifySignature(HttpServletRequest request, PrintWriter out)
{
Object o =3D
request.getAttribute("javax.servlet.request.X509Certificate");
X509Certificate[] certs =3D (X509Certificate[]) o;
X509Certificate cert;
if ( certs.length>0)
{
cert =3D certs[0];
Signature signature;
try
{
//Add the providir, perhaps not necesary
Security.addProvider(new BouncyCastleProvider());
//Set provider for signature, perhaps not necesary
signature =3D Signature.getInstance("SHA-1",new BouncyCastleProvider());
signature.initVerify(cert);
signature.update(request.getParameter("textoToSign").getBytes());
if (signature.verify(request.getParameter("firma").getBytes()))
{
out.print("**********OK******************");
}
else
{
out.print("---------------NOT OK-------------");
}
}
catch(Exception e)
{
out.print("ERROR: " + e.getMessage());
e=2EprintStackTrace();
return;
}
}//end if
}//end function
The result is always
ERROR: no such algorithm: SHA-1 for provider BC
I have tryed without specify provide and with
gnu.crypto.jce.GnuCrypto() (GNU Cryto Provider) and the result is the
same.
Thanks in advance.
| |
| fealfu@gmail.com 2006-04-21, 4:06 am |
| Ok, it works.
If I use "SHA1WithRSAEncryption" I don=B4t get this excepti=F3n but I get
that the signature is not verified.
I=B4m trying to verify a PKCS7, do you know if it is the correct system
to validate it?.
Thanks
|
|
|
|
|