def _bcrypt_decrypt(cipher, key, data, iv, padding):
key_handle = None<EOL>try:<EOL><INDENT>key_handle = _bcrypt_create_key_handle(cipher, key)<EOL>if iv is None:<EOL><INDENT>iv_len = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>iv_len = len(iv)<EOL><DEDENT>flags = <NUM_LIT:0><EOL>if padding is True:<EOL><INDENT>flags = BcryptConst.BCRYPT_BLOCK_PADDING<EOL><DEDENT>out_len = new(bcrypt, '<STR_LIT>')<EOL>res = bcrypt.BCryptDecrypt(<EOL>key_handle,<EOL>data,<EOL>len(data),<EOL>null(),<EOL>null(),<EOL><NUM_LIT:0>,<EOL>null(),<EOL><NUM_LIT:0>,<EOL>out_len,<EOL>flags<EOL>)<EOL>handle_error(res)<EOL>buffer_len = deref(out_len)<EOL>buffer = buffer_from_bytes(buffer_len)<EOL>iv_buffer = buffer_from_bytes(iv) if iv else null()<EOL>res = bcrypt.BCryptDecrypt(<EOL>key_handle,<EOL>data,<EOL>len(data),<EOL>null(),<EOL>iv_buffer,<EOL>iv_len,<EOL>buffer,<EOL>buffer_len,<EOL>out_len,<EOL>flags<EOL>)<EOL>handle_error(res)<EOL>return bytes_from_buffer(buffer, deref(out_len))<EOL><DEDENT>finally:<EOL><INDENT>if key_handle:<EOL><INDENT>bcrypt.BCryptDestroyKey(key_handle)<EOL><DEDENT><DEDENT>
Decrypts AES/RC4/RC2/3DES/DES ciphertext via CNG

:param cipher:
    A unicode string of "aes", "des", "tripledes_2key", "tripledes_3key",
    "rc2", "rc4"

:param key:
    The encryption key - a byte string 5-16 bytes long

:param data:
    The ciphertext - a byte string

:param iv:
    The initialization vector - a byte string - unused for RC4

:param padding:
    Boolean, if padding should be used - unused for RC4

:raises:
    ValueError - when any of the parameters contain an invalid value
    TypeError - when any of the parameters are of the wrong type
    OSError - when an error is returned by the OS crypto library

:return:
    A byte string of the plaintext