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` gi[ddlmZmZmZmZddlZddlmZddlm Z m Z m Z m Z m Z mZddlmZmZmZmZddlmZdd lmZmZgd Zd Zd Zd ZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)y))unicode_literalsdivisionabsolute_importprint_functionN)pretty_message)newnullis_nullbuffer_from_bytesbytes_from_bufferderef) libcryptolibcrypto_legacy_supportLibcryptoConsthandle_openssl_error) rand_bytes) type_namebyte_cls) 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_encryptc t|}|s td}n,t|dk7rtt dt|t|dzdk7rtt dt||t ||||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 OpenSSL :return: A tuple of two byte strings (iv, ciphertext) : iv must be 16 bytes long - is %s rzJ data must be a multiple of 16 bytes long - is %s F_calculate_aes_cipherrlen ValueErrorr_encryptkeydataivciphers L/opt/nydus/tmp/pip-target-bkdi07qp/lib/python/oscrypto/_openssl/symmetric.pyrrs2#3 'F ^ RB  G     4y2~  I     dB6 77ct|}t|dk7rttdt|t ||||dS)aM 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 OpenSSL :return: A byte string of the plaintext r$r%Fr'r(r)r_decryptr+s r0rrMsP.#3 'F 2w"}  G     FCr5 11r1ct|}|s td}n,t|dk7rtt dt||t ||||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 OpenSSL :return: A tuple of two byte strings (iv, ciphertext) r$r%Tr&r+s r0rrqsa0#3 'F ^ RB  G     dB5 66r1ct|}t|dk7rttdt|t ||||dS)a9 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 OpenSSL :return: A byte string of the plaintext r$r%Tr3r+s r0rrsP,#3 'F 2w"}  G     FCr4 00r1ct|dvrttdt|t|dk(rd}|St|dk(rd}|St|dk(rd}S) a Determines if the key is a valid AES 128, 192 or 256 key :param key: A byte string of the key to use :raises: ValueError - when an invalid key is provided :return: A unicode string of the AES variation - "aes128", "aes192" or "aes256" )r$ zo key must be either 16, 24 or 32 bytes (128, 192 or 256 bits) long - is %s r$aes128r8aes192r9aes256)r(r)r)r,r/s r0r'r's{ 3x|#  H     3x2~ M SR M SR Mr1cts tdt|dkst|dkDrtt dt|t d||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 OpenSSL :return: A byte string of the ciphertext -OpenSSL has been compiled without RC4 supportr$Q key must be 5 to 16 bytes (40 to 128 bits) long - is %s rc4N)rEnvironmentErrorr(r)rr*r,r-s r0r r _& $NOO 3x!|s3x"}  H     E3dD 11r1cts tdt|dkst|dkDrtt dt|t d||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 OpenSSL :return: A byte string of the plaintext r>r?r$r@rANrrBr(r)rr4rCs r0rrrDr1c.ts tdt|dkst|dkDrtt dt||s t d}n,t|dk7rtt dt||t d|||dfS) ah Encrypts plaintext using RC2 in CBC mode with a 40-128 bit key and PKCS#5 padding. :param key: The encryption key - a byte string 8 bytes long :param data: The plaintext - a byte string :param iv: The initialization vector - a byte string 8-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 OpenSSL :return: A tuple of two byte strings (iv, ciphertext) -OpenSSL has been compiled without RC2 supportr?r$r@9 iv must be 8 bytes long - is %s rc2TrrBr(r)rrr*r,r-r.s r0rrs0 $NOO 3x!|s3x"}  H      ] RA  G     T2t4 55r1cts tdt|dkst|dkDrtt dt|t|dk7rtt dt|t d|||dS) a5 Decrypts RC2 ciphertext ib CBC mode using a 40-128 bit key and PKCS#5 padding. :param key: The encryption key - a byte string 8 bytes long :param data: The ciphertext - a byte string :param iv: The initialization vector - a byte string 8 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 OpenSSL :return: A byte string of the plaintext rHr?r$r@rIrJrKTrFrMs r0rrNs. $NOO 3x!|s3x"}  H     2w!|  G     E3b$ //r1c@t|dk7r,t|dk7rttdt||s td}n,t|dk7rttdt|d}t|dk(r ||ddz}d}|t ||||d fS) a Encrypts plaintext using 3DES in CBC mode using either the 2 or 3 key variant (16 or 24 byte long key) and PKCS#5 padding. :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 initialization vector - a byte string 8-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 OpenSSL :return: A tuple of two byte strings (iv, ciphertext) r$r8zT key must be 16 bytes (2 key) or 24 bytes (3 key) long - %s rIz6 iv must be 8 bytes long - %s tripledes_3keyrtripledes_2keyT)r(r)rrr*r+s r0r"r"{s0 3x2~#c(b.  H      ] RA  G    F 3x2~C!Hn! dB5 66r1c t|dk7r,t|dk7rttdt|t|dk7rttdt|d}t|dk(r ||ddz}d}t||||d S) au Decrypts 3DES ciphertext in CBC mode using either the 2 or 3 key variant (16 or 24 byte long key) and PKCS#5 padding. :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 - a byte string 8-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 OpenSSL :return: A byte string of the plaintext r$r8zW key must be 16 bytes (2 key) or 24 bytes (3 key) long - is %s rIrJrPrrQT)r(r)rr4r+s r0r!r!s. 3x2~#c(b.  H     2w!|  G    F 3x2~C!Hn! FCr4 00r1cts tdt|dk7rtt dt||s t d}n,t|dk7rtt dt||t d|||dfS)a Encrypts plaintext using DES in CBC mode with a 56 bit key and PKCS#5 padding. :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 initialization vector - a byte string 8-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 OpenSSL :return: A tuple of two byte strings (iv, ciphertext) -OpenSSL has been compiled without DES supportrIT key must be 8 bytes (56 bits + 8 parity bits) long - is %s rJdesTrLrMs r0rrs0 $NOO 3x1}  H      ] RA  G     T2t4 55r1cts tdt|dk7rtt dt|t|dk7rtt dt|t d|||dS)aN Decrypts DES ciphertext in CBC mode using a 56 bit key and PKCS#5 padding. :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 - a byte string 8-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 OpenSSL :return: A byte string of the plaintext rTrIrUrJrVTrFrMs r0rrs, $NOO 3x1}  H     2w!|  G     E3b$ //r1c t|tsttdt |t|tsttdt ||dk7r.t|tsttdt ||dk7r1|s/|t gdv}|r|rt |dzdk7r tdd } tj}t|r tdt||\}}| t}|t d dgvrtj||ttt} t| tj|t |} t| |d k(rEtj |t"j$t |d zt} t| t}tj||t||} t| |*tj&|t)|} t| t+|} t-td } tj.|| | |t |} t| t1| t3| } tj4|| | } t| | t1| t3| z } | |rtj6|SS#|rtj6|wwxYw) a Encrypts plaintext :param cipher: A unicode string of "aes128", "aes192", "aes256", "des", "tripledes_2key", "tripledes_3key", "rc2", "rc4" :param key: The encryption key - a byte string 5-32 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 OpenSSL :return: A byte string of the ciphertext ; key must be a byte string, not %s < data must be a byte string, not %s rA: iv must be a byte string, not %s )r:r;r<r$rpadding must be specifiedNrKrIint *) isinstancer TypeErrorrrsetr(r)rEVP_CIPHER_CTX_newr r_setup_evp_encrypt_decryptr EVP_EncryptInit_exEVP_CIPHER_CTX_set_key_lengthEVP_CIPHER_CTX_ctrlrEVP_CTRL_SET_RC2_KEY_BITSEVP_CIPHER_CTX_set_paddingintr r EVP_EncryptUpdater rEVP_EncryptFinal_exEVP_CIPHER_CTX_free) r/r,r-r.paddingis_aesevp_cipher_ctx evp_cipher buffer_sizeresbuffer output_lengthoutputs r0r*r*:s: c8 $  cN     dH %  dO    z"h7  bM    w3=>>&c$i"n%:89 9N1:"557 > "  #":tvsTVWS!  66~s7|TC  %";/Iw/ )).&-QUWZ[_W`aS!"65+?@++NFMRS!#FE-,@AA   ) ). 9 >  ) ). 9 s G>K K:c t|tsttdt |t|tsttdt ||dk7r.t|tsttdt ||t gdvr |s t dd} tj}t|r tdt||\}}| t}|t d dgvrtj||ttt}t|tj|t|}t||d k(rEtj |t"j$t|d zt}t|t}tj||t||}t||*tj&|t)|}t|t+|} t-td } tj.|| | |t|}t|t1| t3| } tj4|| | }t|| t1| t3| z } | |rtj6|SS#|rtj6|wwxYw) a Decrypts AES/RC4/RC2/3DES/DES ciphertext :param cipher: A unicode string of "aes128", "aes192", "aes256", "des", "tripledes_2key", "tripledes_3key", "rc2", "rc4" :param key: The encryption key - a byte string 5-32 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 OpenSSL :return: A byte string of the plaintext rYrZrAr[)rAr:r;r<r\NrrKrIr])r^rr_rrr`r)rrar rrbr EVP_DecryptInit_exrdr(rerrfrgrhr r EVP_DecryptUpdater rEVP_DecryptFinal_exrk) r/r,r-r.rlrnrorprqrrrsrts r0r4r4s: c8 $  cN     dH %  dO    z"h7  bM    S>??455N1:"557 > "  #":tvsTVWS!  66~s7|TC  %";/Iw/ )).&-QUWZ[_W`aS!"65+?@++NFMRS!#FE-,@AA   ) ). 9 >  ) ). 9 s /G>KK c  tjtjtjtjtj tj tjtjd|}|dk(rt|}||fSdddddddd|}|ttjt||z z}||fS)a 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 )r:r;r<rKrArVrQrPrAr$rI)r:r;r<rKrVrQrP) rEVP_aes_128_cbcEVP_aes_192_cbcEVP_aes_256_cbc EVP_rc2_cbcEVP_rc4 EVP_des_cbcEVP_des_ede_cbcEVP_des_ede3_cbcr(rhmathceil)r/r-rorp block_sizes r0rbrbs4 ++++++$$  $$#33#44    J$i   $$   !3tyyTZ1G'H#II  $$r1)* __future__rrrrr_errorsr_ffir r r r r r _libcryptorrrrutilr_typesrr__all__rrrrr'r rrrr"r!rrr*r4rbr1r0rsRR $RRaa(  -8`!2H$7N 1FB2B2B-6`*0Z07f-1`-6`)0Xo:dk:\3%r1