ECDSA with SHA256 in Bouncy castle throws No Such Algorithm Exception

我的梦境 提交于 2021-02-07 08:45:12

问题


I am trying to generate a signature using ECDSA with SHA256 in Bouncy Castle as follows,

  1. I add the provider in the begining
  2. I have built the ECPrivatekey
  3. 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.

  1. 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)
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!