§
    ¢”jæ  ã                   óª   — d dl mZmZmZmZ ddlmZ ddlmZm	Z	 ddl
mZmZmZ ddlmZ ddlmZmZmZ g d	¢Zed
k     rddlmZ n
d„ Zde_        d„ ZdS )é    )Úunicode_literalsÚdivisionÚabsolute_importÚprint_functioné   )Úpretty_message)Úbuffer_from_bytesÚbytes_from_bufferé   )Ú	libcryptoÚlibcrypto_version_infoÚhandle_openssl_error)Ú
rand_bytes)Ú	type_nameÚbyte_clsÚ	int_types)Úpbkdf2Ú
pkcs12_kdfr   )r   )r   c           
      ó  — t          |t          ¦  «        s*t          t          dt	          |¦  «        ¦  «        ¦  «        ‚t          |t          ¦  «        s*t          t          dt	          |¦  «        ¦  «        ¦  «        ‚t          |t
          ¦  «        s*t          t          dt	          |¦  «        ¦  «        ¦  «        ‚|dk     rt          d¦  «        ‚t          |t
          ¦  «        s*t          t          dt	          |¦  «        ¦  «        ¦  «        ‚|dk     rt          d¦  «        ‚| t          g d¢¦  «        vr*t          t          d	t          | ¦  «        ¦  «        ¦  «        ‚	 t          j
        t          j        t          j        t          j        t          j        dœ|          ¦   «         }t          |¦  «        }t          j        |t#          |¦  «        |t#          |¦  «        ||||¦  «        }t%          |¦  «         t'          |¦  «        S )
aæ  
        PBKDF2 from PKCS#5

        :param hash_algorithm:
            The string name of the hash algorithm to use: "sha1", "sha224", "sha256", "sha384", "sha512"

        :param password:
            A byte string of the password to use an input to the KDF

        :param salt:
            A cryptographic random byte string

        :param iterations:
            The numbers of iterations to use when deriving the key

        :param key_length:
            The length of the desired key in bytes

        :raises:
            ValueError - when any of the parameters contain an invalid value
            TypeError - when any of the parameters are of the wrong type

        :return:
            The derived key as a byte string
        zH
                password must be a byte string, not %s
                zD
                salt must be a byte string, not %s
                zG
                iterations must be an integer, not %s
                r   z!iterations must be greater than 0zG
                key_length must be an integer, not %s
                z!key_length must be greater than 0)Úsha1Úsha224Úsha256Úsha384Úsha512z†
                hash_algorithm must be one of "sha1", "sha224", "sha256", "sha384",
                "sha512", not %s
                )Ú
isinstancer   Ú	TypeErrorr   r   r   Ú
ValueErrorÚsetÚreprr   ÚEVP_sha1Ú
EVP_sha224Ú
EVP_sha256Ú
EVP_sha384Ú
EVP_sha512r	   ÚPKCS5_PBKDF2_HMACÚlenr   r
   )Úhash_algorithmÚpasswordÚsaltÚ
