PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` gixRddlmZmZmZmZddlmZddlmZm Z m Z m Z m Z m Z mZmZmZmZddlmZddlmZddlmZmZeZed k(rdd lmZmZmZmZmZndd l m!Z!m"Z"mZm#Z#m$Z$gd Z%d Z&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7dZ8d Z9y!)")unicode_literalsdivisionabsolute_importprint_function)pretty_message) buffer_from_bytesbytes_from_bufferderefnewnull pointer_setstruct struct_bytesunwrapwrite_to_buffer) rand_bytes)backend) type_namebyte_cls winlegacy)advapi32 Advapi32Const handle_erroropen_context_handleclose_context_handle)bcrypt BcryptConstropen_alg_handleclose_alg_handle) aes_cbc_no_padding_decryptaes_cbc_no_padding_encryptaes_cbc_pkcs7_decryptaes_cbc_pkcs7_encryptdes_cbc_pkcs5_decryptdes_cbc_pkcs5_encryptrc2_cbc_pkcs5_decryptrc2_cbc_pkcs5_encrypt rc4_decrypt rc4_encrypttripledes_cbc_pkcs5_decrypttripledes_cbc_pkcs5_encryptcLt|dvrttdt||s td}n,t|dk7rttdt|t|dzdk7rttdt||t d|||dfS) 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 rzJ data must be a multiple of 16 bytes long - is %s aesFlen ValueErrorrr_encryptkeydataivs H/opt/nydus/tmp/pip-target-bkdi07qp/lib/python/oscrypto/_win/symmetric.pyr#r#-s2 3x|#  H      ^ RB  G     4y2~  I     T2u5 66ct|dvrttdt|t|dk7rttdt|td|||dS)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/r3r0r4r5Fr7r8r_decryptr:s r>r"r"dsv. 3x|#  H     2w"}  G     E3b% 00r?ct|dvrttdt||s td}n,t|dk7rttdt||t d|||dfS)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/r3r0r4r5Tr6r:s r>r%r%s0 3x|#  H      ^ RB  G     T2t4 55r?ct|dvrttdt|t|dk7rttdt|td|||dS)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/r3r0r4r5TrAr:s r>r$r$sv, 3x|#  H     2w"}  G     E3b$ //r?ct|dkst|dkDrttdt|td||ddS)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 r0Q key must be 5 to 16 bytes (40 to 128 bits) long - is %s rc4N)r7r8rr9r;r<s r>r+r+P& 3x!|s3x"}  H     E3dD 11r?ct|dkst|dkDrttdt|td||ddS)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 rFr0rGrHNrArIs r>r*r*rJr?c t|dkst|dkDrttdt||s td}n,t|dk7rttdt||t d|||dfS)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) rFr0rG9 iv must be 8 bytes long - is %s rc2Tr6r:s r>r)r)#s. 3x!|s3x"}  H      ] RA  G     T2t4 55r?ct|dkst|dkDrttdt|t|dk7rttdt|td|||dS)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 rFr0rGrMrNrOTrAr:s r>r(r(Os, 3x!|s3x"}  H     2w!|  G     E3b$ //r?c0t|dk7r,t|dk7rttdt||s td}n,t|dk7rttdt|d}t|dk(rd}|t ||||dfS) 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) r0r1W key must be 16 bytes (2 key) or 24 bytes (3 key) long - is %s rMrNtripledes_3keytripledes_2keyTr6r;r<r=ciphers r>r-r-xs. 3x2~#c(b.  H      ] RA  G    F 3x2~! dB5 66r?ct|dk7r,t|dk7rttdt|t|dk7rttdt|d}t|dk(rd}t||||dS) 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 r0r1rRrMrNrSrTTrArUs r>r,r,s, 3x2~#c(b.  H     2w!|  G    F 3x2~! FCr4 00r?ct|dk7rttdt||s td}n,t|dk7rttdt||t d|||dfS)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) rMT key must be 8 bytes (56 bits + 8 parity bits) long - is %s rNdesTr6r:s r>r'r's0 3x1}  H      ] RA  G     T2t4 55r?ct|dk7rttdt|t|dk7rttdt|td|||dS)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 rMrYrNrZTrAr:s r>r&r&su. 3x1}  H     2w!|  G     E3b$ //r?cd}|dk(r=tjtjtjdt |}nQtj tj tjtjtjd|}tj}t|d}ttd}t|}tj|_tj"|_d|_||_ttd }t|} || _t || _t/||z} d} |t1d d gvrt |d k(rtj2} t5td } tj6|| t | t9| | } t;| t| }|d k(rNt5tdt |dz}tj<|tj>|d} t;| |d k7rtj<|tj@|d} t;| t5tdtjB}tj<|tjD|d} t;| t5tdtjF}tj<|tjH|d} t;| ||fS)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) Nr5r/)rZrTrSrOrHF) verify_only BLOBHEADERrPLAINTEXTKEYBLOBrOrHrFz HCRYPTKEY *DWORD *rM)%r CALG_AES_128 CALG_AES_192 CALG_AES_256r7CALG_DES CALG_3DES_112 CALG_3DESCALG_RC2CALG_RC4MS_ENH_RSA_AES_PROVrrrrr_bTypeCUR_BLOB_VERSIONbVersionreservedaiKeyAlghdr dwKeySizerset CRYPT_NO_SALTr CryptImportKeyr rCryptSetKeyParamKP_EFFECTIVE_KEYLENKP_IVCRYPT_MODE_CBCKP_MODE PKCS5_PADDING KP_PADDING)rVr;r=context_handle algorithm_idproviderblob_header_pointer blob_headerblob_struct_pointer blob_structblobflagskey_handle_pointerres key_handlebufs r>_advapi32_create_handlesr,s(N ******  c(  !))+99+55 )) ))    00H(uEN <8,-K%66K(99KK'K +=>,-K!KOHK + ,s 2D E eU^$$SQ++X}5  ! !  D     C*+J (Is3x!|4''   - -    S ''        S(I}'C'CD''   ! !    S(I}'B'BC''   $ $    S J ''r?c fd}tjtjtjtjtj tj d|} t|}tj}ttd}t|}tj|_ tj|_t!||_t%||z}|dk(rOt'tdt!|dz}tj(|tj*|dd} t-| t'td } tj.|t1|| t1d|t!|d } t-| t| |r t3|SS#|r t3|wwxYw) 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)r5rZrTrSrOrHBCRYPT_KEY_DATA_BLOB_HEADERrOr`rMrzBCRYPT_KEY_HANDLE *)rBCRYPT_AES_ALGORITHMBCRYPT_DES_ALGORITHMBCRYPT_3DES_112_ALGORITHMBCRYPT_3DES_ALGORITHMBCRYPT_RC2_ALGORITHMBCRYPT_RC4_ALGORITHMr BCRYPT_KEY_DATA_BLOBrrrBCRYPT_KEY_DATA_BLOB_MAGICdwMagicBCRYPT_KEY_DATA_BLOB_VERSION1 dwVersionr7 cbKeyDatarr BCryptSetPropertyBCRYPT_EFFECTIVE_KEY_LENGTHrBCryptImportKeyr r!) rVr; alg_handle alg_constant blob_typerrrrrrs r>_bcrypt_create_key_handlers J////%??%;;////  L))$\2 44 $V-JK01 )DD  + I I  #C /036 U?fiSA6C**77 C   )>?$$  F   F  I    S()  Z ( : Z ( s $D-F F0ct|tsttdt |t|tsttdt ||dk7r.t|tsttdt ||dk7r#|s!|dk(rt |dzdk(s t dtd k(rt|||||St|||||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 r5r0rpadding must be specifiedr) isinstancer TypeErrorrrr7r8_backend_advapi32_encrypt_bcrypt_encryptrVr;r<r=paddings r>r9r9s: c8 $  cN     dH %  dO    z"h7  bM    w%CINa$789 9; dB@@ 63b' ::r?c d}d} t|||\}}ttdt|}tj|t ddt |d}t |t|} t| } t| |t|t|tj|t dd| || }t |t| t|} |dk(r!|st| t|dzk(r| dd} | |rtj||r t|SS#|rtj||r t|wwxYw)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`Trr5r0i)rr rr7 CryptEncryptr rr r rrr CryptDestroyKeyr) rVr;r<r=rr{rout_lenr buffer_lenbufferoutputs r>rr"sK:NJ,1%=fc2%N" h 3t95##  F  F    S7^ ":.%GSY'##  F      S"65>: U?7s6{c$i"n/LDS\F   $ $Z 0   0    $ $Z 0   0 s DD--'Ec d} t||}|d}n t|}d}|durtj}t t d}t j ||t|ttdtd|| } t| t|} t| } |r t|n t} t j ||t|t| || | || } t| t| t||rt j|SS#|rt j|wwxYw)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 NrTULONG *) rr7rBCRYPT_BLOCK_PADDINGr r BCryptEncryptr rr r r BCryptDestroyKey rVr;r<r=rriv_lenrrrrr iv_buffers r>rrq1:J10.vs; :FWF d?44Efi(""   I F F F     S7^ ":.-/%b)TV ""   I F         S w8   # #J / :  # #J /  DD$$D>ct|tsttdt |t|tsttdt ||dk7r.t|tsttdt ||t ddgvr |s t dtdk(rt|||||St|||||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 rrrHrr5rr) rrrrrrqr8r_advapi32_decrypt_bcrypt_decryptrs r>rBrBs: c8 $  cN     dH %  dO    z"h7  bM    S%((455; dB@@ 63b' ::r?cd}d} t|||\}}|dk(r|st|dzdk7r tdt|}t t dt|}t j |t|dk(r|sdndd||} t| t|t||rt j||r t|SS#|rt j||r t|wwxYw) 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 Nr5r0rz9Invalid data - ciphertext length must be a multiple of 16r`FT) rr7r8r r r CryptDecryptr rr r rr) rVr;r<r=rr{rrrrs r>rrs:NJ1%=fc2%N" U?7s4y2~/BXY Y"4(h 3t95##  Fu_WE$     S w8   $ $Z 0   0    $ $Z 0   0 s B"C'C5c d} t||}|d}n t|}d}|durtj}t t d}t j ||t|ttdtd|| } t| t|} t| } |r t|n t} t j ||t|t| || | || } t| t| t||rt j|SS#|rt j|wwxYw)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 NrTr) rr7rrr r BCryptDecryptr rr r r rrs r>rr>rrN): __future__rrrr_errorsr_ffir r r r r rrrrrutilrr_typesrrr _advapi32rrrrr_cngrrr r!__all__r#r"r%r$r+r*r)r(r-r,r'r&rrr9rrrBrrr?r>rsRR$   ( 9 {kkZZ  47n(1V+6\'0T2<2<)6X&0R-7`*1Z*6Z'0Tl(^D)N=;@L1^P0f:;z:1zP0r?