2 * Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
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
10 #ifndef OPENSSL_DESERIALIZER_H
11 # define OPENSSL_DESERIALIZER_H
14 # include <openssl/opensslconf.h>
16 # ifndef OPENSSL_NO_STDIO
21 # include <openssl/deserializererr.h>
22 # include <openssl/types.h>
23 # include <openssl/core.h>
29 OSSL_DESERIALIZER
*OSSL_DESERIALIZER_fetch(OPENSSL_CTX
*libctx
,
31 const char *properties
);
32 int OSSL_DESERIALIZER_up_ref(OSSL_DESERIALIZER
*ser
);
33 void OSSL_DESERIALIZER_free(OSSL_DESERIALIZER
*ser
);
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
,
41 void OSSL_DESERIALIZER_do_all_provided(OPENSSL_CTX
*libctx
,
42 void (*fn
)(OSSL_DESERIALIZER
*ser
,
45 void OSSL_DESERIALIZER_names_do_all(const OSSL_DESERIALIZER
*ser
,
46 void (*fn
)(const char *name
, 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
[]);
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
);
57 /* Utilities that help set specific parameters */
58 int OSSL_DESERIALIZER_CTX_set_passphrase(OSSL_DESERIALIZER_CTX
*ctx
,
59 const unsigned char *kstr
,
61 int OSSL_DESERIALIZER_CTX_set_pem_password_cb(OSSL_DESERIALIZER_CTX
*ctx
,
64 int OSSL_DESERIALIZER_CTX_set_passphrase_ui(OSSL_DESERIALIZER_CTX
*ctx
,
65 const UI_METHOD
*ui_method
,
69 * Utilities to read the object to deserialize, with the result sent to cb.
70 * These will discover all provided methods
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
);
81 typedef struct ossl_deserializer_instance_st OSSL_DESERIALIZER_INSTANCE
;
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
);
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
);
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
);
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
);
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
);
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.
117 OSSL_DESERIALIZER_CTX
*
118 OSSL_DESERIALIZER_CTX_new_by_EVP_PKEY(EVP_PKEY
**pkey
, const char *input_type
,
120 const char *propquery
);