问题
I am trying to generate a signature using ECDSA
with SHA256
in Bouncy Castle
as follows,
- I add the provider in the begining
- I have built the ECPrivatekey
Signature s_oSignature = Signature.getInstance("SHA256withECDSA", BouncyCastleProvider.PROVIDER_NAME);
but step 3 throws "java.security.NoSuchAlgorithmException: no such algorithm: SHA256withECDSA for provider BC"
.
But same "SHA256withECDSA"
thing when replaced with "SHA1withECDSA"
prceeds without any exception.
How is it possible? I am using "bcprov-jdk14-121.jar"
.
Can any one please help me as I have been struggling for a long time?
回答1:
I've never encountered this problem but here are a few things you can try.
- make sure you have the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files installed and configured (download here at the bottom of the page)
- try using the latest release of BouncyCastle and installing it as a provider in the runtime and not on-the-fly within the program
This problem is extremely odd as SHA256withECDSA is clearly listed in the specifications so it only leaves the option to try all possible options no matter how unlikely they are to help.
来源:https://stackoverflow.com/questions/10721831/ecdsa-with-sha256-in-bouncy-castle-throws-no-such-algorithm-exception