
     hx                     \   d dl mZmZmZmZ ddlmZ ddlmZm	Z	m
Z
mZmZmZmZmZmZmZ ddlmZ ddlmZ ddlmZmZ  e            Zed	k    rdd
lmZmZmZmZmZ nddl m!Z!m"Z"mZm#Z#m$Z$ g dZ%d Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-d Z.d Z/d Z0d Z1d Z2d Z3d Z4d Z5d Z6d Z7d Z8d  Z9d!S )"    )unicode_literalsdivisionabsolute_importprint_function   )pretty_message)
buffer_from_bytesbytes_from_bufferderefnewnullpointer_setstructstruct_bytesunwrapwrite_to_buffer   )
rand_bytes)backend)	type_namebyte_cls	winlegacy)advapi32Advapi32Consthandle_erroropen_context_handleclose_context_handle)bcryptBcryptConstr   open_alg_handleclose_alg_handle)aes_cbc_no_padding_decryptaes_cbc_no_padding_encryptaes_cbc_pkcs7_decryptaes_cbc_pkcs7_encryptdes_cbc_pkcs5_decryptdes_cbc_pkcs5_encryptrc2_cbc_pkcs5_decryptrc2_cbc_pkcs5_encryptrc4_decryptrc4_encrypttripledes_cbc_pkcs5_decrypttripledes_cbc_pkcs5_encryptc                    t          |           dvr*t          t          dt          |                               |st          d          }n=t          |          dk    r*t          t          dt          |                              t          |          dz  dk    r*t          t          dt          |                              |t	          d| ||d          fS )	a  
    Encrypts plaintext using AES in CBC mode with a 128, 192 or 256 bit key and
    no padding. This means the ciphertext must be an exact multiple of 16 bytes
    long.

    :param key:
        The encryption key - a byte string either 16, 24 or 32 bytes long

    :param data:
        The plaintext - a byte string

    :param iv:
        The initialization vector - either a byte string 16-bytes long or None
        to generate an IV

    :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 tuple of two byte strings (iv, ciphertext)
              o
            key must be either 16, 24 or 32 bytes (128, 192 or 256 bits)
            long - is %s
            r0   :
            iv must be 16 bytes long - is %s
            r   zJ
            data must be a multiple of 16 bytes long - is %s
            aesFlen
