1/*
2 * Copyright 2019 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
15struct 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
31struct ossl_serializer_ctx_st {
32 OSSL_SERIALIZER *ser;
33 void *serctx;
34
35 /*
36 * |object| is the libcrypto object to handle.
37 * |do_output| must have intimate knowledge of this object.
38 */
39 const void *object;
40 int (*do_output)(OSSL_SERIALIZER_CTX *ctx, BIO *out);
41
42 /* For any function that needs a passphrase reader */
43 const UI_METHOD *ui_method;
44 void *ui_data;
45 /*
46 * if caller used OSSL_SERIALIZER_CTX_set_passphrase_cb(), we need
47 * intermediary storage.
48 */
49 UI_METHOD *allocated_ui_method;
50};
51