]>
Commit | Line | Data |
---|---|---|
0d003c52 | 1 | /* |
33388b44 | 2 | * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved. |
0d003c52 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_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> | |
866234ac | 21 | # include <openssl/serializererr.h> |
0d003c52 RL |
22 | # include <openssl/types.h> |
23 | # include <openssl/core.h> | |
24 | ||
25 | # ifdef __cplusplus | |
26 | extern "C" { | |
27 | # endif | |
28 | ||
29 | OSSL_SERIALIZER *OSSL_SERIALIZER_fetch(OPENSSL_CTX *libctx, | |
30 | const char *name, | |
31 | const char *properties); | |
32 | int OSSL_SERIALIZER_up_ref(OSSL_SERIALIZER *ser); | |
33 | void OSSL_SERIALIZER_free(OSSL_SERIALIZER *ser); | |
34 | ||
35 | const OSSL_PROVIDER *OSSL_SERIALIZER_provider(const OSSL_SERIALIZER *ser); | |
36 | const char *OSSL_SERIALIZER_properties(const OSSL_SERIALIZER *ser); | |
37 | int OSSL_SERIALIZER_number(const OSSL_SERIALIZER *ser); | |
38 | int OSSL_SERIALIZER_is_a(const OSSL_SERIALIZER *ser, | |
39 | const char *name); | |
40 | ||
41 | void OSSL_SERIALIZER_do_all_provided(OPENSSL_CTX *libctx, | |
42 | void (*fn)(OSSL_SERIALIZER *ser, | |
43 | void *arg), | |
44 | void *arg); | |
45 | void OSSL_SERIALIZER_names_do_all(const OSSL_SERIALIZER *ser, | |
46 | void (*fn)(const char *name, void *data), | |
47 | void *data); | |
48 | ||
49 | const OSSL_PARAM *OSSL_SERIALIZER_settable_ctx_params(OSSL_SERIALIZER *ser); | |
50 | OSSL_SERIALIZER_CTX *OSSL_SERIALIZER_CTX_new(OSSL_SERIALIZER *ser); | |
51 | const OSSL_SERIALIZER * | |
52 | OSSL_SERIALIZER_CTX_get_serializer(OSSL_SERIALIZER_CTX *ctx); | |
53 | int OSSL_SERIALIZER_CTX_set_params(OSSL_SERIALIZER_CTX *ctx, | |
54 | const OSSL_PARAM params[]); | |
55 | void OSSL_SERIALIZER_CTX_free(OSSL_SERIALIZER_CTX *ctx); | |
56 | ||
866234ac RL |
57 | /* Utilities that help set specific parameters */ |
58 | int OSSL_SERIALIZER_CTX_set_cipher(OSSL_SERIALIZER_CTX *ctx, | |
59 | const char *cipher_name, | |
60 | const char *propquery); | |
61 | int OSSL_SERIALIZER_CTX_set_passphrase(OSSL_SERIALIZER_CTX *ctx, | |
62 | const unsigned char *kstr, | |
63 | size_t klen); | |
45396db0 | 64 | int OSSL_SERIALIZER_CTX_set_passphrase_cb(OSSL_SERIALIZER_CTX *ctx, |
866234ac RL |
65 | pem_password_cb *cb, void *cbarg); |
66 | int OSSL_SERIALIZER_CTX_set_passphrase_ui(OSSL_SERIALIZER_CTX *ctx, | |
67 | const UI_METHOD *ui_method, | |
68 | void *ui_data); | |
69 | ||
742496f1 RL |
70 | /* Utilities to output the object to serialize */ |
71 | int OSSL_SERIALIZER_to_bio(OSSL_SERIALIZER_CTX *ctx, BIO *out); | |
72 | #ifndef OPENSSL_NO_STDIO | |
73 | int OSSL_SERIALIZER_to_fp(OSSL_SERIALIZER_CTX *ctx, FILE *fp); | |
74 | #endif | |
75 | ||
866234ac RL |
76 | /* |
77 | * Create the OSSL_SERIALIZER_CTX with an associated type. This will perform | |
78 | * an implicit OSSL_SERIALIZER_fetch(), suitable for the object of that type. | |
79 | * This is more useful than calling OSSL_SERIALIZER_CTX_new(). | |
80 | */ | |
81 | OSSL_SERIALIZER_CTX *OSSL_SERIALIZER_CTX_new_by_EVP_PKEY(const EVP_PKEY *pkey, | |
82 | const char *propquery); | |
83 | ||
84 | /* | |
85 | * These macros define the last argument to pass to | |
86 | * OSSL_SERIALIZER_CTX_new_by_TYPE(). | |
87 | */ | |
88 | # define OSSL_SERIALIZER_PUBKEY_TO_PEM_PQ "format=pem,type=public" | |
89 | # define OSSL_SERIALIZER_PrivateKey_TO_PEM_PQ "format=pem,type=private" | |
b305452f | 90 | # define OSSL_SERIALIZER_Parameters_TO_PEM_PQ "format=pem,type=parameters" |
866234ac | 91 | |
4b1aa164 RL |
92 | # define OSSL_SERIALIZER_PUBKEY_TO_DER_PQ "format=der,type=public" |
93 | # define OSSL_SERIALIZER_PrivateKey_TO_DER_PQ "format=der,type=private" | |
94 | # define OSSL_SERIALIZER_Parameters_TO_DER_PQ "format=der,type=parameters" | |
95 | ||
866234ac RL |
96 | /* Corresponding macros for text output */ |
97 | # define OSSL_SERIALIZER_PUBKEY_TO_TEXT_PQ "format=text,type=public" | |
98 | # define OSSL_SERIALIZER_PrivateKey_TO_TEXT_PQ "format=text,type=private" | |
b305452f | 99 | # define OSSL_SERIALIZER_Parameters_TO_TEXT_PQ "format=text,type=parameters" |
866234ac | 100 | |
0d003c52 RL |
101 | # ifdef __cplusplus |
102 | } | |
103 | # endif | |
104 | #endif |