哪种签名算法可以处理RSA密钥?

时间:2019-06-08 21:54:54

标签: java digital-signature

我已经开发了Java RMI应用程序。我已经为不同客户端和服务器之间的所有通信实现了混合加密。对于非对称密钥,我使用RSA。现在,我正在尝试使用SignedObject类来实现签名。作为创建新SignedObject时的第三个参数,我必须传递一个签名算法。我的问题是哪种签名算法可以与已经实施的RSA密钥兼容?

当前,我正在使用默认签名算法DSA,如文档中所述。但是,在运行应用程序时,遇到以下错误:

TweetClient exception (publish): java.security.InvalidKeyException: No installed provider supports this key: sun.security.rsa.RSAPrivateCrtKeyImpl
java.security.InvalidKeyException: No installed provider supports this key: sun.security.rsa.RSAPrivateCrtKeyImpl
    at java.security.Signature$Delegate.chooseProvider(Signature.java:1138)
    at java.security.Signature$Delegate.engineInitSign(Signature.java:1179)
    at java.security.Signature.initSign(Signature.java:530)
    at java.security.SignedObject.sign(SignedObject.java:240)
    at java.security.SignedObject.<init>(SignedObject.java:160)
    at be.vub.parallellism.solutions.encryption.EncryptionUnit.encryptWithSecretKey(EncryptionUnit.java:80)
    at be.vub.parallellism.solutions.TweetClient.publish(TweetClient.java:137)
    at be.vub.parallellism.solutions.TweetClient.access$000(TweetClient.java:25)
    at be.vub.parallellism.solutions.TweetClient$1.run(TweetClient.java:126)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

1 个答案:

答案 0 :(得分:0)

找到答案,“ SHA256withRSA”可用于256字节大小的RSA密钥。