0

I am trying to generate signature using ECDSA with binary curve (B163) . Also i am using Bouncy Castle libraries. but it generate error like this-

Exception in thread "main" java.lang.IllegalAccessError: tried to access method java.security.Provider.<init>(Ljava/lang/String;DLjava/lang/String;)V from class ECCKey
    at ECCKey.main(ECCKey.java:13)

how can this error be resolved?

Security.addProvider(new BouncyCastleProvider());

 KeyPairGenerator keyGen = KeyPairGenerator.getInstance("ECDSA", "BC");

 ECGenParameterSpec ecSpec = new ECGenParameterSpec("B-163");

    keyGen.initialize(ecSpec, new SecureRandom());

    KeyPair keyPair = keyGen.generateKeyPair();
    Signature signature = Signature.getInstance("ECDSA", "BC");
    signature.initSign(keyPair.getPrivate(), new SecureRandom());


    byte[] message = "abc".getBytes();
    signature.update(message);
dave_thompson_085
  • 34,712
  • 6
  • 50
  • 70
divan
  • 87
  • 1
  • 1
  • 7
  • I added formatting, especially for ''; anglebracketed items in a post (but not comment) are default taken as HTML and vanish. `IllegalAccess` often means a wrong version of a class/library, but this Provider ctor (String,double,String) hasn't changed in a long time and shouldn't be called directly anyway -- are you sure there isn't another `at` line in your actual trace? The other common cause is inconsistent classloading; are you running in a plain JRE (and if so which) or in an IDE (Eclipse, Intellij, Netbeans) or container (Tomcat/Wildfly, Weblogic, Websphere, browser/JNLP, etc)? – dave_thompson_085 Apr 08 '16 at 23:07
  • sir, i have added jar files bcprov-jdk15on-154 in Eclipse libraries but it creates error.. – divan Apr 09 '16 at 04:48
  • *Building* in Eclipse doesn't necessarily mean you *run* in Eclipse, and even if you do Eclipse provides numerous execution environments corresponding to different kinds of projects and (planned) deployments. I put the code from your question in a single class in a new plain vanilla Java-Project (on Mars 4.5.1 on Java 8u60 with the bcprov you name) and it runs correctly without error. Try that; if it fails running under Eclipse also try running in Java invoked directly from commandline (shell or CMD) with bcprov added to classpath. – dave_thompson_085 Apr 12 '16 at 08:04

0 Answers0