ValueErrorr   r   _encryptkeydataivs      S/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/oscrypto/_win/symmetric.pyr#   r#   -   s    2 3xx|## HH
 
   	  ^^	RB GG	
 
   	 4yy2~ II	
 
   	 T2u5566    c                    t          |           dvr*t          t          dt          |                               t          |          dk    r*t          t          dt          |                              t          d| ||d          S )a[  
    Decrypts AES ciphertext in CBC mode using a 128, 192 or 256 bit key and no
    padding.

    :param key:
        The encryption key - a byte string either 16, 24 or 32 bytes long

    :param data:
        The ciphertext - a byte string

    :param iv:
        The initialization vector - a byte string 16-bytes long

    :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
    r/   r3   r0   r4   r5   Fr7   r8   r   _decryptr:   s      r>   r"   r"   d   s    . 3xx|## HH
 
   	 2ww"}} GG	
 
   	 E3b%000r?   c                 @   t          |           dvr*t          t          dt          |                               |st          d          }n=t          |          dk    r*t          t          dt          |                              |t	          d| ||d          fS )a  
    Encrypts plaintext using AES in CBC mode with a 128, 192 or 256 bit key and
    PKCS#7 padding.

    :param key:
        The encryption key - a byte string either 16, 24 or 32 bytes long

    :param data:
        The plaintext - a byte string

    :param iv:
        The initialization vector - either a byte string 16-bytes long or None
        to generate an IV

    :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 tuple of two byte strings (iv, ciphertext)
    r/   r3   r0   r4   r5   Tr6   r:   s      r>   r%   r%      s    0 3xx|## HH
 
   	  ^^	RB GG	
 
   	 T2t4455r?   c                    t          |           dvr*t          t          dt          |                               t          |          dk    r*t          t          dt          |                              t          d| ||d          S )aG  
    Decrypts AES ciphertext in CBC mode using a 128, 192 or 256 bit key

    :param key:
        The encryption key - a byte string either 16, 24 or 32 bytes long

    :param data:
        The ciphertext - a byte string

    :param iv:
        The initialization vector - a byte string 16-bytes long

    :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
    r/   r3   r0   r4   r5   TrA   r:   s      r>   r$   r$      s    , 3xx|## HH
 
   	 2ww"}} GG	
 
   	 E3b$///r?   c                     t          |           dk     st          |           dk    r*t          t          dt          |                               t          d| |dd          S )a  
    Encrypts plaintext using RC4 with a 40-128 bit key

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

    :param data:
        The plaintext - a byte string

    :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 ciphertext
       r0   Q
            key must be 5 to 16 bytes (40 to 128 bits) long - is %s
            rc4N)r7   r8   r   r9   r;   r<   s     r>   r+   r+      g    & 3xx!||s3xx"}} HH	
 
   	 E3dD111r?   c                     t          |           dk     st          |           dk    r*t          t          dt          |                               t          d| |dd          S )a  
    Decrypts RC4 ciphertext using a 40-128 bit key

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

    :param data:
        The ciphertext - a byte string

    :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
    rF   r0   rG   rH   NrA   rI   s     r>   r*   r*     rJ   r?   c                 j   t          |           dk     st          |           dk    r*t          t          dt          |                               |st          d          }n=t          |          dk    r*t          t          dt          |                              |t	          d| ||d          fS )ab  
    Encrypts plaintext using RC2 with a 64 bit key

    :param key:
        The encryption key - a byte string 8 bytes long

    :param data:
        The plaintext - a byte string

    :param iv:
        The 8-byte initialization vector to use - a byte string - set as None
        to generate an appropriate one

    :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 tuple of two byte strings (iv, ciphertext)
    rF   r0   rG      9
            iv must be 8 bytes long - is %s
            rc2Tr6   r:   s      r>   r)   r)   #  s    . 3xx!||s3xx"}} HH	
 
   	  ]]	RA GG	
 
   	 T2t4455r?   c                 B   t          |           dk     st          |           dk    r*t          t          dt          |                               t          |          dk    r*t          t          dt          |                              t          d| ||d          S )a"  
    Decrypts RC2 ciphertext using a 64 bit key

    :param key:
        The encryption key - a byte string 8 bytes long

    :param data:
        The ciphertext - a byte string

    :param iv:
        The initialization vector used for encryption - a byte string

    :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
    rF   r0   rG   rM   rN   rO   TrA   r:   s      r>   r(   r(   O  s    , 3xx!||s3xx"}} HH	
 
   	 2ww!|| GG	
 
   	 E3b$///r?   c                    t          |           dk    r=t          |           dk    r*t          t          dt          |                               |st          d          }n=t          |          dk    r*t          t          dt          |                              d}t          |           dk    rd}|t	          || ||d          fS )	a  
    Encrypts plaintext using 3DES in either 2 or 3 key mode

    :param key:
        The encryption key - a byte string 16 or 24 bytes long (2 or 3 key mode)

    :param data:
        The plaintext - a byte string

    :param iv:
        The 8-byte initialization vector to use - a byte string - set as None
        to generate an appropriate one

    :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 tuple of two byte strings (iv, ciphertext)
    r0   r1   W
            key must be 16 bytes (2 key) or 24 bytes (3 key) long - is %s
            rM   rN   tripledes_3keytripledes_2keyTr6   r;   r<   r=   ciphers       r>   r-   r-   x  s    . 3xx2~~#c((b.. HH	
 
   	  ]]	RA GG	
 
   	 F
3xx2~~!dB5566r?   c                 p   t          |           dk    r=t          |           dk    r*t          t          dt          |                               t          |          dk    r*t          t          dt          |                              d}t          |           dk    rd}t          || ||d          S )	aC  
    Decrypts 3DES ciphertext in either 2 or 3 key mode

    :param key:
        The encryption key - a byte string 16 or 24 bytes long (2 or 3 key mode)

    :param data:
        The ciphertext - a byte string

    :param iv:
        The initialization vector used for encryption - a byte string

    :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
    r0   r1   rR   rM   rN   rS   rT   TrA   rU   s       r>   r,   r,     s    , 3xx2~~#c((b.. HH	
 
   	 2ww!|| GG	
 
   	 F
