Make SMIME_read_CMS_ex() and SMIME_read_ASN1_ex() support binary input
[openssl.git] / crypto / pkcs7 / pk7_mime.c
index 2099e8d9eff4b44b9edd69fc5833e846054fbb07..b4464233849cfa7a683966177f6363dd61de8d6d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -31,7 +31,7 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags)
 {
     STACK_OF(X509_ALGOR) *mdalgs;
     int ctype_nid = OBJ_obj2nid(p7->type);
-    const PKCS7_CTX *ctx = pkcs7_get0_ctx(p7);
+    const PKCS7_CTX *ctx = ossl_pkcs7_get0_ctx(p7);
 
     if (ctype_nid == NID_pkcs7_signed)
         mdalgs = p7->d.sign->md_algs;
@@ -40,21 +40,20 @@ int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags)
 
     flags ^= SMIME_OLDMIME;
 
-    return SMIME_write_ASN1_with_libctx(bio, (ASN1_VALUE *)p7, data, flags,
-                                        ctype_nid, NID_undef, mdalgs,
-                                        ASN1_ITEM_rptr(PKCS7),
-                                        pkcs7_ctx_get0_libctx(ctx),
-                                        pkcs7_ctx_get0_propq(ctx));
+    return SMIME_write_ASN1_ex(bio, (ASN1_VALUE *)p7, data, flags, ctype_nid,
+                               NID_undef, mdalgs, ASN1_ITEM_rptr(PKCS7),
+                               ossl_pkcs7_ctx_get0_libctx(ctx),
+                               ossl_pkcs7_ctx_get0_propq(ctx));
 }
 
 PKCS7 *SMIME_read_PKCS7_ex(BIO *bio, BIO **bcont, PKCS7 **p7)
 {
     PKCS7 *ret;
 
-    ret = (PKCS7 *)SMIME_read_ASN1_ex(bio, bcont, ASN1_ITEM_rptr(PKCS7),
+    ret = (PKCS7 *)SMIME_read_ASN1_ex(bio, 0, bcont, ASN1_ITEM_rptr(PKCS7),
                                       (ASN1_VALUE **)p7);
-    if (ret != NULL && p7 != NULL)
-        pkcs7_resolve_libctx(ret);
+    if (ret != NULL)
+        ossl_pkcs7_resolve_libctx(ret);
     return ret;
 }