我有通过PKCS7非对称加密方法加密的消息。里面有xml
我尝试通过以下方式对此进行解密
public static byte[] decryptData(byte[] encryptedData, PrivateKey decryptionKey) throws CMSException {
byte[] decryptedData = null;
if (null != encryptedData && null != decryptionKey) {
CMSEnvelopedData envelopedData = new CMSEnvelopedData(encryptedData);
Collection<RecipientInformation> recipients = envelopedData.getRecipientInfos().getRecipients();
KeyTransRecipientInformation recipientInfo = (KeyTransRecipientInformation) recipients.iterator().next();
JceKeyTransRecipient recipient = new JceKeyTransEnvelopedRecipient(decryptionKey);
return recipientInfo.getContent(recipient);
}
return decryptedData;
}
其错误格式错误的内容
CMSEnvelopedData envelopedData = new CMSEnvelopedData(encryptedData);