title: Encrypting email using RSAES-OAEP & AES
body: <p>I'm using Bouncycastle SMIME package to encrypt messages using rsassa-pss certificate:</p>
  
  <pre><code>openssl x509 -text -in certificate.crt | grep -i "algorithm"
  Signature Algorithm: rsassaPss
       Hash Algorithm: sha256
       Mask Algorithm: mgf1 with sha256
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>public void encrypt(Collection&lt;X509Certificate&gt; certs)  {
      OutputEncryptor enc = new BcCMSContentEncryptorBuilder(CMSAlgorithm.AES192_CBC).build();
      SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator();
  
      for (X509Certificate nCert : certs) {
           gen.addRecipientInfoGenerator(
           new JceKeyTransRecipientInfoGenerator(nCert, new AlgorithmIdentifier(PKCSObjectIdentifiers.id_RSAES_OAEP))
                  .setProvider("BC"));
  }
  </code></pre>
  
  <p>But it doesn't work. Any ideas?</p>