]>
Commit | Line | Data |
---|---|---|
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 | |
26 | extern "C" { | |
27 | # endif | |
28 | ||
29 | OSSL_DESERIALIZER *OSSL_DESERIALIZER_fetch(OPENSSL_CTX *libctx, | |
30 | const char *name, | |
31 | const char *properties); | |
32 | int OSSL_DESERIALIZER_up_ref(OSSL_DESERIALIZER *ser); | |
33 | void OSSL_DESERIALIZER_free(OSSL_DESERIALIZER *ser); | |
34 | ||
35 | const OSSL_PROVIDER *OSSL_DESERIALIZER_provider(const OSSL_DESERIALIZER *ser); | |
36 | const char *OSSL_DESERIALIZER_properties(const OSSL_DESERIALIZER *ser); | |
37 | int OSSL_DESERIALIZER_number(const OSSL_DESERIALIZER *ser); | |
38 | int OSSL_DESERIALIZER_is_a(const OSSL_DESERIALIZER *ser, | |
39 | const char *name); | |
40 | ||
41 | void OSSL_DESERIALIZER_do_all_provided(OPENSSL_CTX *libctx, | |
42 | void (*fn)(OSSL_DESERIALIZER *ser, | |
43 | void *arg), | |
44 | void *arg); | |
45 | void OSSL_DESERIALIZER_names_do_all(const OSSL_DESERIALIZER *ser, | |
46 | void (*fn)(const char *name, void *data), | |
47 | void *data); | |
48 | const OSSL_PARAM *OSSL_DESERIALIZER_gettable_params(OSSL_DESERIALIZER *deser); | |
49 | int OSSL_DESERIALIZER_get_params(OSSL_DESERIALIZER *deser, OSSL_PARAM params[]); | |
50 | ||
51 | const OSSL_PARAM *OSSL_DESERIALIZER_settable_ctx_params(OSSL_DESERIALIZER *ser); | |
52 | OSSL_DESERIALIZER_CTX *OSSL_DESERIALIZER_CTX_new(void); | |
53 | int OSSL_DESERIALIZER_CTX_set_params(OSSL_DESERIALIZER_CTX *ctx, | |
54 | const OSSL_PARAM params[]); | |
55 | void OSSL_DESERIALIZER_CTX_free(OSSL_DESERIALIZER_CTX *ctx); | |
56 | ||
57 | /* Utilities that help set specific parameters */ | |
c3e4c1f3 RL |
58 | int OSSL_DESERIALIZER_CTX_set_passphrase(OSSL_DESERIALIZER_CTX *ctx, |
59 | const unsigned char *kstr, | |
60 | size_t klen); | |
4701f0a9 RL |
61 | int OSSL_DESERIALIZER_CTX_set_pem_password_cb(OSSL_DESERIALIZER_CTX *ctx, |
62 | pem_password_cb *cb, | |
63 | void *cbarg); | |
c3e4c1f3 RL |
64 | int 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 | ||
73 | int OSSL_DESERIALIZER_CTX_set_input_type(OSSL_DESERIALIZER_CTX *ctx, | |
74 | const char *input_type); | |
75 | int OSSL_DESERIALIZER_CTX_add_deserializer(OSSL_DESERIALIZER_CTX *ctx, | |
76 | OSSL_DESERIALIZER *deser); | |
77 | int OSSL_DESERIALIZER_CTX_add_extra(OSSL_DESERIALIZER_CTX *ctx, | |
78 | OPENSSL_CTX *libctx, const char *propq); | |
79 | int OSSL_DESERIALIZER_CTX_num_deserializers(OSSL_DESERIALIZER_CTX *ctx); | |
80 | ||
81 | typedef struct ossl_deserializer_instance_st OSSL_DESERIALIZER_INSTANCE; | |
3c033c5b RL |
82 | OSSL_DESERIALIZER *OSSL_DESERIALIZER_INSTANCE_deserializer |
83 | (OSSL_DESERIALIZER_INSTANCE *deser_inst); | |
84 | void *OSSL_DESERIALIZER_INSTANCE_deserializer_ctx | |
85 | (OSSL_DESERIALIZER_INSTANCE *deser_inst); | |
c3e4c1f3 | 86 | |
3c033c5b RL |
87 | typedef int (OSSL_DESERIALIZER_CONSTRUCT) |
88 | (OSSL_DESERIALIZER_INSTANCE *deser_inst, | |
89 | const OSSL_PARAM *params, void *construct_data); | |
90 | typedef void (OSSL_DESERIALIZER_CLEANUP)(void *construct_data); | |
91 | ||
92 | int OSSL_DESERIALIZER_CTX_set_construct(OSSL_DESERIALIZER_CTX *ctx, | |
93 | OSSL_DESERIALIZER_CONSTRUCT *construct); | |
94 | int OSSL_DESERIALIZER_CTX_set_construct_data(OSSL_DESERIALIZER_CTX *ctx, | |
95 | void *construct_data); | |
96 | int OSSL_DESERIALIZER_CTX_set_cleanup(OSSL_DESERIALIZER_CTX *ctx, | |
97 | OSSL_DESERIALIZER_CLEANUP *cleanup); | |
98 | OSSL_DESERIALIZER_CONSTRUCT * | |
99 | OSSL_DESERIALIZER_CTX_get_construct(OSSL_DESERIALIZER_CTX *ctx); | |
100 | void *OSSL_DESERIALIZER_CTX_get_construct_data(OSSL_DESERIALIZER_CTX *ctx); | |
101 | OSSL_DESERIALIZER_CLEANUP * | |
102 | OSSL_DESERIALIZER_CTX_get_cleanup(OSSL_DESERIALIZER_CTX *ctx); | |
c3e4c1f3 RL |
103 | |
104 | int 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 |
108 | int OSSL_DESERIALIZER_from_bio(OSSL_DESERIALIZER_CTX *ctx, BIO *in); |
109 | #ifndef OPENSSL_NO_STDIO | |
110 | int 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 | */ | |
117 | OSSL_DESERIALIZER_CTX * | |
118 | OSSL_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 |