在Android上解密SMIME消息时发生异常

时间:2019-01-29 21:40:39

标签: android smime

当尝试使用Bouncy Castle 1.6.0在Android 28上解密SMIME消息时,出现“传递给RSA的未知密钥类型”异常。 我可以看到私钥是AndroidKeyStoreRSAPrivateKey类型的。 是否因为BC无法使用这种类型的密钥而导致例外?有解决方法吗? 谢谢。

堆栈跟踪:

org.bouncycastle.operator.OperatorException: key invalid: unknown key type passed to RSA
        at org.bouncycastle.operator.jcajce.JceAsymmetricKeyUnwrapper.generateUnwrappedKey(Unknown Source:187)
        at org.bouncycastle.cms.jcajce.JceKeyTransRecipient.extractSecretKey(Unknown Source:230)
        at org.bouncycastle.cms.jcajce.JceKeyTransEnvelopedRecipient.getRecipientOperator(Unknown Source:0) 
        at org.bouncycastle.cms.KeyTransRecipientInformation.getRecipientOperator(Unknown Source:16) 
        at org.bouncycastle.cms.RecipientInformation.getContentStream(Unknown Source:0) 
        at org.bouncycastle.cms.RecipientInformation.getContent(Unknown Source:0) 

Caused by: java.security.InvalidKeyException: unknown key type passed to RSA
    at org.bouncycastle.jcajce.provider.asymmetric.rsa.CipherSpi.engineInit(Unknown Source:331)
    at org.bouncycastle.jcajce.provider.asymmetric.rsa.CipherSpi.engineInit(Unknown Source:3)
    at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2984)
    at javax.crypto.Cipher.tryCombinations(Cipher.java:2877)

0 个答案:

没有答案