1EVP_CIPHER_METH_NEW(3) OpenSSL EVP_CIPHER_METH_NEW(3)
2
3
4
6 EVP_CIPHER_meth_new, EVP_CIPHER_meth_dup, EVP_CIPHER_meth_free,
7 EVP_CIPHER_meth_set_iv_length, EVP_CIPHER_meth_set_flags,
8 EVP_CIPHER_meth_set_impl_ctx_size, EVP_CIPHER_meth_set_init,
9 EVP_CIPHER_meth_set_do_cipher, EVP_CIPHER_meth_set_cleanup,
10 EVP_CIPHER_meth_set_set_asn1_params,
11 EVP_CIPHER_meth_set_get_asn1_params, EVP_CIPHER_meth_set_ctrl,
12 EVP_CIPHER_meth_get_init, EVP_CIPHER_meth_get_do_cipher,
13 EVP_CIPHER_meth_get_cleanup, EVP_CIPHER_meth_get_set_asn1_params,
14 EVP_CIPHER_meth_get_get_asn1_params, EVP_CIPHER_meth_get_ctrl -
15 Routines to build up EVP_CIPHER methods
16
18 #include <openssl/evp.h>
19
20 EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len);
21 EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher);
22 void EVP_CIPHER_meth_free(EVP_CIPHER *cipher);
23
24 int EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len);
25 int EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags);
26 int EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size);
27 int EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher,
28 int (*init)(EVP_CIPHER_CTX *ctx,
29 const unsigned char *key,
30 const unsigned char *iv,
31 int enc));
32 int EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher,
33 int (*do_cipher)(EVP_CIPHER_CTX *ctx,
34 unsigned char *out,
35 const unsigned char *in,
36 size_t inl));
37 int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher,
38 int (*cleanup)(EVP_CIPHER_CTX *));
39 int EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher,
40 int (*set_asn1_parameters)(EVP_CIPHER_CTX *,
41 ASN1_TYPE *));
42 int EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher,
43 int (*get_asn1_parameters)(EVP_CIPHER_CTX *,
44 ASN1_TYPE *));
45 int EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher,
46 int (*ctrl)(EVP_CIPHER_CTX *, int type,
47 int arg, void *ptr));
48
49 int (*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
50 const unsigned char *key,
51 const unsigned char *iv,
52 int enc);
53 int (*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
54 unsigned char *out,
55 const unsigned char *in,
56 size_t inl);
57 int (*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *);
58 int (*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
59 ASN1_TYPE *);
60 int (*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
61 ASN1_TYPE *);
62 int (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
63 int type, int arg,
64 void *ptr);
65
67 The EVP_CIPHER type is a structure for symmetric cipher method
68 implementation.
69
70 EVP_CIPHER_meth_new() creates a new EVP_CIPHER structure.
71
72 EVP_CIPHER_meth_dup() creates a copy of cipher.
73
74 EVP_CIPHER_meth_free() destroys a EVP_CIPHER structure.
75
76 EVP_CIPHER_meth_set_iv_length() sets the length of the IV. This is
77 only needed when the implemented cipher mode requires it.
78
79 EVP_CIPHER_meth_set_flags() sets the flags to describe optional
80 behaviours in the particular cipher. With the exception of cipher
81 modes, of which only one may be present, several flags can be or'd
82 together. The available flags are:
83
84 EVP_CIPH_STREAM_CIPHER, EVP_CIPH_ECB_MODE EVP_CIPH_CBC_MODE,
85 EVP_CIPH_CFB_MODE, EVP_CIPH_OFB_MODE, EVP_CIPH_CTR_MODE,
86 EVP_CIPH_GCM_MODE, EVP_CIPH_CCM_MODE, EVP_CIPH_XTS_MODE,
87 EVP_CIPH_WRAP_MODE, EVP_CIPH_OCB_MODE
88 The cipher mode.
89
90 EVP_CIPH_VARIABLE_LENGTH
91 This cipher is of variable length.
92
93 EVP_CIPH_CUSTOM_IV
94 Storing and initialising the IV is left entirely to the
95 implementation.
96
97 EVP_CIPH_ALWAYS_CALL_INIT
98 Set this if the implementation's init() function should be called
99 even if key is NULL.
100
101 EVP_CIPH_CTRL_INIT
102 Set this to have the implementation's ctrl() function called with
103 command code EVP_CTRL_INIT early in its setup.
104
105 EVP_CIPH_CUSTOM_KEY_LENGTH
106 Checking and setting the key length after creating the EVP_CIPHER
107 is left to the implementation. Whenever someone uses
108 EVP_CIPHER_CTX_set_key_length() on a EVP_CIPHER with this flag set,
109 the implementation's ctrl() function will be called with the
110 control code EVP_CTRL_SET_KEY_LENGTH and the key length in arg.
111
112 EVP_CIPH_NO_PADDING
113 Don't use standard block padding.
114
115 EVP_CIPH_RAND_KEY
116 Making a key with random content is left to the implementation.
117 This is done by calling the implementation's ctrl() function with
118 the control code EVP_CTRL_RAND_KEY and the pointer to the key
119 memory storage in ptr.
120
121 EVP_CIPH_CUSTOM_COPY
122 Set this to have the implementation's ctrl() function called with
123 command code EVP_CTRL_COPY at the end of EVP_CIPHER_CTX_copy().
124 The intended use is for further things to deal with after the
125 implementation specific data block has been copied. The
126 destination EVP_CIPHER_CTX is passed to the control with the ptr
127 parameter. The implementation specific data block is reached with
128 EVP_CIPHER_CTX_get_cipher_data().
129
130 EVP_CIPH_FLAG_DEFAULT_ASN1
131 Use the default EVP routines to pass IV to and from ASN.1.
132
133 EVP_CIPH_FLAG_LENGTH_BITS
134 Signals that the length of the input buffer for encryption /
135 decryption is to be understood as the number of bits instead of
136 bytes for this implementation. This is only useful for CFB1
137 ciphers.
138
139 EVP_CIPH_FLAG_CUSTOM_CIPHER
140 This indicates that the implementation takes care of everything,
141 including padding, buffering and finalization. The EVP routines
142 will simply give them control and do nothing more.
143
144 EVP_CIPH_FLAG_AEAD_CIPHER
145 This indicates that this is an AEAD cipher implementation.
146
147 EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK
148 Allow interleaving of crypto blocks, a particular optimization only
149 applicable to certain TLS ciphers.
150
151 EVP_CIPHER_meth_set_impl_ctx_size() sets the size of the EVP_CIPHER's
152 implementation context so that it can be automatically allocated.
153
154 EVP_CIPHER_meth_set_init() sets the cipher init function for cipher.
155 The cipher init function is called by EVP_CipherInit(),
156 EVP_CipherInit_ex(), EVP_EncryptInit(), EVP_EncryptInit_ex(),
157 EVP_DecryptInit(), EVP_DecryptInit_ex().
158
159 EVP_CIPHER_meth_set_do_cipher() sets the cipher function for cipher.
160 The cipher function is called by EVP_CipherUpdate(),
161 EVP_EncryptUpdate(), EVP_DecryptUpdate(), EVP_CipherFinal(),
162 EVP_EncryptFinal(), EVP_EncryptFinal_ex(), EVP_DecryptFinal() and
163 EVP_DecryptFinal_ex().
164
165 EVP_CIPHER_meth_set_cleanup() sets the function for cipher to do extra
166 cleanup before the method's private data structure is cleaned out and
167 freed. Note that the cleanup function is passed a EVP_CIPHER_CTX *,
168 the private data structure is then available with
169 EVP_CIPHER_CTX_get_cipher_data(). This cleanup function is called by
170 EVP_CIPHER_CTX_reset() and EVP_CIPHER_CTX_free().
171
172 EVP_CIPHER_meth_set_set_asn1_params() sets the function for cipher to
173 set the AlgorithmIdentifier "parameter" based on the passed cipher.
174 This function is called by EVP_CIPHER_param_to_asn1().
175 EVP_CIPHER_meth_set_get_asn1_params() sets the function for cipher that
176 sets the cipher parameters based on an ASN.1 AlgorithmIdentifier
177 "parameter". Both these functions are needed when there is a need for
178 custom data (more or other than the cipher IV). They are called by
179 EVP_CIPHER_param_to_asn1() and EVP_CIPHER_asn1_to_param() respectively
180 if defined.
181
182 EVP_CIPHER_meth_set_ctrl() sets the control function for cipher.
183
184 EVP_CIPHER_meth_get_init(), EVP_CIPHER_meth_get_do_cipher(),
185 EVP_CIPHER_meth_get_cleanup(), EVP_CIPHER_meth_get_set_asn1_params(),
186 EVP_CIPHER_meth_get_get_asn1_params() and EVP_CIPHER_meth_get_ctrl()
187 are all used to retrieve the method data given with the
188 EVP_CIPHER_meth_set_*() functions above.
189
191 EVP_CIPHER_meth_new() and EVP_CIPHER_meth_dup() return a pointer to a
192 newly created EVP_CIPHER, or NULL on failure. All
193 EVP_CIPHER_meth_set_*() functions return 1. All
194 EVP_CIPHER_meth_get_*() functions return pointers to their respective
195 cipher function.
196
198 EVP_EncryptInit
199
201 The functions described here were added in OpenSSL 1.1.0.
202
204 Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
205
206 Licensed under the OpenSSL license (the "License"). You may not use
207 this file except in compliance with the License. You can obtain a copy
208 in the file LICENSE in the source distribution or at
209 <https://www.openssl.org/source/license.html>.
210
211
212
2131.1.1i 2021-07-22 EVP_CIPHER_METH_NEW(3)