使用证书加密数据我们正在使用bouncycaste:
private Provider providerBC = new BouncyCastleProvider();
public byte[] encryptData(byte[] data, X509Certificate cert) throws Exception {
CMSTypedData msg = new CMSProcessableByteArray(data);
CMSEnvelopedDataGenerator envGen = new CMSEnvelopedDataGenerator();
envGen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(cert)
.setProvider(providerBC));
CMSEnvelopedData envData = envGen.generate(msg,
new JceCMSContentEncryptorBuilder(CMSAlgorithm.AES128_CBC).build());
return envData.getEncoded();
}
如何使用IBM提供商之一替换加密数据?
security.provider.1 = com.ibm.crypto.pkcs11impl.provider.IBMPKCS11Impl security.provider.2 = com.ibm.crypto.provider.IBMJCE security.provider.3 = com.ibm.jsse2.IBMJSSEProvider2 security.provider.4 = com.ibm.security.jgss.IBMJGSSProvider security.provider.5 = com.ibm.security.cert.IBMCertPath security.provider.6 = com.ibm.security.cmskeystore.CMSProvider security.provider.7 = com.ibm.security.jgss.mech.spnego.IBMSPNEGO security.provider.8 = com.ibm.security.sasl.IBMSASL security.provider.9 = com.ibm.xml.crypto.IBMXMLCryptoProvider security.provider.10 = com.ibm.xml.enc.IBMXMLEncProvider security.provider.11 = org.apache.harmony.security.provider.PolicyProvider
因为我们正在将程序移动到webpshere服务器,我不能使用bouncycastle
更新:
确定替换cms可能是一个大问题但是我们想要使用PKCS7Padding进行加密的加密呢?
Cipher.getInstance("AES/CBC/PKCS7Padding", providerBC)