§
    ¢”j²  ã                   óD  — d dl mZmZmZmZ d dlZd dlZd dlmZ ddlm	Z	 ddl
mZ ddlmZmZ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 n%edk    sedk    rddlmZmZ ddlmZmZ nddlmZmZ g d¢Zej        dk    rd„ Z d„ Z!nd„ Z d„ Z!dd„Z"d„ Z#dS )é    )Úunicode_literalsÚdivisionÚabsolute_importÚprint_functionN)Údatetimeé   )Úbackend)Ú
rand_bytes)Ú	type_nameÚbyte_clsÚ	int_types)Úpretty_message)ÚnewÚderefÚmac)Úpbkdf2Ú
pkcs12_kdfÚwinÚ	winlegacy)Úkernel32Úhandle_error)Úpbkdf1r   Úpbkdf2_iteration_calculatorr   Úwin32c                  ó�   — t          t          d¦  «        } t          j        | ¦  «        }t          |¦  «         t	          | ¦  «        S )NzLARGE_INTEGER *)r   r   ÚQueryPerformanceCounterr   r   )ÚnumberÚress     ú[/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/oscrypto/kdf.pyÚ
_get_startr    $   s<   € Ý•XÐ0Ñ1Ô1ˆÝÔ.¨vÑ6Ô6ˆÝ�SÑÔÐÝ�V‰}Œ}Ðó    c                 óH   — t          ¦   «         | z
  }t          |dz  ¦  «        S )Ng     @�@)r    Úint)ÚstartÚlengths     r   Ú_get_elapsedr&   *   s"   € Ý‘” Ñ%ˆÝ�6˜F‘?Ñ#Ô#Ð#r!   c                  ó(   — t          j        ¦   «         S )N)r   Únow© r!   r   r    r    /   s   € ÝŒ|‰~Œ~Ðr!   c                 ó–   — t          j        ¦   «         | z
  }|j        |j        dz  dz  z   }|j        dz  }t          ||dz  z   ¦  «        S )Né   i  iè  )r   r(   ÚsecondsÚdaysÚmicrosecondsr#   )r$   r%   r,   Úmillisecondss       r   r&   r&   2   sO   € Ý”‘” %Ñ'ˆØ”. F¤K°"Ñ$4°tÑ$;Ñ<ˆØÔ+¨gÑ5ˆÝ�< 7¨WÑ#4Ñ5Ñ6Ô6Ð6r!   éd   Fc                 óÂ  ‡ ‡‡‡‡‡	‡
— ‰ t          g d¢¦  «        vr*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          j	        rt          t          d¦  «        ¦  «        ‚d	Šd
                     d¦  «        Š	t          ‰¦  «        Š
ˆ ˆˆˆ	ˆˆ
ˆfd„} |¦   «         }t          ‰|z  dz  ¦  «        Š |¦   «         }‰|z  Š‰dk     rdnd}t          t          ‰|¦  «        ¦  «        }|dk    r|dz  dz  }|S )aß  
    Runs pbkdf2() twice to determine the approximate number of iterations to
    use to hit a desired time per run. Use this on a production machine to
    dynamically adjust the number of iterations as high as you can.

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

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

    :param target_ms:
        The number of milliseconds the derivation should take

    :param quiet:
        If no output should be printed as attempts are made

    :return:
        An integer number of iterations of PBKDF2 using the specified hash
        that will take at least target_ms
    )Úsha1Úsha224Úsha256Úsha384Úsha512zz
            hash_algorithm must be one of "sha1", "sha224", "sha256", "sha384",
            "sha512", not %s
            ú?
            key_length must be an integer, not %s
            r   úC
            key_length must be greater than 0 - is %s
            z>
            target_ms must be an integer, not %s
            zB
            target_ms must be greater than 0 - is %s
            z€
            Only a very slow, pure-python version of PBKDF2 is available,
            making this function useless
            i'  zthis is a testzutf-8c                  ó¢   •— t          ¦   «         } t          ‰‰‰‰‰¦  «         t          | ¦  «        }‰st          ‰›d|›d�¦  «         d‰z  |z  S )Nz iterations in Úmsg      ð?)r    r   r&   Úprint)	r$   Úobserved_msÚhash_algorithmÚ
iterationsÚ
key_lengthÚpasswordÚquietÚsaltÚ	target_mss	     €€€€€€€r   Ú_measurez-pbkdf2_iteration_calculator.<locals>._measure†   sb   ø€ Ý‘”ˆÝˆ~˜x¨¨z¸:ÑFÔFÐFÝ" 5Ñ)Ô)ˆØð 	GÝ¨Z¨Z¨Z¸¸¸ÐEÑFÔFÐFØ�Y‰ Ñ,Ð,r!   g       @i † éýÿÿÿéüÿÿÿi N  iˆ  )ÚsetÚ
ValueErrorr   ÚreprÚ
isinstancer   Ú	TypeErrorr   r   Úpure_pythonÚOSErrorÚencoder
   r#   Úround)r=   r?   rC   rA   rD   ÚfractionÚround_factorÚresultr>   r@   rB   s   ````    @@@r   r   r   9   s`  øøøøøøø€ ð0 �SÐ!QÐ!QÐ!QÑRÔRÐRÐRÝ�ðõ �Ñ Ô ñ
