Make the naming scheme for dispatched functions more consistent
[oweals/openssl.git] / providers / implementations / serializers / serializer_dsa_param.c
index 59549887af10f8a2a5a7edf693321da6db506723..fff577df3983502a92f132b52139b74993ae46ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2019-2020 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
@@ -7,7 +7,13 @@
  * https://www.openssl.org/source/license.html
  */
 
-#include <openssl/core_numbers.h>
+/*
+ * DSA low level APIs are deprecated for public use, but still ok for
+ * internal use.
+ */
+#include "internal/deprecated.h"
+
+#include <openssl/core_dispatch.h>
 #include <openssl/pem.h>
 #include <openssl/dsa.h>
 #include <openssl/types.h>
 #include "prov/bio.h"
 #include "prov/implementations.h"
 #include "prov/providercommonerr.h"
+#include "prov/provider_ctx.h"
 #include "serializer_local.h"
 
-static OSSL_OP_serializer_newctx_fn dsa_param_newctx;
-static OSSL_OP_serializer_freectx_fn dsa_param_freectx;
-static OSSL_OP_serializer_serialize_data_fn dsa_param_der_data;
-static OSSL_OP_serializer_serialize_object_fn dsa_param_der;
-static OSSL_OP_serializer_serialize_data_fn dsa_param_pem_data;
-static OSSL_OP_serializer_serialize_object_fn dsa_param_pem;
+static OSSL_FUNC_serializer_newctx_fn dsa_param_newctx;
+static OSSL_FUNC_serializer_freectx_fn dsa_param_freectx;
+static OSSL_FUNC_serializer_serialize_data_fn dsa_param_der_data;
+static OSSL_FUNC_serializer_serialize_object_fn dsa_param_der;
+static OSSL_FUNC_serializer_serialize_data_fn dsa_param_pem_data;
+static OSSL_FUNC_serializer_serialize_object_fn dsa_param_pem;
 
-static OSSL_OP_serializer_serialize_data_fn dsa_param_print_data;
-static OSSL_OP_serializer_serialize_object_fn dsa_param_print;
+static OSSL_FUNC_serializer_serialize_data_fn dsa_param_print_data;
+static OSSL_FUNC_serializer_serialize_object_fn dsa_param_print;
 
 /* Parameters : context */
 
@@ -42,12 +49,13 @@ static void dsa_param_freectx(void *ctx)
 }
 
 /* Public key : DER */
