Buggy code:
public class Encryptor { public static final String TAG = Encryptor . class . getSimpleName ( ) ; private Encryptor ( ) { } public static byte [ ] encryptSMIME ( MimeMessage msgToEncrypt , X509Certificate receiverCert ) throws Exception { } public static EncryptedBundleVS decryptEncryptedBundle ( EncryptedBundleVS encryptedBundleVS , PublicKey publicKey , PrivateKey receiverPrivateKey ) throws Exception { } public static List < EncryptedBundleVS > decryptEncryptedBundleList ( List < EncryptedBundleVS > encryptedBundleVSList , PublicKey publicKey , PrivateKey receiverPrivateKey ) throws Exception { } public static byte [ ] encryptMessage ( byte [ ] text , X509Certificate receiverCert , Header ... headers ) throws Exception { } public static byte [ ] encryptToCMS ( byte [ ] dataToEncrypt , X509Certificate receiverCert ) throws IOException , CertificateEncodingException , CMSException , OperatorCreationException { CMSEnvelopedDataStreamGenerator dataStreamGen = new CMSEnvelopedDataStreamGenerator ( ) ; dataStreamGen . addRecipientInfoGenerator ( new JceKeyTransRecipientInfoGenerator ( receiverCert ) . setProvider ( PROVIDER ) ) ; ByteArrayOutputStream bOut = new ByteArrayOutputStream ( ) ; OutputStream out = dataStreamGen . open ( bOut , new org . bouncycastle2 . cms . jcajce . JceCMSContentEncryptorBuilder ( CMSAlgorithm . DES_EDE3_CBC ) . setProvider ( PROVIDER ) . build ( ) ) ; out . write ( dataToEncrypt ) ; out . close ( ) ; <START_BUG> return Base64 . encode ( bOut . toByteArray ( ) ) ; <END_BUG> } public static SMIMEMessage decryptSMIME ( byte [ ] encryptedMessageBytes , PrivateKey receiverPrivateKey ) throws Exception { } public static byte [ ] decryptMessage ( byte [ ] encryptedMessageBytes , PrivateKey receiverPrivateKey ) throws Exception { } public static byte [ ] decryptFile ( byte [ ] encryptedFile , PublicKey publicKey , PrivateKey receiverPrivateKey ) throws Exception { } public static byte [ ] decryptCMS ( byte [ ] base64EncryptedData , PrivateKey privateKey ) throws Exception { } public static EncryptedBundle pbeAES_Encrypt ( String password , byte [ ] bytesToEncrypt ) throws UnsupportedEncodingException , InvalidKeyException , NoSuchAlgorithmException , InvalidKeySpecException , InvalidParameterSpecException , BadPaddingException , IllegalBlockSizeException , NoSuchPaddingException { } public static byte [ ] pbeAES_Decrypt ( String password , EncryptedBundle bundle ) throws UnsupportedEncodingException , InvalidAlgorithmParameterException , InvalidKeyException , NoSuchAlgorithmException , InvalidKeySpecException , BadPaddingException , IllegalBlockSizeException , NoSuchPaddingException { } public static String encryptAES ( String messageToEncrypt , AESParams aesParams ) throws UnsupportedEncodingException , InvalidAlgorithmParameterException , InvalidKeyException , NoSuchAlgorithmException , BadPaddingException , IllegalBlockSizeException , NoSuchPaddingException , InvalidCipherTextException { } public static String decryptAES ( String messageToDecrypt , AESParams aesParams ) throws UnsupportedEncodingException , InvalidAlgorithmParameterException , InvalidKeyException , NoSuchAlgorithmException , BadPaddingException , IllegalBlockSizeException , NoSuchPaddingException , InvalidCipherTextException { } }

Fix:
return Base64 . encode ( bOut . toByteArray ( ) , NO_WRAP ) ;