def _setup_evp_encrypt_decrypt(cipher, data):
evp_cipher = {<EOL>'<STR_LIT>': libcrypto.EVP_aes_128_cbc,<EOL>'<STR_LIT>': libcrypto.EVP_aes_192_cbc,<EOL>'<STR_LIT>': libcrypto.EVP_aes_256_cbc,<EOL>'<STR_LIT>': libcrypto.EVP_rc2_cbc,<EOL>'<STR_LIT>': libcrypto.EVP_rc4,<EOL>'<STR_LIT>': libcrypto.EVP_des_cbc,<EOL>'<STR_LIT>': libcrypto.EVP_des_ede_cbc,<EOL>'<STR_LIT>': libcrypto.EVP_des_ede3_cbc,<EOL>}[cipher]()<EOL>if cipher == '<STR_LIT>':<EOL><INDENT>buffer_size = len(data)<EOL><DEDENT>else:<EOL><INDENT>block_size = {<EOL>'<STR_LIT>': <NUM_LIT:16>,<EOL>'<STR_LIT>': <NUM_LIT:16>,<EOL>'<STR_LIT>': <NUM_LIT:16>,<EOL>'<STR_LIT>': <NUM_LIT:8>,<EOL>'<STR_LIT>': <NUM_LIT:8>,<EOL>'<STR_LIT>': <NUM_LIT:8>,<EOL>'<STR_LIT>': <NUM_LIT:8>,<EOL>}[cipher]<EOL>buffer_size = block_size * int(math.ceil(len(data) / block_size))<EOL><DEDENT>return (evp_cipher, buffer_size)<EOL>
Creates an EVP_CIPHER pointer object and determines the buffer size
necessary for the parameter specified.

:param evp_cipher_ctx:
    An EVP_CIPHER_CTX pointer

:param cipher:
    A unicode string of "aes128", "aes192", "aes256", "des",
    "tripledes_2key", "tripledes_3key", "rc2", "rc4"

:param key:
    The key byte string

:param data:
    The plaintext or ciphertext as a byte string

:param padding:
    If padding is to be used

:return:
    A 2-element tuple with the first element being an EVP_CIPHER pointer
    and the second being an integer that is the required buffer size