ô 
ñ ô ð 	õ �j¥)Ñ,Ô,ð Ý�ðõ �jÑ!Ô!ñ	
ô 
ñ ô ð 	ð �A‚~€~Ý�ðõ �ÑÔñ	
ô 
ñ ô ð 	õ �i¥Ñ+Ô+ð Ý�ðõ �iÑ Ô ñ	
ô 
ñ ô ð 	ð �1‚}€}Ý�ðõ �‰OŒOñ	
ô 
ñ ô ð 	õ Ôð Ý•nðñ
ô 
ñ ô ð 	ð €JØ×&Ò& wÑ/Ô/€HÝ�jÑ!Ô!€Dð-ð -ð -ð -ð -ð -ð -ð -ð -ð -ð -ð ˆx‰zŒz€HÝ�Z (Ñ*¨SÑ0Ñ1Ô1€Jàˆx‰zŒz€HØ˜hÑ&€Jð
 $ fÒ,Ð,�2�2°"€LÝ•�z <Ñ0Ô0Ñ1Ô1€FØ�‚~€~Ø˜D‘. DÑ(ˆØ€Mr!   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          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          | ¦  «        ¦  «        ¦  «        ‚|d
k    r?| t          ddg¦  «        v r,t          t          d| t          |¦  «        f¦  «        ¦  «        ‚|dk    r0| dk    r*t          t          dt          |¦  «        ¦  «        ¦  «        ‚t          t          | ¦  «        } |||z   ¦  «                             ¦   «         }t          d|dz   ¦  «        D ]} ||¦  «                             ¦   «         }Œ |d|…         S )aF  
    An implementation of PBKDF1 - should only be used for interop with legacy
    systems, not new architectures

    :param hash_algorithm:
        The string name of the hash algorithm to use: "md2", "md5", "sha1"

    :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

    :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
            r7   r8   )Úmd2Úmd5r2   zT
            hash_algorithm must be one of "md2", "md5", "sha1", not %s
            é   rT   rU   zM
            key_length can not be longer than 16 for %s - is %s
            é   r2   zO
            key_length can not be longer than 20 for sha1 - is %s
            é   N)rJ   r   rK   r   r   r   rH   rI   rG   ÚgetattrÚhashlibÚdigestÚrange)r=   r@   rB   r>   r?   ÚalgoÚoutputÚ_s           r   r   r       sä  € õ0 �h¥Ñ)Ô)ð Ý�ðõ �xÑ Ô ñ	
ô 
ñ ô ð 	õ �d�HÑ%Ô%ð Ý�ðõ �t‰_Œ_ñ	
ô 
ñ ô ð 	õ �j¥)Ñ,Ô,ð Ý�ðõ �zÑ"Ô"ñ	
ô 
ñ ô ð 	ð �A‚~€~Ý�ðõ �ÑÔñ	
ô 
ñ ô ð 	õ �j¥)Ñ,Ô,ð Ý�ðõ �zÑ"Ô"ñ	
ô 
ñ ô ð 	ð �A‚~€~Ý�ðõ �ÑÔñ	
ô 
ñ ô ð 	ð �SÐ!7Ð!7Ð!7Ñ8Ô8Ð8Ð8Ý�ðõ �Ñ Ô ñ	
ô 
ñ ô ð 	ð �B‚€˜>­S°%¸°Ñ-@Ô-@Ð@Ð@Ý�ðð �T *Ñ-Ô-Ð.ñ	
ô 
ñ ô ð 	ð �B‚€˜>¨VÒ3Ð3Ý�ðõ �ÑÔñ	
ô 
ñ ô ð 	õ •7˜NÑ+Ô+€DØˆT�(˜T‘/Ñ"Ô"×)Ò)Ñ+Ô+€FÝ�1�j 1‘nÑ%Ô%ð 'ð 'ˆØ��f‘”×$Ò$Ñ&Ô&ˆˆà�+�:�+ÔÐr!   )r0   F)$Ú
__future__r   r   r   r   ÚsysrZ   r   Ú r	   Úutilr
   Ú_typesr   r   r   Ú_errorsr   Ú_ffir   r   Ú_backendÚ	_mac.utilr   r   Ú	_win.utilÚ_win._kernel32r   r   Ú_openssl.utilÚ__all__Úplatformr    r&   r   r   r)   r!   r   ú<module>rn      sæ  ðà RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ Rà 
€
€
€
Ø €€€Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð Ð Ð ð ˆ7‰9Œ9€ð ˆuÒÐØ-Ð-Ð-Ð-Ð-Ð-Ð-Ð-Ð-Ø�ÒÐ˜( kÒ1Ð1Ø-Ð-Ð-Ð-Ð-Ð-Ð-Ð-Ø6Ð6Ð6Ð6Ð6Ð6Ð6Ð6Ð6à1Ð1Ð1Ð1Ð1Ð1Ð1Ð1ðð ð €ð „<�7ÒÐðð ð ð$ð $ð $ð $ð
ð ð ð7ð 7ð 7ðdð dð dð dðNeð eð eð eð er!   