-static int dsa_param_der_data(void *ctx, const OSSL_PARAM params[], BIO *out,
+static int dsa_param_der_data(void *ctx, const OSSL_PARAM params[],
+                              OSSL_CORE_BIO *out,
                               OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)
 {
-    OSSL_OP_keymgmt_new_fn *dsa_new = ossl_prov_get_keymgmt_dsa_new();
-    OSSL_OP_keymgmt_free_fn *dsa_free = ossl_prov_get_keymgmt_dsa_free();
-    OSSL_OP_keymgmt_import_fn *dsa_import = ossl_prov_get_keymgmt_dsa_import();
+    OSSL_FUNC_keymgmt_new_fn *dsa_new = ossl_prov_get_keymgmt_dsa_new();
+    OSSL_FUNC_keymgmt_free_fn *dsa_free = ossl_prov_get_keymgmt_dsa_free();
+    OSSL_FUNC_keymgmt_import_fn *dsa_import = ossl_prov_get_keymgmt_dsa_import();
     int ok = 0;
 
     if (dsa_import != NULL) {
@@ -63,19 +71,29 @@ static int dsa_param_der_data(void *ctx, const OSSL_PARAM params[], BIO *out,
     return ok;
 }
 
-static int dsa_param_der(void *ctx, void *dsa, BIO *out,
+static int dsa_param_der(void *ctx, void *dsa, OSSL_CORE_BIO *cout,
                          OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)
 {
-    return i2d_DSAparams_bio(out, dsa);
+    BIO *out = bio_new_from_core_bio(ctx, cout);
+    int ret;
+
+    if (out == NULL)
+        return 0;
+
+    ret = i2d_DSAparams_bio(out, dsa);
+    BIO_free(out);
+
+    return ret;
 }
 
 /* Public key : PEM */
-static int dsa_param_pem_data(void *ctx, const OSSL_PARAM params[], BIO *out,
+static int dsa_param_pem_data(void *ctx, const OSSL_PARAM params[],
+                              OSSL_CORE_BIO *out,
                               OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)
 {
-    OSSL_OP_keymgmt_new_fn *dsa_new = ossl_prov_get_keymgmt_dsa_new();
-    OSSL_OP_keymgmt_free_fn *dsa_free = ossl_prov_get_keymgmt_dsa_free();
-    OSSL_OP_keymgmt_import_fn *dsa_import = ossl_prov_get_keymgmt_dsa_import();
+    OSSL_FUNC_keymgmt_new_fn *dsa_new = ossl_prov_get_keymgmt_dsa_new();
+    OSSL_FUNC_keymgmt_free_fn *dsa_free = ossl_prov_get_keymgmt_dsa_free();
+    OSSL_FUNC_keymgmt_import_fn *dsa_import = ossl_prov_get_keymgmt_dsa_import();
     int ok = 0;
 
     if (dsa_import != NULL) {
@@ -91,18 +109,28 @@ static int dsa_param_pem_data(void *ctx, const OSSL_PARAM params[], BIO *out,
     return ok;
 }
 
-static int dsa_param_pem(void *ctx, void *dsa, BIO *out,
+static int dsa_param_pem(void *ctx, void *dsa, OSSL_CORE_BIO *cout,
                          OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)
 {
-    return PEM_write_bio_DSAparams(out, dsa);
+    BIO *out = bio_new_from_core_bio(ctx, cout);
+    int ret;
+
+    if (out == NULL)
+        return 0;
+
+    ret = PEM_write_bio_DSAparams(out, dsa);
+    BIO_free(out);
+
+    return ret;
 }
 
-static int dsa_param_print_data(void *ctx, const OSSL_PARAM params[], BIO *out,
+static int dsa_param_print_data(void *ctx, const OSSL_PARAM params[],
+                                OSSL_CORE_BIO *out,
                                 OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)
 {
-    OSSL_OP_keymgmt_new_fn *dsa_new = ossl_prov_get_keymgmt_dsa_new();
-    OSSL_OP_keymgmt_free_fn *dsa_free = ossl_prov_get_keymgmt_dsa_free();
-    OSSL_OP_keymgmt_import_fn *dsa_import = ossl_prov_get_keymgmt_dsa_import();
+    OSSL_FUNC_keymgmt_new_fn *dsa_new = ossl_prov_get_keymgmt_dsa_new();
+    OSSL_FUNC_keymgmt_free_fn *dsa_free = ossl_prov_get_keymgmt_dsa_free();
+    OSSL_FUNC_keymgmt_import_fn *dsa_import = ossl_prov_get_keymgmt_dsa_import();
     int ok = 0;
 
     if (dsa_import != NULL) {
@@ -118,10 +146,19 @@ static int dsa_param_print_data(void *ctx, const OSSL_PARAM params[], BIO *out,
     return ok;
 }
 
-static int dsa_param_print(void *ctx, void *dsa, BIO *out,
+static int dsa_param_print(void *ctx, void *dsa, OSSL_CORE_BIO *cout,
                            OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)
 {
-    return ossl_prov_print_dsa(out, dsa, dsa_print_params);
+    BIO *out = bio_new_from_core_bio(ctx, cout);
+    int ret;
+
+    if (out == NULL)
+        return 0;
+
+    ret = ossl_prov_print_dsa(out, dsa, dsa_print_params);
+    BIO_free(out);
+
+    return ret;
 }
 
 const OSSL_DISPATCH dsa_param_der_serializer_functions[] = {