Nena
Nena

Reputation: 701

bouncy castle DefaultSignatureAlgorithmIdentifierFinder NoSuchFieldError: gostR3410_94

I'm working with BouncyCastle libraries: bcprov-jdk16-146.jar and bcpkix-jdk15on-1.54.jar. And I'm trying to run the following snippet of code, where the last line throws a java.lang.NoSuchFieldError: gostR3410_94 I've tried researching this issue but haven't found anything - I'm not sure why I'm getting this issue? Error occurs in static initializer for DefaultSignatureAlgorithmIdentifierFinder. Using java8 and I've added bouncycastle as my security provider in java.security as well.

Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
        KeyPair kp = RSAKeyGenerator.generate2();
        AsymmetricKeyParameter privateKey = 
                (AsymmetricKeyParameter) PrivateKeyFactory.createKey(kp.getPrivate().getEncoded());
        AsymmetricKeyParameter publicKey = 
                (AsymmetricKeyParameter) PublicKeyFactory.createKey(kp.getPublic().getEncoded());


    X500NameBuilder x500NameBld = new X500NameBuilder(RFC4519Style.INSTANCE);

    x500NameBld.addRDN(RFC4519Style.c, "AU");
    x500NameBld.addRDN(RFC4519Style.o, "The Legion of the Bouncy Castle");
    x500NameBld.addRDN(RFC4519Style.l, "Melbourne");
    x500NameBld.addRDN(RFC4519Style.st, "Victoria");
    x500NameBld.addRDN(PKCSObjectIdentifiers.pkcs_9_at_emailAddress, "[email protected]");

    X500Name subject = x500NameBld.build();

    PKCS10CertificationRequestBuilder requestBuilder = new PKCS10CertificationRequestBuilder(subject, new SubjectPublicKeyInfo(ASN1Sequence.getInstance(kp.getPublic().getEncoded())));

    DefaultSignatureAlgorithmIdentifierFinder sigAlgFinder = new DefaultSignatureAlgorithmIdentifierFinder();

Upvotes: 3

Views: 4291

Answers (1)

Nena
Nena

Reputation: 701

The solution to this problem was to use an earlier version of Bouncy Castle Provider: bcprov-jdk15on-1.54.jar. This jar is compatible with bcpkix-jdk15on-1.54.jar. The newer jar resulted in mismatched CryptoProObjectIdentifiers object identifiers.

Upvotes: 4

Related Questions