]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/deserializer.h
Rename OSSL_SERIALIZER / OSSL_DESERIALIZER to OSSL_ENCODE / OSSL_DECODE
[thirdparty/openssl.git] / include / openssl / deserializer.h
CommitLineData
c3e4c1f3
RL
1/*
2 * Copyright 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#ifndef OPENSSL_DESERIALIZER_H
11# define OPENSSL_DESERIALIZER_H
12# pragma once
13
14# include <openssl/opensslconf.h>
15
16# ifndef OPENSSL_NO_STDIO
17# include <stdio.h>
18# endif
19# include <stdarg.h>
20# include <stddef.h>
21# include <openssl/deserializererr.h>
22# include <openssl/types.h>
23# include <openssl/core.h>
24
25# ifdef __cplusplus
26extern "C" {
27# endif
28
29OSSL_DESERIALIZER *OSSL_DESERIALIZER_fetch(OPENSSL_CTX *libctx,
30 const char *name,
31 const char *properties);
32int OSSL_DESERIALIZER_up_ref(OSSL_DESERIALIZER *ser);
33void OSSL_DESERIALIZER_free(OSSL_DESERIALIZER *ser);
34
35const OSSL_PROVIDER *OSSL_DESERIALIZER_provider(const OSSL_DESERIALIZER *ser);
36const char *OSSL_DESERIALIZER_properties(const OSSL_DESERIALIZER *ser);
37int OSSL_DESERIALIZER_number(const OSSL_DESERIALIZER *ser);
38int OSSL_DESERIALIZER_is_a(const OSSL_DESERIALIZER *ser,
39 const char *name);
40
41void OSSL_DESERIALIZER_do_all_provided(OPENSSL_CTX *libctx,
42 void (*fn)(OSSL_DESERIALIZER *ser,
43 void *arg),
44 void *arg);
45void OSSL_DESERIALIZER_names_do_all(const OSSL_DESERIALIZER *ser,
46 void (*fn)(const char *name, void *data),
47 void *data);
48const OSSL_PARAM *OSSL_DESERIALIZER_gettable_params(OSSL_DESERIALIZER *deser);
49int OSSL_DESERIALIZER_get_params(OSSL_DESERIALIZER *deser, OSSL_PARAM params[]);
50
51const OSSL_PARAM *OSSL_DESERIALIZER_settable_ctx_params(OSSL_DESERIALIZER *ser);
52OSSL_DESERIALIZER_CTX *OSSL_DESERIALIZER_CTX_new(void);
53int OSSL_DESERIALIZER_CTX_set_params(OSSL_DESERIALIZER_CTX *ctx,
54 const OSSL_PARAM params[]);
55void OSSL_DESERIALIZER_CTX_free(OSSL_DESERIALIZER_CTX *ctx);
56
57/* Utilities that help set specific parameters */
c3e4c1f3
RL
58int OSSL_DESERIALIZER_CTX_set_passphrase(OSSL_DESERIALIZER_CTX *ctx,
59 const unsigned char *kstr,
60 size_t klen);
4701f0a9
RL
61int OSSL_DESERIALIZER_CTX_set_pem_password_cb(OSSL_DESERIALIZER_CTX *ctx,
62 pem_password_cb *cb,
63 void *cbarg);
c3e4c1f3
RL
64int OSSL_DESERIALIZER_CTX_set_passphrase_ui(OSSL_DESERIALIZER_CTX *ctx,
65 const UI_METHOD *ui_method,
66 void *ui_data);
67
68/*
69 * Utilities to read the object to deserialize, with the result sent to cb.
70 * These will discover all provided methods
71 */
72
73int OSSL_DESERIALIZER_CTX_set_input_type(OSSL_DESERIALIZER_CTX *ctx,
74 const char *input_type);
75int OSSL_DESERIALIZER_CTX_add_deserializer(OSSL_DESERIALIZER_CTX *ctx,
76 OSSL_DESERIALIZER *deser);
77int OSSL_DESERIALIZER_CTX_add_extra(OSSL_DESERIALIZER_CTX *ctx,
78 OPENSSL_CTX *libctx, const char *propq);
79int OSSL_DESERIALIZER_CTX_num_deserializers(OSSL_DESERIALIZER_CTX *ctx);
80
81typedef struct ossl_deserializer_instance_st OSSL_DESERIALIZER_INSTANCE;
3c033c5b
RL
82OSSL_DESERIALIZER *OSSL_DESERIALIZER_INSTANCE_deserializer
83 (OSSL_DESERIALIZER_INSTANCE *deser_inst);
84void *OSSL_DESERIALIZER_INSTANCE_deserializer_ctx
85 (OSSL_DESERIALIZER_INSTANCE *deser_inst);
c3e4c1f3 86
3c033c5b
RL
87typedef int (OSSL_DESERIALIZER_CONSTRUCT)
88 (OSSL_DESERIALIZER_INSTANCE *deser_inst,
89 const OSSL_PARAM *params, void *construct_data);
90typedef void (OSSL_DESERIALIZER_CLEANUP)(void *construct_data);
91
92int OSSL_DESERIALIZER_CTX_set_construct(OSSL_DESERIALIZER_CTX *ctx,
93 OSSL_DESERIALIZER_CONSTRUCT *construct);
94int OSSL_DESERIALIZER_CTX_set_construct_data(OSSL_DESERIALIZER_CTX *ctx,
95 void *construct_data);
96int OSSL_DESERIALIZER_CTX_set_cleanup(OSSL_DESERIALIZER_CTX *ctx,
97 OSSL_DESERIALIZER_CLEANUP *cleanup);
98OSSL_DESERIALIZER_CONSTRUCT *
99OSSL_DESERIALIZER_CTX_get_construct(OSSL_DESERIALIZER_CTX *ctx);
100void *OSSL_DESERIALIZER_CTX_get_construct_data(OSSL_DESERIALIZER_CTX *ctx);
101OSSL_DESERIALIZER_CLEANUP *
102OSSL_DESERIALIZER_CTX_get_cleanup(OSSL_DESERIALIZER_CTX *ctx);
c3e4c1f3
RL
103
104int OSSL_DESERIALIZER_export(OSSL_DESERIALIZER_INSTANCE *deser_inst,
105 void *reference, size_t reference_sz,
106 OSSL_CALLBACK *export_cb, void *export_cbarg);
107
c3e4c1f3
RL
108int OSSL_DESERIALIZER_from_bio(OSSL_DESERIALIZER_CTX *ctx, BIO *in);
109#ifndef OPENSSL_NO_STDIO
110int OSSL_DESERIALIZER_from_fp(OSSL_DESERIALIZER_CTX *ctx, FILE *in);
111#endif
112
072a9fde
RL
113/*
114 * Create the OSSL_DESERIALIZER_CTX with an associated type. This will perform
115 * an implicit OSSL_DESERIALIZER_fetch(), suitable for the object of that type.
116 */
117OSSL_DESERIALIZER_CTX *
118OSSL_DESERIALIZER_CTX_new_by_EVP_PKEY(EVP_PKEY **pkey, const char *input_type,
119 OPENSSL_CTX *libctx,
120 const char *propquery);
121
c3e4c1f3
RL
122# ifdef __cplusplus
123}
124# endif
125#endif