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