小编Vit*_*aly的帖子

java.lang.IllegalArgumentException: string curve25519 不是 OID bouncycastle 1.52

我正在尝试使用曲线 25519 的 /java bouncy castle 1.52 实现生成密钥对,这给了我什么

java.lang.IllegalArgumentException: 字符串 curve25519 不是 OID

这是我的代码:

public KeyPair generateKeys() throws NoSuchAlgorithmException,
        NoSuchProviderException, InvalidAlgorithmParameterException {
    ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("curve25519");
    KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC");
    g.initialize(ecSpec, new SecureRandom());

    return g.generateKeyPair();
}
Run Code Online (Sandbox Code Playgroud)

此代码的结果是下面的堆栈跟踪:

java.lang.IllegalArgumentException:字符串curve25519 不是org.bouncycastle.asn1.ASN1ObjectIdentifier.(Unknown Source) at org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPublicKey.getEncoded(Unknown Source) at org.bouncycastle的OID .provider.asymmetric.ec.BCECPrivateKey.getPublicKeyDetails(Unknown Source) at org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey.(Unknown Source) at org.bouncycastle.jcajce.provider.asymmetric.ec.KeyPairGeneratorSpi$EC. generateKeyPair(Unknown Source) at com.poc.databank.encryption.BouncyCastleEncryption.generateKeys(BouncyCastleEncryption.java:22) at com.poc.databank.encryption.BouncyCastleTest.testApp(BouncyCastleTest.java:16) at sun.reflect.NativeMethodAccessorImpl. invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl。invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.junit.runners.model.FrameworkMethod $1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)在 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 在 org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) 在 …

java cryptography bouncycastle elliptic-curve key-pair

3
推荐指数
1
解决办法
2308
查看次数