]>
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 */ | |
58 | int OSSL_DESERIALIZER_CTX_set_cipher(OSSL_DESERIALIZER_CTX *ctx, | |
59 | const char *cipher_name, | |
60 | const char *propquery); | |
61 | int OSSL_DESERIALIZER_CTX_set_passphrase(OSSL_DESERIALIZER_CTX *ctx, | |
62 | const unsigned char *kstr, | |
63 | size_t klen); | |
45396db0 | 64 | int OSSL_DESERIALIZER_CTX_set_passphrase_cb(OSSL_DESERIALIZER_CTX *ctx, |
c3e4c1f3 RL |
65 | pem_password_cb *cb, void *cbarg); |
66 | int OSSL_DESERIALIZER_CTX_set_passphrase_ui(OSSL_DESERIALIZER_CTX *ctx, | |
67 | const UI_METHOD *ui_method, | |
68 | void *ui_data); | |
69 | ||
70 | /* | |
71 | * Utilities to read the object to deserialize, with the result sent to cb. | |
72 | * These will discover all provided methods | |
73 | */ | |
74 | ||
75 | int OSSL_DESERIALIZER_CTX_set_input_type(OSSL_DESERIALIZER_CTX *ctx, | |
76 | const char *input_type); | |
77 | int OSSL_DESERIALIZER_CTX_add_deserializer(OSSL_DESERIALIZER_CTX *ctx, | |
78 | OSSL_DESERIALIZER *deser); | |
79 | int OSSL_DESERIALIZER_CTX_add_extra(OSSL_DESERIALIZER_CTX *ctx, | |
80 | OPENSSL_CTX *libctx, const char *propq); | |
81 | int OSSL_DESERIALIZER_CTX_num_deserializers(OSSL_DESERIALIZER_CTX *ctx); | |
82 | ||
83 | typedef struct ossl_deserializer_instance_st OSSL_DESERIALIZER_INSTANCE; | |
84 | typedef int (OSSL_DESERIALIZER_FINALIZER) | |
85 | (OSSL_DESERIALIZER_INSTANCE *deser_inst, | |
86 | const OSSL_PARAM *params, void *finalize_arg); | |
87 | typedef void (OSSL_DESERIALIZER_CLEANER)(void *finalize_arg); | |
88 | ||
89 | int OSSL_DESERIALIZER_CTX_set_finalizer(OSSL_DESERIALIZER_CTX *ctx, | |
90 | OSSL_DESERIALIZER_FINALIZER *finalizer, | |
91 | OSSL_DESERIALIZER_CLEANER *cleaner, | |
92 | void *finalize_arg); | |
93 | ||
94 | int OSSL_DESERIALIZER_export(OSSL_DESERIALIZER_INSTANCE *deser_inst, | |
95 | void *reference, size_t reference_sz, | |
96 | OSSL_CALLBACK *export_cb, void *export_cbarg); | |
97 | ||
98 | OSSL_DESERIALIZER *OSSL_DESERIALIZER_INSTANCE_deserializer | |
99 | (OSSL_DESERIALIZER_INSTANCE *deser_inst); | |
100 | void *OSSL_DESERIALIZER_INSTANCE_deserializer_ctx | |
101 | (OSSL_DESERIALIZER_INSTANCE *deser_inst); | |
102 | ||
103 | int OSSL_DESERIALIZER_from_bio(OSSL_DESERIALIZER_CTX *ctx, BIO *in); | |
104 | #ifndef OPENSSL_NO_STDIO | |
105 | int OSSL_DESERIALIZER_from_fp(OSSL_DESERIALIZER_CTX *ctx, FILE *in); | |
106 | #endif | |
107 | ||
072a9fde RL |
108 | /* |
109 | * Create the OSSL_DESERIALIZER_CTX with an associated type. This will perform | |
110 | * an implicit OSSL_DESERIALIZER_fetch(), suitable for the object of that type. | |
111 | */ | |
112 | OSSL_DESERIALIZER_CTX * | |
113 | OSSL_DESERIALIZER_CTX_new_by_EVP_PKEY(EVP_PKEY **pkey, const char *input_type, | |
114 | OPENSSL_CTX *libctx, | |
115 | const char *propquery); | |
116 | ||
c3e4c1f3 RL |
117 | # ifdef __cplusplus |
118 | } | |
119 | # endif | |
120 | #endif |