Code: Select all
$ openssl pkcs12 -in bc_legacy.p12 -info -noout
...
Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 51200
PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 51200
Code: Select all
$ openssl pkcs12 -in sun.p12 -info -noout
...
Shrouded Keybag: PBES2, PBKDF2, AES-256-CBC, Iteration 10000, PRF hmacWithSHA256
PKCS7 Encrypted data: PBES2, PBKDF2, AES-256-CBC, Iteration 10000, PRF hmacWithSHA256
Code: Select all
ASN1ObjectIdentifier ENC_ALGORITHM = NISTObjectIdentifiers.id_aes256_CBC;
ASN1ObjectIdentifier MAC_ALGORITHM = PKCSObjectIdentifiers.id_PBES2;
int ITERATION_COUNT = 10_000;
OutputEncryptor keyEncryptor = new JcePKCSPBEOutputEncryptorBuilder(ENC_ALGORITHM)
.setProvider("BC")
.setIterationCount(ITERATION_COUNT)
.build(p12Password.toCharArray());
PKCS12SafeBagBuilder keyBagBuilder = new JcaPKCS12SafeBagBuilder((PrivateKey) privKey, keyEncryptor);
keyBagBuilder.addBagAttribute(PKCS12SafeBag.friendlyNameAttribute, new DERBMPString(alias));
PKCS12SafeBagBuilder certBagBuilder = new JcaPKCS12SafeBagBuilder(cert);
certBagBuilder.addBagAttribute(PKCS12SafeBag.friendlyNameAttribute, new DERBMPString(alias));
PKCS12PfxPduBuilder pfxBuilder = new PKCS12PfxPduBuilder();
pfxBuilder.addEncryptedData(
keyEncryptor,
new PKCS12SafeBag[]{keyBagBuilder.build(), certBagBuilder.build()}
);
JcePKCS12MacCalculatorBuilder macBuilder = new JcePKCS12MacCalculatorBuilder(MAC_ALGORITHM)
.setIterationCount(ITERATION_COUNT)
.setProvider("BC");
PKCS12PfxPdu pfx = pfxBuilder.build(macBuilder, p12Password.toCharArray());
Code: Select all
org.bouncycastle.pkcs.PKCSException: unable to process data: unable to create MAC calculator: no such algorithm: 1.2.840.113549.1.5.13 for provider BC
Kann Bouncy Castle OpenSSL-3.0-kompatible PKCS#12-Dateien erstellen?
Mobile version