def _advapi32_decrypt(cipher, key, data, iv, padding):
context_handle = None<EOL>key_handle = None<EOL>try:<EOL><INDENT>context_handle, key_handle = _advapi32_create_handles(cipher, key, iv)<EOL>if cipher == '<STR_LIT>' and not padding:<EOL><INDENT>data += (b'<STR_LIT>' * <NUM_LIT:16>)<EOL><DEDENT>buffer = buffer_from_bytes(data)<EOL>out_len = new(advapi32, '<STR_LIT>', len(data))<EOL>res = advapi32.CryptDecrypt(<EOL>key_handle,<EOL>null(),<EOL>True,<EOL><NUM_LIT:0>,<EOL>buffer,<EOL>out_len<EOL>)<EOL>handle_error(res)<EOL>return bytes_from_buffer(buffer, deref(out_len))<EOL><DEDENT>finally:<EOL><INDENT>if key_handle:<EOL><INDENT>advapi32.CryptDestroyKey(key_handle)<EOL><DEDENT>if context_handle:<EOL><INDENT>close_context_handle(context_handle)<EOL><DEDENT><DEDENT>
Decrypts AES/RC4/RC2/3DES/DES ciphertext via CryptoAPI

: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