转换java.security“;“不使用RSA”;BouncyCastle轻量级API的签名
我需要将Java应用程序转换为C#,因此需要从Java.security API迁移到转换java.security“;“不使用RSA”;BouncyCastle轻量级API的签名,java,cryptography,rsa,bouncycastle,Java,Cryptography,Rsa,Bouncycastle,我需要将Java应用程序转换为C#,因此需要从Java.security API迁移到BouncyCastle轻量级API 我的工作代码(java.security)如下所示: private byte[] computeSignature(byte[] message, PrivateKey key) { Signature signature = Signature.getInstance("NONEwithRSA"); signature.initSign(privateK
BouncyCastle
轻量级API
我的工作代码(java.security)如下所示:
private byte[] computeSignature(byte[] message, PrivateKey key) {
Signature signature = Signature.getInstance("NONEwithRSA");
signature.initSign(privateKey);
signature.update(message);
return signature.sign();
}
这是我的验证:
private void verifySignature(byte[] signature, byte[] message, PublicKey publicKey) {
Signature signature = Signature.getInstance("NONEwithRSA");
signature.initVerify(publicKey);
signature.update(message);
System.out.println(signer.verify(result) ? "OK" : "FAIL");
}
现在我正尝试将其迁移到BC,如下所示:
private byte[] computeSignature(byte[] message, PrivateKey key) {
Signature signature = Signature.getInstance("NONEwithRSA");
signature.initSign(privateKey);
signature.update(message);
return signature.sign();
}
private byte[] computeSignature(byte[] message, AsymmetricKeyParameter privateKey) {
Signer signer = new GenericSigner(new RSAEngine(), new NullDigest());
signer.init(true, privateKey);
signer.update(message, 0, message.length);
return signer.generateSignature();
}
NONEwithRSA
算法迁移到BC-LW-API中吗?我假设我需要编写自己的签名者,但作为BC的新手和BC文档,我无法独自处理此问题。尝试以下方法:
RSABlindedEngine engine = new RSABlindedEngine();
PKCS1Encoding paddedEngine = new PKCS1Encoding(engine);
paddedEngine.init(true, privateKey);
return paddedEngine.processBlock(message, 0, message.length);
嗨,leizeQ,请使用常用标签(有很多追随者)。至少尝试并包括编程语言。它尊重它的名字:它有2个追随者,而且它的目标不仅仅是弹跳城堡。