SERIALIZER: add functions for serialization to file
[openssl.git] / include / openssl / serializer.h
1 /*
2  * Copyright 2019 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_SERIALIZER_H
11 # define OPENSSL_SERIALIZER_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/types.h>
22 # include <openssl/core.h>
23
24 # ifdef __cplusplus
25 extern "C" {
26 # endif
27
28 OSSL_SERIALIZER *OSSL_SERIALIZER_fetch(OPENSSL_CTX *libctx,
29                                        const char *name,
30                                        const char *properties);
31 int OSSL_SERIALIZER_up_ref(OSSL_SERIALIZER *ser);
32 void OSSL_SERIALIZER_free(OSSL_SERIALIZER *ser);
33
34 const OSSL_PROVIDER *OSSL_SERIALIZER_provider(const OSSL_SERIALIZER *ser);
35 const char *OSSL_SERIALIZER_properties(const OSSL_SERIALIZER *ser);
36 int OSSL_SERIALIZER_number(const OSSL_SERIALIZER *ser);
37 int OSSL_SERIALIZER_is_a(const OSSL_SERIALIZER *ser,
38                          const char *name);
39
40 void OSSL_SERIALIZER_do_all_provided(OPENSSL_CTX *libctx,
41                                      void (*fn)(OSSL_SERIALIZER *ser,
42                                                 void *arg),
43                                      void *arg);
44 void OSSL_SERIALIZER_names_do_all(const OSSL_SERIALIZER *ser,
45                                   void (*fn)(const char *name, void *data),
46                                   void *data);
47
48 const OSSL_PARAM *OSSL_SERIALIZER_settable_ctx_params(OSSL_SERIALIZER *ser);
49 OSSL_SERIALIZER_CTX *OSSL_SERIALIZER_CTX_new(OSSL_SERIALIZER *ser);
50 const OSSL_SERIALIZER *
51 OSSL_SERIALIZER_CTX_get_serializer(OSSL_SERIALIZER_CTX *ctx);
52 int OSSL_SERIALIZER_CTX_set_params(OSSL_SERIALIZER_CTX *ctx,
53                                    const OSSL_PARAM params[]);
54 void OSSL_SERIALIZER_CTX_free(OSSL_SERIALIZER_CTX *ctx);
55
56 /* Utilities to output the object to serialize */
57 int OSSL_SERIALIZER_to_bio(OSSL_SERIALIZER_CTX *ctx, BIO *out);
58 #ifndef OPENSSL_NO_STDIO
59 int OSSL_SERIALIZER_to_fp(OSSL_SERIALIZER_CTX *ctx, FILE *fp);
60 #endif
61
62 # ifdef __cplusplus
63 }
64 # endif
65 #endif