3xx2~~!FCr4000r?   c                 D   t          |           dk    r*t          t          dt          |                               |st          d          }n=t          |          dk    r*t          t          dt          |                              |t	          d| ||d          fS )a  
    Encrypts plaintext using DES with a 56 bit key

    :param key:
        The encryption key - a byte string 8 bytes long (includes error
        correction bits)

    :param data:
        The plaintext - a byte string

    :param iv:
        The 8-byte initialization vector to use - a byte string - set as None
        to generate an appropriate one

    :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 tuple of two byte strings (iv, ciphertext)
    rM   T
            key must be 8 bytes (56 bits + 8 parity bits) long - is %s
            rN   desTr6   r:   s      r>   r'   r'     s    0 3xx1}} HH	
 
   	  ]]	RA GG	
 
   	 T2t4455r?   c                    t          |           dk    r*t          t          dt          |                               t          |          dk    r*t          t          dt          |                              t          d| ||d          S )aK  
    Decrypts DES ciphertext using a 56 bit key

    :param key:
        The encryption key - a byte string 8 bytes long (includes error
        correction bits)

    :param data:
        The ciphertext - a byte string

    :param iv:
        The initialization vector used for encryption - a byte string

    :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
    rM   rY   rN   rZ   TrA   r:   s      r>   r&   r&     s    . 3xx1}} HH	
 
   	 2ww!|| GG	
 
   	 E3b$///r?   c                 $   d}| dk    r8t           j        t           j        t           j        dt	          |                   }n@t           j        t           j        t           j        t           j        t           j	        d|          }t           j
        }t          |d          }t          t          d          }t          |          }t           j        |_        t           j        |_        d|_        ||_        t          t          d	          }t          |          }	||	_        t	          |          |	_        t/          |          |z   }
d}| t1          d
dg          v rt	          |          dk    rt           j        }t5          t          d          }t          j        ||
t	          |
          t9                      ||          }t;          |           t          |          }| d
k    rVt5          t          dt	          |          dz            }t          j        |t           j        |d          }t;          |           | dk    rt          j        |t           j         |d          }t;          |           t5          t          dt           j!                  }t          j        |t           j"        |d          }t;          |           t5          t          dt           j#                  }t          j        |t           j$        |d          }t;          |           ||fS )a  
    Creates an HCRYPTPROV and HCRYPTKEY for symmetric encryption/decryption. The
    HCRYPTPROV must be released by close_context_handle() and the
    HCRYPTKEY must be released by advapi32.CryptDestroyKey() when done.

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

    :param key:
        A byte string of the symmetric key

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

    :return:
        A tuple of (HCRYPTPROV, HCRYPTKEY)
    Nr5   r/   )rZ   rT   rS   rO   rH   F)verify_only
BLOBHEADERr   PLAINTEXTKEYBLOBrO   rH   rF   zHCRYPTKEY *DWORD *rM   )%r   CALG_AES_128CALG_AES_192CALG_AES_256r7   CALG_DESCALG_3DES_112	CALG_3DESCALG_RC2CALG_RC4MS_ENH_RSA_AES_PROVr   r   r   r   r_   bTypeCUR_BLOB_VERSIONbVersionreservedaiKeyAlghdr	dwKeySizer   setCRYPT_NO_SALTr   CryptImportKeyr   r   CryptSetKeyParamKP_EFFECTIVE_KEYLENKP_IVCRYPT_MODE_CBCKP_MODEPKCS5_PADDING
KP_PADDING)rV   r;   r=   context_handlealgorithm_idproviderblob_header_pointerblob_headerblob_struct_pointerblob_structblobflagskey_handle_pointerres
key_handlebufs                   r>   _advapi32_create_handlesr   ,  s   ( N***
 
 c((	 !)+9+5 ) )
 
  0H(uEEEN <88,--K%6K(9KK'K +=>>,--K!KOHHK+,,s2DEeU^$$$$SQ+X}55

!D		 C *++J(Is3xx!|44'-	
 
 	S'	
 
 	S(I}'CDD'!	
 
 	S(I}'BCC'$	
 
 	SJ''r?   c                    d}t           j        t           j        t           j        t           j        t           j        t           j        d|          }	 t          |          }t           j        }t          t          d          }t          |          }t           j        |_        t           j        |_        t!          |          |_        t%          |          |z   }| dk    rWt'          t          dt!          |          dz            }t          j        |t           j        |dd          }	t-          |	           t'          t          d	          }
