5 OSSL_ENCODER_CTX_new_by_EVP_PKEY,
6 OSSL_ENCODER_CTX_set_cipher,
7 OSSL_ENCODER_CTX_set_passphrase,
8 OSSL_ENCODER_CTX_set_pem_password_cb,
9 OSSL_ENCODER_CTX_set_passphrase_cb,
10 OSSL_ENCODER_CTX_set_passphrase_ui
11 - Encoder routines to encode EVP_PKEYs
15 #include <openssl/encoder.h>
18 OSSL_ENCODER_CTX_new_by_EVP_PKEY(const EVP_PKEY *pkey,
19 const char *output_type, int selection,
20 OPENSSL_CTX *libctx, const char *propquery);
22 int OSSL_ENCODER_CTX_set_cipher(OSSL_ENCODER_CTX *ctx,
23 const char *cipher_name,
24 const char *propquery);
25 int OSSL_ENCODER_CTX_set_passphrase(OSSL_ENCODER_CTX *ctx,
26 const unsigned char *kstr,
28 int OSSL_ENCODER_CTX_set_pem_password_cb(OSSL_ENCODER_CTX *ctx,
29 pem_password_cb *cb, void *cbarg);
30 int OSSL_ENCODER_CTX_set_passphrase_ui(OSSL_ENCODER_CTX *ctx,
31 const UI_METHOD *ui_method,
33 int OSSL_ENCODER_CTX_set_passphrase_cb(OSSL_ENCODER_CTX *ctx,
34 OSSL_PASSPHRASE_CALLBACK *cb,
39 OSSL_ENCODER_CTX_new_by_EVP_PKEY() is a utility function that creates a
40 B<OSSL_ENCODER_CTX>, finds all applicable encoder implementations and sets
41 them up, so almost all the caller has to do next is call functions like
42 L<OSSL_ENCODER_to_bio(3)>.
44 Internally, OSSL_ENCODER_CTX_new_by_EVP_PKEY() uses the names from the
45 L<EVP_KEYMGMT(3)> implementation associated with I<pkey> to build a list of
46 applicable encoder implementations that are used to process the I<pkey> into
47 the encoding named by I<output_type>. All these implementations are
48 implicitly fetched using I<libctx> and I<propquery>.
50 If no suitable encoder implementation is found,
51 OSSL_ENCODER_CTX_new_by_EVP_PKEY() still creates a B<OSSL_ENCODER_CTX>, but
52 with no associated encoder (L<OSSL_ENCODER_CTX_get_num_encoders(3)> returns
53 zero). This helps the caller to distinguish between an error when creating
54 the B<OSSL_ENCODER_CTX> and missing encoder implementation, and allows it to
57 OSSL_ENCODER_CTX_set_cipher() tells the implementation what cipher
58 should be used to encrypt encoded keys. The cipher is given by
59 name I<cipher_name>. The interpretation of that I<cipher_name> is
60 implementation dependent. The implementation may implement the cipher
61 directly itself or by other implementations, or it may choose to fetch
62 it. If the implementation supports fetching the cipher, then it may
63 use I<propquery> as properties to be queried for when fetching.
64 I<cipher_name> may also be NULL, which will result in unencrypted
67 OSSL_ENCODER_CTX_set_passphrase() gives the implementation a
68 pass phrase to use when encrypting the encoded private key.
69 Alternatively, a pass phrase callback may be specified with the
72 OSSL_ENCODER_CTX_set_pem_password_cb(), OSSL_ENCODER_CTX_set_passphrase_ui()
73 and OSSL_ENCODER_CTX_set_passphrase_cb() sets up a callback method that the
74 implementation can use to prompt for a pass phrase, giving the caller the
75 choice of prefered pass phrase callback form. These are called indirectly,
76 through an internal B<OSSL_PASSPHRASE_CALLBACK> function.
80 OSSL_ENCODER_CTX_new_by_EVP_PKEY() returns a pointer to a
81 B<OSSL_ENCODER_CTX>, or NULL if it couldn't be created.
83 OSSL_ENCODER_CTX_set_cipher(), OSSL_ENCODER_CTX_set_passphrase(),
84 OSSL_ENCODER_CTX_set_pem_password_cb(), OSSL_ENCODER_CTX_set_passphrase_ui()
85 and OSSL_ENCODER_CTX_set_passphrase_cb() all return 1 on success, or 0 on
90 Parts of the function names are made to match already existing OpenSSL
93 B<EVP_PKEY> in OSSL_ENCODER_CTX_new_by_EVP_PKEY() matches the type name,
94 thus making for the naming pattern B<OSSL_ENCODER_CTX_new_by_I<TYPE>>() when
95 new types are handled.
99 L<provider(7)>, L<OSSL_ENCODER(3)>, L<OSSL_ENCODER_CTX(3)>
103 The functions described here were added in OpenSSL 3.0.
107 Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
109 Licensed under the Apache License 2.0 (the "License"). You may not use
110 this file except in compliance with the License. You can obtain a copy
111 in the file LICENSE in the source distribution or at
112 L<https://www.openssl.org/source/license.html>.