final byte[] iv = new byte[16];
Crypto.getSecureRandomSupplier().get().nextBytes(iv);
cipher.init( Cipher.ENCRYPT_MODE, symmKey, new IvParameterSpec( iv ) );
final byte[] cipherText = cipher.doFinal(Base64.encode( targetCert.getPrivateKey().getBytes() ));
final String encPrivKey = new String(Base64.encode(Arrays.concatenate(iv, cipherText)));
<BUG>X509Certificate x509Cert = PEMFiles.toCertificate(certPem);
</BUG>
cipher = Ciphers.RSA_PKCS1.get();
cipher.init(Cipher.ENCRYPT_MODE, x509Cert.getPublicKey());
byte[] symmkey = cipher.doFinal(symmKey.getEncoded());

final byte[] iv = new byte[16];
Crypto.getSecureRandomSupplier().get().nextBytes(iv);
cipher.init( Cipher.ENCRYPT_MODE, symmKey, new IvParameterSpec( iv ) );
final byte[] cipherText = cipher.doFinal(Base64.encode( targetCert.getPrivateKey().getBytes() ));
final String encPrivKey = new String(Base64.encode(Arrays.concatenate(iv, cipherText)));
X509Certificate x509Cert = PEMFiles.getCert( B64.standard.dec( certPem ) );
cipher = Ciphers.RSA_PKCS1.get();
cipher.init(Cipher.ENCRYPT_MODE, x509Cert.getPublicKey());
byte[] symmkey = cipher.doFinal(symmKey.getEncoded());