t          j        |t1                      ||
t1                      d|t!          |          d	  	        }	t-          |	           t          |
          |rt3          |           S S # |rt3          |           w w xY w)
ao  
    Creates a BCRYPT_KEY_HANDLE for symmetric encryption/decryption. The
    handle must be released by bcrypt.BCryptDestroyKey() when done.

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

    :param key:
        A byte string of the symmetric key

    :return:
        A BCRYPT_KEY_HANDLE
    N)r5   rZ   rT   rS   rO   rH   BCRYPT_KEY_DATA_BLOB_HEADERrO   r`   rM      r   zBCRYPT_KEY_HANDLE *)r   BCRYPT_AES_ALGORITHMBCRYPT_DES_ALGORITHMBCRYPT_3DES_112_ALGORITHMBCRYPT_3DES_ALGORITHMBCRYPT_RC2_ALGORITHMBCRYPT_RC4_ALGORITHMr    BCRYPT_KEY_DATA_BLOBr   r   r   BCRYPT_KEY_DATA_BLOB_MAGICdwMagicBCRYPT_KEY_DATA_BLOB_VERSION1	dwVersionr7   	cbKeyDatar   r   BCryptSetPropertyBCRYPT_EFFECTIVE_KEY_LENGTHr   BCryptImportKeyr   r!   )rV   r;   
alg_handlealg_constant	blob_typer   r   r   r   r   r   s              r>   _bcrypt_create_key_handler     s     J //%?%;//  L))$\22
4	$V-JKK011)D + I #C/0036U??fiSA66C*7 C  )>??$FFFFII

 

 	S())  	)Z((((	): 	)Z((((	)s   EF9 9Gc                 P   t          |t                    s*t          t          dt	          |                              t          |t                    s*t          t          dt	          |                              | dk    r?t          |t                    s*t          t          dt	          |                              | dk    r-|s+| dk    rt          |          dz  dk    st          d          t          d	k    rt          | ||||          S t          | ||||          S )
a  
    Encrypts plaintext

    :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 plaintext - 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 ciphertext
    ;
            key must be a byte string, not %s
            <
            data must be a byte string, not %s
            rH   :
            iv must be a byte string, not %s
            r5   r0   r   padding must be specifiedr   )

isinstancer   	TypeErrorr   r   r7   r8   _backend_advapi32_encrypt_bcrypt_encryptrV   r;   r<   r=   paddings        r>   r9   r9     sA   : c8$$  cNN	
 
   	 dH%%  dOO	
 
   	 z"h77 bMM	
 
   	 w %CIINa$7$78999; dB@@@63b':::r?   c           	      N   d}d}	 t          | ||          \  }}t          t          dt          |                    }t          j        |t                      ddt                      |d          }t          |           t          |          }	t          |	          }
t          |
|           t          |t          |                     t          j        |t                      dd|
||	          }t          |           t          |
t          |                    }| dk    r/|s-t          |          t          |          dz   k    r
|dd         }||rt          j        |           |rt          |           S S # |rt          j        |           |rt          |           w w xY w)a  
    Encrypts plaintext 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 plaintext - 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 ciphertext
    Nr`   Tr   r5   r0   i)r   r   r   r7   CryptEncryptr   r   r   r	   r   r   r
   CryptDestroyKeyr   )rV   r;   r<   r=   r   r{   r   out_lenr   
buffer_lenbufferoutputs               r>   r   r   "  s   : NJ,1%=fc2%N%N"
h	3t9955#FFFF
 
 	S7^^
":..%%%GSYY'''#FF
 
 	S"65>>:: U??7?s6{{c$ii"n/L/LDSD\F  	1$Z000 	1 0000	1  	1$Z000 	1 0000	1s   EE: :*F$c                    d}	 t          | |          }|d}nt          |          }d}|du rt          j        }t	          t
          d          }t          j        ||t          |          t                      t                      dt                      d||
  
        }	t          |	           t          |          }
