]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/OSSL_SERIALIZER_CTX_new_by_EVP_PKEY.pod
Rename OSSL_SERIALIZER / OSSL_DESERIALIZER to OSSL_ENCODE / OSSL_DECODE
[thirdparty/openssl.git] / doc / man3 / OSSL_SERIALIZER_CTX_new_by_EVP_PKEY.pod
CommitLineData
866234ac
RL
1=pod
2
3=head1 NAME
4
5OSSL_SERIALIZER_CTX_new_by_EVP_PKEY,
6OSSL_SERIALIZER_CTX_set_cipher,
7OSSL_SERIALIZER_CTX_set_passphrase,
8OSSL_SERIALIZER_CTX_set_passphrase_cb,
9OSSL_SERIALIZER_CTX_set_passphrase_ui,
10OSSL_SERIALIZER_PUBKEY_TO_PEM_PQ,
11OSSL_SERIALIZER_PrivateKey_TO_PEM_PQ,
12OSSL_SERIALIZER_Parameters_TO_PEM_PQ,
9ea59241
RL
13OSSL_SERIALIZER_PUBKEY_TO_DER_PQ,
14OSSL_SERIALIZER_PrivateKey_TO_DER_PQ,
15OSSL_SERIALIZER_Parameters_TO_DER_PQ,
866234ac
RL
16OSSL_SERIALIZER_PUBKEY_TO_TEXT_PQ,
17OSSL_SERIALIZER_PrivateKey_TO_TEXT_PQ,
18OSSL_SERIALIZER_Parameters_TO_TEXT_PQ
19- Serializer routines to serialize EVP_PKEYs
20
21=head1 SYNOPSIS
22
23 #include <openssl/serializer.h>
24
25 OSSL_SERIALIZER_CTX *OSSL_SERIALIZER_CTX_new_by_EVP_PKEY(const EVP_PKEY *pkey,
26 const char *propquery);
27
28 int OSSL_SERIALIZER_CTX_set_cipher(OSSL_SERIALIZER_CTX *ctx,
29 const char *cipher_name,
30 const char *propquery);
31 int OSSL_SERIALIZER_CTX_set_passphrase(OSSL_SERIALIZER_CTX *ctx,
32 const unsigned char *kstr,
33 size_t klen);
45396db0 34 int OSSL_SERIALIZER_CTX_set_passphrase_cb(OSSL_SERIALIZER_CTX *ctx,
866234ac
RL
35 pem_password_cb *cb, void *cbarg);
36 int OSSL_SERIALIZER_CTX_set_passphrase_ui(OSSL_SERIALIZER_CTX *ctx,
37 const UI_METHOD *ui_method,
38 void *ui_data);
39
40 #define OSSL_SERIALIZER_PUBKEY_TO_PEM_PQ "format=pem,type=public"
41 #define OSSL_SERIALIZER_PrivateKey_TO_PEM_PQ "format=pem,type=private"
b305452f 42 #define OSSL_SERIALIZER_Parameters_TO_PEM_PQ "format=pem,type=parameters"
866234ac 43
9ea59241
RL
44 #define OSSL_SERIALIZER_PUBKEY_TO_DER_PQ "format=der,type=public"
45 #define OSSL_SERIALIZER_PrivateKey_TO_DER_PQ "format=der,type=private"
46 #define OSSL_SERIALIZER_Parameters_TO_DER_PQ "format=der,type=parameters"
47
866234ac
RL
48 #define OSSL_SERIALIZER_PUBKEY_TO_TEXT_PQ "format=text,type=public"
49 #define OSSL_SERIALIZER_PrivateKey_TO_TEXT_PQ "format=text,type=private"
b305452f 50 #define OSSL_SERIALIZER_Parameters_TO_TEXT_PQ "format=text,type=parameters"
866234ac
RL
51
52=head1 DESCRIPTION
53
54OSSL_SERIALIZER_CTX_new_by_EVP_PKEY() creates a B<OSSL_SERIALIZER_CTX>
55with a suitable attached output routine for B<EVP_PKEY>s. It will
56search for a serializer implementation that matches the algorithm of
57the B<EVP_PKEY> and the property query given with I<propquery>. It
58will prefer to find a serializer from the same provider as the key
59data of the B<EVP_PKEY> itself, but failing that, it will choose the
60first serializer that supplies a generic serializing function.
61
62If no suitable serializer was found, OSSL_SERIALIZER_CTX_new_by_EVP_PKEY()
63still creates a B<OSSL_SERIALIZER_CTX>, but with no associated
64serializer (L<OSSL_SERIALIZER_CTX_get_serializer(3)> returns NULL).
65This helps the caller distinguish between an error when creating
66the B<OSSL_SERIALIZER_CTX>, and the lack the serializer support and
67act accordingly.
68
69OSSL_SERIALIZER_CTX_set_cipher() tells the implementation what cipher
70should be used to encrypt serialized keys. The cipher is given by
71name I<cipher_name>. The interpretation of that I<cipher_name> is
72implementation dependent. The implementation may implement the digest
73directly itself or by other implementations, or it may choose to fetch
74it. If the implementation supports fetching the cipher, then it may
75use I<propquery> as properties to be queried for when fetching.
76I<cipher_name> may also be NULL, which will result in unencrypted
77serialization.
78
79OSSL_SERIALIZER_CTX_set_passphrase() gives the implementation a
80pass phrase to use when encrypting the serialized private key.
81Alternatively, a pass phrase callback may be specified with the
82following functions.
83
84OSSL_SERIALIZER_CTX_set_passphrase_cb() and
85OSSL_SERIALIZER_CTX_set_passphrase_ui() sets up a callback method that
86the implementation can use to prompt for a pass phrase.
87
88=for comment Note that the callback method is called indirectly,
89through an internal B<OSSL_PASSPHRASE_CALLBACK> function.
90
91The macros B<OSSL_SERIALIZER_PUBKEY_TO_PEM_PQ>,
92B<OSSL_SERIALIZER_PrivateKey_TO_PEM_PQ>,
93B<OSSL_SERIALIZER_Parameters_TO_PEM_PQ>,
9ea59241
RL
94B<OSSL_SERIALIZER_PUBKEY_TO_DER_PQ>,
95B<OSSL_SERIALIZER_PrivateKey_TO_DER_PQ>,
96B<OSSL_SERIALIZER_Parameters_TO_DER_PQ>,
866234ac
RL
97B<OSSL_SERIALIZER_PUBKEY_TO_TEXT_PQ>,
98B<OSSL_SERIALIZER_PrivateKey_TO_TEXT_PQ>,
99B<OSSL_SERIALIZER_Parameters_TO_TEXT_PQ> are convenience macros with
100property queries to serialize the B<EVP_PKEY> as a public key, private
9ea59241 101key or parameters to B<PEM>, to B<DER>, or to text.
866234ac
RL
102
103=head1 RETURN VALUES
104
105OSSL_SERIALIZER_CTX_new_by_EVP_PKEY() returns a pointer to a
106B<OSSL_SERIALIZER_CTX>, or NULL if it couldn't be created.
107
108OSSL_SERIALIZER_CTX_set_cipher(),
109OSSL_SERIALIZER_CTX_set_passphrase(),
110OSSL_SERIALIZER_CTX_set_passphrase_cb(), and
111OSSL_SERIALIZER_CTX_set_passphrase_ui() all return 1 on success, or 0
112on failure.
113
114=head1 NOTES
115
116Parts of the function and macro names are made to match already
117existing OpenSSL names.
118
119B<EVP_PKEY> in OSSL_SERIALIZER_CTX_new_by_EVP_PKEY() matches the type
120name, thus making for the naming pattern
121B<OSSL_SERIALIZER_CTX_new_by_I<TYPE>>() when new types are handled.
122
123B<PUBKEY>, B<PrivateKey> and B<Parameters> in the macro names match
8c1cbc72 124the B<I<TYPE>> part of B<PEM_write_bio_I<TYPE>> functions as well
866234ac
RL
125as B<i2d_I<TYPE>_bio> functions.
126
127=head1 SEE ALSO
128
129L<provider(7)>, L<OSSL_SERIALIZER(3)>, L<OSSL_SERIALIZER_CTX(3)>
130
131=head1 HISTORY
132
133The functions described here were added in OpenSSL 3.0.
134
135=head1 COPYRIGHT
136
33388b44 137Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
866234ac
RL
138
139Licensed under the Apache License 2.0 (the "License"). You may not use
140this file except in compliance with the License. You can obtain a copy
141in the file LICENSE in the source distribution or at
142L<https://www.openssl.org/source/license.html>.
143
144=cut