![](/img/trans.png)
[英]java.security.NoSuchAlgorithmException: Algorithm x25519 not available
[英]java.security.NoSuchAlgorithmException: Ed25519 KeyPairGenerator not available
我已尝试使用 EdDSA 算法以使用 jar eddsa 0.3.0 生成密钥。 但是,我得到java.security.NoSuchAlgorithmException: Ed25519 KeyPairGenerator not available
当我尝试做KeyPairGenerator.getInstance("Ed25519");
另外,我有以下异常java.security.NoSuchAlgorithmException: Ed25519 Signature not available
当我尝试生成签名时。 有没有如何使它工作的例子?
我已经完成了研究,但我是加密阶段的新手,我真的不知道应该如何让它工作。
我知道 eddsaparam 构造函数是错误的。 下面的代码:
KeyPairGenerator keyPairGenerator=KeyPairGenerator.getInstance("EdDSA");//getInstance("ECDSA","BC");//EDDSA
SecureRandom secureRandom=SecureRandom.getInstance("SHA1PRNG");
EdDSANamedCurveSpec ed25519 = EdDSANamedCurveTable.getByName("Ed25519");
EdDSAParameterSpec edDSAParameterSpec = new EdDSAParameterSpec(ed25519, "Ed25519");
keyPairGenerator.initialize(edDSAParameterSpec,secureRandom);
我担心“Ed25519”是一个错字,应该是“EdDSA”。
假设您的 pom 文件包含以下内容:
<dependency>
<groupId>net.i2p.crypto</groupId>
<artifactId>eddsa</artifactId>
<version>0.3.0</version>
</dependency>
您的代码类似于:
import net.i2p.crypto.eddsa.EdDSASecurityProvider;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
public class App {
public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchProviderException {
// throws NoSuchAlgorithmException: EdDSA KeyPairGenerator not available
//KeyPairGenerator.getInstance("EdDSA");
// add eddsa to the security providers
Security.addProvider(new EdDSASecurityProvider());
// throws: NoSuchAlgorithmException: Ed25519 KeyPairGenerator not available
//KeyPairGenerator.getInstance("Ed25519");
// throws: NoSuchAlgorithmException: no such algorithm: Ed25519 for provider EdDSA
//KeyPairGenerator.getInstance("Ed25519", "EdDSA");
// works
KeyPairGenerator.getInstance("EdDSA", "EdDSA");
// also works
KeyPairGenerator.getInstance("EdDSA");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.