@@ -259,7 +259,14 @@ ossl_pkcs7_s_sign(int argc, VALUE *argv, VALUE klass)
259259
260260/*
261261 * call-seq:
262- * PKCS7.encrypt(certs, data, [, cipher [, flags]]) => pkcs7
262+ * PKCS7.encrypt(certs, data, cipher, flags = 0) => pkcs7
263+ *
264+ * Creates a PKCS #7 enveloped-data structure.
265+ *
266+ * Before version 3.3.0, +cipher+ was optional and defaulted to
267+ * <tt>"RC2-40-CBC"</tt>.
268+ *
269+ * See also the man page PKCS7_encrypt(3).
263270 */
264271static VALUE
265272ossl_pkcs7_s_encrypt (int argc , VALUE * argv , VALUE klass )
@@ -273,21 +280,12 @@ ossl_pkcs7_s_encrypt(int argc, VALUE *argv, VALUE klass)
273280 PKCS7 * p7 ;
274281
275282 rb_scan_args (argc , argv , "22" , & certs , & data , & cipher , & flags );
276- if (NIL_P (cipher )){
277- #if !defined(OPENSSL_NO_RC2 )
278- ciph = EVP_rc2_40_cbc ();
279- #elif !defined(OPENSSL_NO_DES )
280- ciph = EVP_des_ede3_cbc ();
281- #elif !defined(OPENSSL_NO_RC2 )
282- ciph = EVP_rc2_40_cbc ();
283- #elif !defined(OPENSSL_NO_AES )
284- ciph = EVP_EVP_aes_128_cbc ();
285- #else
286- ossl_raise (ePKCS7Error , "Must specify cipher" );
287- #endif
288-
283+ if (NIL_P (cipher )) {
284+ rb_raise (rb_eArgError ,
285+ "cipher must be specified. Before version 3.3, " \
286+ "the default cipher was RC2-40-CBC." );
289287 }
290- else ciph = ossl_evp_get_cipherbyname (cipher );
288+ ciph = ossl_evp_get_cipherbyname (cipher );
291289 flg = NIL_P (flags ) ? 0 : NUM2INT (flags );
292290 ret = NewPKCS7 (cPKCS7 );
293291 in = ossl_obj2bio (& data );
0 commit comments