]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/decoder.h
errors: update error message (to be squashed)
[thirdparty/openssl.git] / include / openssl / decoder.h
CommitLineData
ece9304c 1/*
a28d06f3 2 * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
ece9304c
RL
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_DECODER_H
11# define OPENSSL_DECODER_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/decodererr.h>
22# include <openssl/types.h>
23# include <openssl/core.h>
24
25# ifdef __cplusplus
26extern "C" {
27# endif
28
b4250010 29OSSL_DECODER *OSSL_DECODER_fetch(OSSL_LIB_CTX *libctx, const char *name,
ece9304c
RL
30 const char *properties);
31int OSSL_DECODER_up_ref(OSSL_DECODER *encoder);
32void OSSL_DECODER_free(OSSL_DECODER *encoder);
33
34const OSSL_PROVIDER *OSSL_DECODER_provider(const OSSL_DECODER *encoder);
35const char *OSSL_DECODER_properties(const OSSL_DECODER *encoder);
36int OSSL_DECODER_number(const OSSL_DECODER *encoder);
49664117 37const char *OSSL_DECODER_name(const OSSL_DECODER *decoder);
1010884e 38const char *OSSL_DECODER_description(const OSSL_DECODER *decoder);
ece9304c
RL
39int OSSL_DECODER_is_a(const OSSL_DECODER *encoder, const char *name);
40
b4250010 41void OSSL_DECODER_do_all_provided(OSSL_LIB_CTX *libctx,
ece9304c
RL
42 void (*fn)(OSSL_DECODER *encoder, void *arg),
43 void *arg);
d84f5515
MC
44int OSSL_DECODER_names_do_all(const OSSL_DECODER *encoder,
45 void (*fn)(const char *name, void *data),
46 void *data);
ece9304c
RL
47const OSSL_PARAM *OSSL_DECODER_gettable_params(OSSL_DECODER *decoder);
48int OSSL_DECODER_get_params(OSSL_DECODER *decoder, OSSL_PARAM params[]);
49
50const OSSL_PARAM *OSSL_DECODER_settable_ctx_params(OSSL_DECODER *encoder);
51OSSL_DECODER_CTX *OSSL_DECODER_CTX_new(void);
52int OSSL_DECODER_CTX_set_params(OSSL_DECODER_CTX *ctx,
53 const OSSL_PARAM params[]);
54void OSSL_DECODER_CTX_free(OSSL_DECODER_CTX *ctx);
55
56/* Utilities that help set specific parameters */
57int OSSL_DECODER_CTX_set_passphrase(OSSL_DECODER_CTX *ctx,
48b62fb3 58 const unsigned char *kstr, size_t klen);
ece9304c 59int OSSL_DECODER_CTX_set_pem_password_cb(OSSL_DECODER_CTX *ctx,
48b62fb3 60 pem_password_cb *cb, void *cbarg);
4fd39782
RL
61int OSSL_DECODER_CTX_set_passphrase_cb(OSSL_DECODER_CTX *ctx,
62 OSSL_PASSPHRASE_CALLBACK *cb,
63 void *cbarg);
ece9304c
RL
64int OSSL_DECODER_CTX_set_passphrase_ui(OSSL_DECODER_CTX *ctx,
65 const UI_METHOD *ui_method,
66 void *ui_data);
67
68/*
69 * Utilities to read the object to decode, with the result sent to cb.
70 * These will discover all provided methods
71 */
72
ebfdb63d 73int OSSL_DECODER_CTX_set_selection(OSSL_DECODER_CTX *ctx, int selection);
ece9304c
RL
74int OSSL_DECODER_CTX_set_input_type(OSSL_DECODER_CTX *ctx,
75 const char *input_type);
ebfdb63d
RL
76int OSSL_DECODER_CTX_set_input_structure(OSSL_DECODER_CTX *ctx,
77 const char *input_structure);
ece9304c
RL
78int OSSL_DECODER_CTX_add_decoder(OSSL_DECODER_CTX *ctx, OSSL_DECODER *decoder);
79int OSSL_DECODER_CTX_add_extra(OSSL_DECODER_CTX *ctx,
b4250010 80 OSSL_LIB_CTX *libctx, const char *propq);
48b62fb3 81int OSSL_DECODER_CTX_get_num_decoders(OSSL_DECODER_CTX *ctx);
ece9304c
RL
82
83typedef struct ossl_decoder_instance_st OSSL_DECODER_INSTANCE;
84OSSL_DECODER *
48b62fb3
RL
85OSSL_DECODER_INSTANCE_get_decoder(OSSL_DECODER_INSTANCE *decoder_inst);
86void *
87OSSL_DECODER_INSTANCE_get_decoder_ctx(OSSL_DECODER_INSTANCE *decoder_inst);
88const char *
89OSSL_DECODER_INSTANCE_get_input_type(OSSL_DECODER_INSTANCE *decoder_inst);
ebfdb63d
RL
90const char *
91OSSL_DECODER_INSTANCE_get_input_structure(OSSL_DECODER_INSTANCE *decoder_inst,
92 int *was_set);
ece9304c 93
48b62fb3
RL
94typedef int OSSL_DECODER_CONSTRUCT(OSSL_DECODER_INSTANCE *decoder_inst,
95 const OSSL_PARAM *params,
96 void *construct_data);
97typedef void OSSL_DECODER_CLEANUP(void *construct_data);
ece9304c
RL
98
99int OSSL_DECODER_CTX_set_construct(OSSL_DECODER_CTX *ctx,
100 OSSL_DECODER_CONSTRUCT *construct);
101int OSSL_DECODER_CTX_set_construct_data(OSSL_DECODER_CTX *ctx,
102 void *construct_data);
103int OSSL_DECODER_CTX_set_cleanup(OSSL_DECODER_CTX *ctx,
104 OSSL_DECODER_CLEANUP *cleanup);
105OSSL_DECODER_CONSTRUCT *OSSL_DECODER_CTX_get_construct(OSSL_DECODER_CTX *ctx);
106void *OSSL_DECODER_CTX_get_construct_data(OSSL_DECODER_CTX *ctx);
107OSSL_DECODER_CLEANUP *OSSL_DECODER_CTX_get_cleanup(OSSL_DECODER_CTX *ctx);
108
109int OSSL_DECODER_export(OSSL_DECODER_INSTANCE *decoder_inst,
110 void *reference, size_t reference_sz,
111 OSSL_CALLBACK *export_cb, void *export_cbarg);
112
113int OSSL_DECODER_from_bio(OSSL_DECODER_CTX *ctx, BIO *in);
114#ifndef OPENSSL_NO_STDIO
115int OSSL_DECODER_from_fp(OSSL_DECODER_CTX *ctx, FILE *in);
116#endif
25cf949f
RL
117int OSSL_DECODER_from_data(OSSL_DECODER_CTX *ctx, const unsigned char **pdata,
118 size_t *pdata_len);
ece9304c
RL
119
120/*
121 * Create the OSSL_DECODER_CTX with an associated type. This will perform
122 * an implicit OSSL_DECODER_fetch(), suitable for the object of that type.
123 */
124OSSL_DECODER_CTX *
fe75766c
TM
125OSSL_DECODER_CTX_new_for_pkey(EVP_PKEY **pkey,
126 const char *input_type,
127 const char *input_struct,
128 const char *keytype, int selection,
129 OSSL_LIB_CTX *libctx, const char *propquery);
ece9304c
RL
130
131# ifdef __cplusplus
132}
133# endif
134#endif