@@ -259,7 +259,14 @@ ossl_pkcs7_s_sign(int argc, VALUE *argv, VALUE klass)
259
259
260
260
/*
261
261
* 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).
263
270
*/
264
271
static VALUE
265
272
ossl_pkcs7_s_encrypt (int argc , VALUE * argv , VALUE klass )
@@ -273,21 +280,12 @@ ossl_pkcs7_s_encrypt(int argc, VALUE *argv, VALUE klass)
273
280
PKCS7 * p7 ;
274
281
275
282
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." );
289
287
}
290
- else ciph = ossl_evp_get_cipherbyname (cipher );
288
+ ciph = ossl_evp_get_cipherbyname (cipher );
291
289
flg = NIL_P (flags ) ? 0 : NUM2INT (flags );
292
290
ret = NewPKCS7 (cPKCS7 );
293
291
in = ossl_obj2bio (& data );
0 commit comments