iterationsÚ
key_lengthÚevp_mdÚoutput_bufferÚresults           úe/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/oscrypto/_openssl/util.pyr   r      s2  € õ6 ˜(¥HÑ-Ô-ð 	Ý�Nðõ ˜(Ñ#Ô#ñ	ô ñ ô ð õ ˜$¥Ñ)Ô)ð 	Ý�Nðõ ˜$‘”ñ	ô ñ ô ð õ ˜*¥iÑ0Ô0ð 	Ý�Nðõ ˜*Ñ%Ô%ñ	ô ñ ô ð ð ˜Š>ˆ>ÝÐ@ÑAÔAÐAå˜*¥iÑ0Ô0ð 	Ý�Nðõ ˜*Ñ%Ô%ñ	ô ñ ô ð ð ˜Š>ˆ>ÝÐ@ÑAÔAÐAà¥Ð%UÐ%UÐ%UÑ!VÔ!VÐVÐVÝ�^ðõ �^Ñ$Ô$ñô ñ ô ð ðÝÔ&ÝÔ*ÝÔ*ÝÔ*ÝÔ*ð
ð 
ð ôñ ô ˆõ *¨*Ñ5Ô5ˆÝÔ,ØÝ�‰MŒMØÝ�‰IŒIØØØØñ	
ô 	
ˆõ 	˜VÑ$Ô$Ð$å  Ñ/Ô/Ð/ó    Fc                 óp  — t          |t          ¦  «        s*t          t          dt	          |¦  «        ¦  «        ¦  «        ‚t          |t          ¦  «        s*t          t          dt	          |¦  «        ¦  «        ¦  «        ‚t          |t
          ¦  «        s*t          t          dt	          |¦  «        ¦  «        ¦  «        ‚|dk     r*t          t          dt          |¦  «        ¦  «        ¦  «        ‚t          |t
          ¦  «        s*t          t          dt	          |¦  «        ¦  «        ¦  «        ‚|dk     r*t          t          dt          |¦  «        ¦  «        ¦  «        ‚| t          g d¢¦  «        vr*t          t          d	t          | ¦  «        ¦  «        ¦  «        ‚|t          g d
¢¦  «        vr*t          t          dt          |¦  «        ¦  «        ¦  «        ‚| 	                    d¦  «         
                    d¦  «        dz   }	 t          j        t          j        t          j        t          j        t          j        t          j        dœ|          ¦   «         }t%          |¦  «        }t          j        |t)          |¦  «        |t)          |¦  «        |||||¦	  «	        }	t+          |	¦  «         t-          |¦  «        S )a0  
    KDF from RFC7292 appendix B.2 - https://tools.ietf.org/html/rfc7292#page-19

    :param hash_algorithm:
        The string name of the hash algorithm to use: "md5", "sha1", "sha224", "sha256", "sha384", "sha512"

    :param password:
        A byte string of the password to use an input to the KDF

    :param salt:
        A cryptographic random byte string

    :param iterations:
        The numbers of iterations to use when deriving the key

    :param key_length:
        The length of the desired key in bytes

    :param id_:
        The ID of the usage - 1 for key, 2 for iv, 3 for mac

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type

    :return:
        The derived key as a byte string
    z@
            password must be a byte string, not %s
            z<
            salt must be a byte string, not %s
            z?
            iterations must be an integer, not %s
            r   zC
            iterations must be greater than 0 - is %s
            z?
            key_length must be an integer, not %s
            zC
            key_length must be greater than 0 - is %s
            )Úmd5r   r   r   r   r   z�
            hash_algorithm must be one of "md5", "sha1", "sha224", "sha256",
            "sha384", "sha512", not %s
            )r   r   é   z<
            id_ must be one of 1, 2, 3, not %s
            zutf-8zutf-16bes     )r   r   r   r   r   r   r   r   r   ÚdecodeÚencoder   ÚEVP_md5r    r!   r"   r#   r$   r	   ÚPKCS12_key_gen_unir&   r   r
   )
r'   r(   r)   r*   r+   Úid_Úutf16_passwordÚdigest_typer-   r.   s
             r/   r   r   {   sî  € õ< �h¥Ñ)Ô)ð Ý�ðõ �hÑÔñ	
ô 
ñ ô ð 	õ �d�HÑ%Ô%ð Ý�ðõ �d‰OŒOñ	
ô 
ñ ô ð 	õ �j¥)Ñ,Ô,ð Ý�ðõ �jÑ!Ô!ñ	
ô 
ñ ô ð 	ð �A‚~€~Ý�ðõ �ÑÔñ	
ô 
ñ ô ð 	õ �j¥)Ñ,Ô,ð Ý�ðõ �jÑ!Ô!ñ	
ô 
ñ ô ð 	ð �A‚~€~Ý�ðõ �ÑÔñ	
ô 
ñ ô ð 	ð �SÐ!XÐ!XÐ!XÑYÔYÐYÐYÝ�ðõ �Ñ Ô ñ
ô 
ñ ô ð 	ð •#�i�i�i‘.”.Ð Ð Ý�ðõ �‰IŒIñ	
ô 
ñ ô ð 	ð —_’_ WÑ-Ô-×4Ò4°ZÑ@Ô@À;ÑN€NðÝÔ ÝÔ"ÝÔ&ÝÔ&ÝÔ&ÝÔ&ðð ð ôñ ô €Kõ & jÑ1Ô1€MÝÔ)ØÝˆNÑÔØÝˆD‰	Œ	ØØØØØñ
ô 
€Fõ ˜Ñ Ô Ð å˜]Ñ+Ô+Ð+r0   N)Ú
__future__r   r   r   r   Ú_errorsr   Ú_ffir	   r
   Ú
_libcryptor   r   r   Ú_randr   Ú_typesr   r   r   Ú__all__Ú_pkcs5r   Úpure_pythonr   © r0   r/   ú<module>rE      s  ðà RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ Rà $Ð $Ð $Ð $Ð $Ð $Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø OÐ OÐ OÐ OÐ OÐ OÐ OÐ OÐ OÐ OØ Ð Ð Ð Ð Ð Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3ðð ð €ð ˜DÒ Ð ØÐÐÐÐÐÐð_0ð _0ð _0ðB €FÔðx,ð x,ð x,ð x,ð x,r0   