t          |
          }|rt          |          nt                      }t          j        ||t          |          t                      ||||
||
  
        }	t          |	           t          |t          |                    |rt          j        |           S S # |rt          j        |           w w xY w)a  
    Encrypts plaintext 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 plaintext - 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 ciphertext
    Nr   TULONG *)r   r7   r   BCRYPT_BLOCK_PADDINGr   r   BCryptEncryptr   r   r   r	   r
   BCryptDestroyKeyrV   r;   r<   r=   r   r   iv_lenr   r   r   r   r   	iv_buffers                r>   r   r   q     : J10.vs;;
:FFWWFd??4Efi(("IIFFFFFF
 
 	S7^^
":..-/;%b)))TVV	"IIFF
 
 	S w88  	0#J////	0: 	0#J////	0   EE" "E;c                 2   t          |t                    s*t          t          dt	          |                              t          |t                    s*t          t          dt	          |                              | dk    r?t          |t                    s*t          t          dt	          |                              | t          ddg          vr|st          d          t          dk    rt          | ||||          S t          | ||||          S )a  
    Decrypts AES/RC4/RC2/3DES/DES ciphertext

    :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
    r   r   rH   r   r5   r   r   )
r   r   r   r   r   rq   r8   r   _advapi32_decrypt_bcrypt_decryptr   s        r>   rB   rB     s1   : c8$$  cNN	
 
   	 dH%%  dOO	
 
   	 z"h77 bMM	
 
   	 S%(((((4555; dB@@@63b':::r?   c                 R   d}d}	 t          | ||          \  }}| dk    r'|s%t          |          dz  dk    rt          d          t          |          }t	          t
          dt          |                    }t          j        |t                      | dk    r|sdndd||          }	t          |	           t          |t          |                    |rt          j        |           |rt          |           S S # |rt          j        |           |rt          |           w w xY w)	a  
    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
    Nr5   r0   r   z9Invalid data - ciphertext length must be a multiple of 16r`   FT)r   r7   r8   r	   r   r   CryptDecryptr   r   r
   r   r   r   )
rV   r;   r<   r=   r   r{   r   r   r   r   s
             r>   r   r     sP   : NJ1%=fc2%N%N"
U??7?s4yy2~/B/BXYYY"4((h	3t9955#FF u__W_EE$	
 	
 	S w88  	1$Z000 	1 0000	1  	1$Z000 	1 0000	1s   CC< <*D&c                    d}	 t          | |          }|d}nt          |          }d}|du rt          j        }t	          t
          d          }t          j        ||t          |          t                      t                      dt                      d||
  
        }	t          |	           t          |          }
t          |
          }|rt          |          nt                      }t          j        ||t          |          t                      ||||
||
  
        }	t          |	           t          |t          |                    |rt          j        |           S S # |rt          j        |           w w xY w)a  
    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
    Nr   Tr   )r   r7   r   r   r   r   BCryptDecryptr   r   r   r	   r
   r   r   s                r>   r   r   >  r   r   N):
__future__r   r   r   r   _errorsr   _ffir	   r
   r   r   r   r   r   r   r   r   utilr    r   _typesr   r   r   	_advapi32r   r   r   r   r   _cngr   r   r    r!   __all__r#   r"   r%   r$   r+   r*   r)   r(   r-   r,   r'   r&   r   r   r9   r   r   rB   r   r    r?   r>   <module>r      s   R R R R R R R R R R R R $ $ $ $ $ $                                    ( ( ( ( ( ( ( (799{kkkkkkkkkkkkkkkZZZZZZZZZZZZZZ   47 47 47n(1 (1 (1V+6 +6 +6\'0 '0 '0T2 2 2<2 2 2<)6 )6 )6X&0 &0 &0R-7 -7 -7`*1 *1 *1Z*6 *6 *6Z'0 '0 '0Tl( l( l(^D) D) D)N=; =; =;@L1 L1 L1^P0 P0 P0f:; :; :;z:1 :1 :1zP0 P0 P0 P0 P0r?   