§
    ¢”jr  ã                   óà   — d dl 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 ddlmZ ddlmZmZmZ g d¢Z e¦   «         Zed	k    rd
dlmZmZmZmZmZ d„ Zde_        d„ ZdS ddlmZ ddlmZ dS )é    )Úunicode_literalsÚdivisionÚabsolute_importÚprint_functioné   )Úbackend)Úpretty_message)Úbuffer_from_bytesÚbytes_from_buffer)Ú
pkcs12_kdf)Ú	type_nameÚbyte_clsÚ	int_types)Úpbkdf2r   Ú
rand_bytesÚwiné   )ÚbcryptÚBcryptConstÚhandle_errorÚopen_alg_handleÚclose_alg_handlec                 ó„  — 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        dœ|          }d
}	 t          |t          j        ¦  «        }t!          |¦  «        }t#          j        ||t'          |¦  «        |t'          |¦  «        |||d¦	  «	        }t)          |¦  «         t+          |¦  «        |rt-          |¦  «         S S # |rt-          |¦  «         w w xY w)a%  
        PBKDF2 from PKCS#5

        :param hash_algorithm:
            The string name of the hash algorithm to use: "sha1", "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
            OSError - when an error is returned by the OS crypto library

        :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Úsha256Úsha384Úsha512z|
                hash_algorithm must be one of "sha1", "sha256", "sha384", "sha512",
                not %s
                Nr   )Ú
isinstancer   Ú	TypeErrorr	   r   r   Ú
ValueErrorÚsetÚreprr   ÚBCRYPT_SHA1_ALGORITHMÚBCRYPT_SHA256_ALGORITHMÚBCRYPT_SHA384_ALGORITHMÚBCRYPT_SHA512_ALGORITHMr   ÚBCRYPT_ALG_HANDLE_HMAC_FLAGr
   r   ÚBCryptDeriveKeyPBKDF2Úlenr   r   r   )	Úhash_algorithmÚpasswordÚsaltÚ
iterationsÚ
key_lengthÚalg_constantÚ
alg_handleÚoutput_bufferÚress	            úa/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/oscrypto/_win/util.pyr   r      sz  € õ8 ˜(¥HÑ-Ô-ð 	Ý�Nðõ ˜(Ñ#Ô#ñ	ô ñ ô ð õ ˜$¥Ñ)Ô)ð 	Ý�Nðõ ˜$‘”ñ	ô ñ ô ð õ ˜*¥iÑ0Ô0ð 	Ý�Nðõ ˜*Ñ%Ô%ñ	ô ñ ô ð ð ˜Š>ˆ>ÝÐ@ÑAÔAÐAå˜*¥iÑ0Ô0ð 	Ý�Nðõ ˜*Ñ%Ô%ñ	ô ñ ô ð ð ˜Š>ˆ>ÝÐ@ÑAÔAÐAà¥Ð%KÐ%KÐ%KÑ!LÔ!LÐLÐLÝ�^ðõ �^Ñ$Ô$ñô ñ ô ð õ  Ô5Ý!Ô9Ý!Ô9Ý!Ô9ð	
ð 
ð
 ôˆð ˆ
ð	-Ý(¨µ{Ô7^Ñ_Ô_ˆJå-¨jÑ9Ô9ˆMÝÔ.ØØÝ�H‘”ØÝ�D‘	”	ØØØØñ
ô 
ˆCõ ˜ÑÔÐå$ ]Ñ3Ô3àð -Ý  Ñ,Ô,Ð,Ð,ð-øˆzð -Ý  Ñ,Ô,Ð,Ð,ð-øøøs   ÆA<H+ È+H?Fc                 óæ  — t          | t          ¦  «        s*t          t          dt	          | ¦  «        ¦  «        ¦  «        ‚| dk     rt          d¦  «        ‚| dk    rt          d¦  «        ‚d}	 t          t          j        ¦  «        }t          | ¦  «        }t          j        ||| d¦  «        }t          |¦  «         t          |¦  «        |rt          |¦  «         S S # |rt          |¦  «         w w xY w)a³  
        Returns a number of random bytes suitable for cryptographic purposes

        :param length:
            The desired number of bytes

        :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
        zC
                length must be an integer, not %s
                r   zlength must be greater than 0i   z$length must not be greater than 1024Nr   )r   r   r   r	   r   r    r   r   ÚBCRYPT_RNG_ALGORITHMr
   r   ÚBCryptGenRandomr   r   r   )Úlengthr0   Úbufferr2   s       r3   r   r   „   s  € õ  ˜&¥)Ñ,Ô,ð 	Ý�Nðõ ˜&Ñ!Ô!ñ	ô ñ ô ð ð �AŠ:ˆ:ÝÐ<Ñ=Ô=Ð=à�DŠ=ˆ=ÝÐCÑDÔDÐDàˆ
ð	-Ý(­Ô)IÑJÔJˆJÝ& vÑ.Ô.ˆFåÔ(¨°V¸VÀQÑGÔGˆCÝ˜ÑÔÐå$ VÑ,Ô,ð ð -Ý  Ñ,Ô,Ð,Ð,ð-øˆzð -Ý  Ñ,Ô,Ð,Ð,ð-øøøs   Á-AC ÃC0)r   )r   N)Ú
__future__r   r   r   r   Ú r   Ú_errorsr	   Ú_ffir
   r   Ú_pkcs12r   Ú_typesr   r   r   Ú__all__Ú_backendÚ_cngr   r   r   r   r   r   Úpure_pythonr   Ú_pkcs5Ú_rand© ó    r3   ú<module>rG      sM  ðà RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ Rà Ð Ð Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø  Ð  Ð  Ð  Ð  Ð  Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3ðð ð €ð ˆ7‰9Œ9€ð ˆuÒÐØZÐZÐZÐZÐZÐZÐZÐZÐZÐZÐZÐZÐZÐZðh-ð h-ð h-ðT €FÔð+-ð +-ð +-ð +-ð +-ð^  ÐÐÐÐÐØ"Ð"Ð"Ð"Ð"Ð"Ð"Ð"rF   