
    FRc                        d dl mZ d dl mZ d dlZd dlZd dlZd dlZddlmZ ddl	m
Z
mZmZmZmZmZmZmZ g dZ ej        d          ZddededefdZdededefdZdededefdZ	 ddedededededefdZdeddfdZdS )    )absolute_import)divisionN   )_bcrypt)
__author____copyright__	__email____license____summary__	__title____uri____version__)r   r   r   r   r   r	   r
   r   gensalthashpwkdfcheckpws   ^\$2y\$      2broundsprefixreturnc                    |dvrt          d          | dk     s| dk    rt          d          t          j        d          }t          j                            dd          }t          j                            ||t          |                     d	|z   d	z   d
| z  	                    d          z   d	z   t          j        
                    |          z   S )N)s   2ar   z%Supported prefixes are b'2a' or b'2b'      zInvalid rounds   char[]      $z%2.2uascii)
ValueErrorosurandomr   ffinewlibencode_base64lenencodestring)r   r   saltoutputs       /lib/python3.11/site-packages/bcrypt/__init__.pyr   r   9   s    ^# B@AAAz +Vb[ +)***:b>>D[__Xr**FKfdCII666 	
	
	 V
#
#G
,
,	- 		
 +

V
$
$	%    passwordr*   c                 (   t          | t          j                  st          |t          j                  rt          d          d| v rt	          d          | d d         } |t
                              d|          }}t          j        	                    dd          }t          j
                            | ||t          |                    }|dk    rt	          d	          |d d
         t          j                            |          d
d          z   S )N.Unicode-objects must be encoded before hashing    z"password may not contain NUL bytesH   s   $2b$r      r   zInvalid saltr   )
isinstancesix	text_type	TypeErrorr    _normalize_resubr   r#   r$   r%   bcrypt_hashpassr'   r)   )r.   r*   original_salthashedretvals        r,   r   r   N   s    (CM** Jjs}.M.M JHIII( ?=>>> }H  1 1'4 @ @4M[__Xs++F[((4VMMF{ )((( !w{11&99!""===r-   hashed_passwordc                 ~   t          | t          j                  st          |t          j                  rt          d          d| v sd|v rt	          d          t          | |          }t          |          t          |          k    rdS t          j        	                    ||t          |                    dk    S )Nz/Unicode-objects must be encoded before checkingr1   z6password and hashed_password may not contain NUL bytesFr   )
r4   r5   r6   r7   r    r   r'   r   r%   timingsafe_bcmp)r.   r>   rets      r,   r   r   t   s    (CM** Kj/ / K IJJJ( 
g8 
D
 
 	
 ?
+
+C
3xx3''' u;&&sOSXXFF!KKr-   Fdesired_key_bytesignore_few_roundsc           
         t          | t          j                  st          |t          j                  rt          d          t	          |           dk    st	          |          dk    rt          d          |dk    s|dk    rt          d          |dk     rt          d          |dk     r1|s/t          j        d	                    |          t          d
           t          j                            d|          }t          j                            | t	          |           |t	          |          |t	          |          |          }t          |dk               t          j                            ||          d d          S )Nr0   r   z#password and salt must not be emptyi   zdesired_key_bytes must be 1-512r   zrounds must be 1 or more2   zrWarning: bcrypt.kdf() called with only {0} round(s). This few is not secure: the parameter is linear, like PBKDF2.   )
stacklevelz	uint8_t[])r4   r5   r6   r7   r'   r    warningswarnformatUserWarningr   r#   r$   r%   bcrypt_pbkdf_bcrypt_assertbuffer)r.   r*   rB   r   rC   keyress          r,   r   r      s    (CM** Jjs}.M.M JHIII
8}} @SYY!^ @>???A <!2S!8 <:;;;z 53444{ 
, 
 	PfVnn	
 	
 	
 	
 +//+'8
9
9C
+
"
"#h--s4yy#s3xx C 3!8;c#455aaa88r-   okc                 (    | st          d          d S )Nzbcrypt assertion failed)SystemError)rQ   s    r,   rM   rM      s#     534445 5r-   )r   r   )F)
__future__r   r   r!   rerH   r5    r   	__about__r   r   r	   r
   r   r   r   r   __all__compiler8   intbytesr   r   boolr   r   rM    r-   r,   <module>r^      s    ' & & & & &       				 				  



      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	    
;'' C e     *#>U #>% #>E #> #> #> #>LLe Le L L L L L0 $&9 &9&9
&9 &9 	&9
 &9 &9 &9 &9 &9R5t 5 5 5 5 5 5 5r-   