]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/serializer.h
Redesign the KEYMGMT libcrypto <-> provider interface - the basics
[thirdparty/openssl.git] / include / openssl / serializer.h
CommitLineData
0d003c52
RL
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>
866234ac 21# include <openssl/serializererr.h>
0d003c52
RL
22# include <openssl/types.h>
23# include <openssl/core.h>
24
25# ifdef __cplusplus
26extern "C" {
27# endif
28
29OSSL_SERIALIZER *OSSL_SERIALIZER_fetch(OPENSSL_CTX *libctx,
30 const char *name,
31 const char *properties);
32int OSSL_SERIALIZER_up_ref(OSSL_SERIALIZER *ser);
33void OSSL_SERIALIZER_free(OSSL_SERIALIZER *ser);
34
35const OSSL_PROVIDER *OSSL_SERIALIZER_provider(const OSSL_SERIALIZER *ser);
36const char *OSSL_SERIALIZER_properties(const OSSL_SERIALIZER *ser);
37int OSSL_SERIALIZER_number(const OSSL_SERIALIZER *ser);
38int OSSL_SERIALIZER_is_a(const OSSL_SERIALIZER *ser,
39 const char *name);
40
41void OSSL_SERIALIZER_do_all_provided(OPENSSL_CTX *libctx,
42 void (*fn)(OSSL_SERIALIZER *ser,
43 void *arg),
44 void *arg);
45void OSSL_SERIALIZER_names_do_all(const OSSL_SERIALIZER *ser,
46 void (*fn)(const char *name, void *data),
47 void *data);
48
49const OSSL_PARAM *OSSL_SERIALIZER_settable_ctx_params(OSSL_SERIALIZER *ser);
50OSSL_SERIALIZER_CTX *OSSL_SERIALIZER_CTX_new(OSSL_SERIALIZER *ser);
51const OSSL_SERIALIZER *
52OSSL_SERIALIZER_CTX_get_serializer(OSSL_SERIALIZER_CTX *ctx);
53int OSSL_SERIALIZER_CTX_set_params(OSSL_SERIALIZER_CTX *ctx,
54 const OSSL_PARAM params[]);
55void OSSL_SERIALIZER_CTX_free(OSSL_SERIALIZER_CTX *ctx);
56
866234ac
RL
57/* Utilities that help set specific parameters */
58int OSSL_SERIALIZER_CTX_set_cipher(OSSL_SERIALIZER_CTX *ctx,
59 const char *cipher_name,
60 const char *propquery);
61int OSSL_SERIALIZER_CTX_set_passphrase(OSSL_SERIALIZER_CTX *ctx,
62 const unsigned char *kstr,
63 size_t klen);
64int OSSL_SERIALIZER_CTX_set_passphrase_cb(OSSL_SERIALIZER_CTX *ctx, int enc,
65 pem_password_cb *cb, void *cbarg);
66int 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 */
71int OSSL_SERIALIZER_to_bio(OSSL_SERIALIZER_CTX *ctx, BIO *out);
72#ifndef OPENSSL_NO_STDIO
73int 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 */
81OSSL_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
RL
91
92/* Corresponding macros for text output */
93# define OSSL_SERIALIZER_PUBKEY_TO_TEXT_PQ "format=text,type=public"
94# define OSSL_SERIALIZER_PrivateKey_TO_TEXT_PQ "format=text,type=private"
b305452f 95# define OSSL_SERIALIZER_Parameters_TO_TEXT_PQ "format=text,type=parameters"
866234ac 96
0d003c52
RL
97# ifdef __cplusplus
98}
99# endif
100#endif