44578448fc4a5b8876826bf1301ca29876bed9bf
[oweals/openssl.git] / crypto / serializer / serializer_local.h
1 /*
2  * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #include <openssl/core_numbers.h>
11 #include <openssl/types.h>
12 #include "internal/cryptlib.h"
13 #include "internal/refcount.h"
14
15 struct ossl_serializer_st {
16     OSSL_PROVIDER *prov;
17     int id;
18     const char *propdef;
19
20     CRYPTO_REF_COUNT refcnt;
21     CRYPTO_RWLOCK *lock;
22
23     OSSL_OP_serializer_newctx_fn *newctx;
24     OSSL_OP_serializer_freectx_fn *freectx;
25     OSSL_OP_serializer_set_ctx_params_fn *set_ctx_params;
26     OSSL_OP_serializer_settable_ctx_params_fn *settable_ctx_params;
27     OSSL_OP_serializer_serialize_data_fn *serialize_data;
28     OSSL_OP_serializer_serialize_object_fn *serialize_object;
29 };
30
31 struct ossl_serializer_ctx_st {
32     OSSL_SERIALIZER *ser;
33     void *serctx;
34
35     int selection;
36
37     /*
38      * |object| is the libcrypto object to handle.
39      * |do_output| must have intimate knowledge of this object.
40      */
41     const void *object;
42     int (*do_output)(OSSL_SERIALIZER_CTX *ctx, BIO *out);
43
44     /* For any function that needs a passphrase reader */
45     const UI_METHOD *ui_method;
46     void *ui_data;
47     /*
48      * if caller used OSSL_SERIALIZER_CTX_set_passphrase_cb(), we need
49      * intermediary storage.
50      */
51     UI_METHOD *allocated_ui_method;
52 };