
    BwgU                         d dl mZmZmZmZ d dlZd dlZd dlZd dlZddl	m
Z
mZ ddlmZ ddlmZmZmZ ej$                  dk  reZnd Zd	gZd
 Zde_        y)    )unicode_literalsdivisionabsolute_importprint_functionN   )int_from_bytesint_to_bytes)pretty_message)	type_namebyte_cls	int_types)   c                     t        | g      S )N)bytes)nums    F/var/www/horilla/myenv/lib/python3.12/site-packages/oscrypto/_pkcs5.pychr_clsr      s    cU|    pbkdf2c                 ~   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        t        |       }d
dddddd|    }t        j                  |d|      }d}d}	t        |	      |k  r|j                         }
|
j                  |t!        j"                  d|      z          |
j%                         }t'        |      }t)        |dz
        D ]A  }|j                         }
|
j                  |       |
j%                         }|t'        |      z  }C |	t+        ||      z  }	|dz  }t        |	      |k  r|	d| S )a4  
    Implements PBKDF2 from PKCS#5 v2.2 in pure Python

    :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

    :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
            )md5sha1sha224sha256sha384sha512z
            hash_algorithm must be one of "md5", "sha1", "sha224", "sha256",
            "sha384", "sha512", not %s
                         0   @   Nr   s   >I)widthr   )
isinstancer   	TypeErrorr
   r   r   
ValueErrorreprsetgetattrhashlibhmacnewlencopyupdatestructpackdigestr   ranger	   )hash_algorithmpasswordsalt
iterations
key_lengthalgohash_lengthoriginal_hmacblockoutputprflastu_s                 r   r   r      si   0 h) h	
  	 dH% dO	
  	 j), j!	
  	 A~ 	
  	 j), j!	
  	 A~ 	
  	 S!XYY  
  	 7N+D  K HHXtT2MEF
f+

"  "

4&++eU334zz|4 z!|$ 	&A$$&CJJt::<D%%A		& 	,q44
 f+

"  !Jr   T)
__future__r   r   r   r   sysr*   r+   r0   _asn1r   r	   _errorsr
   _typesr   r   r   version_infochrr   __all__r   pure_python r   r   <module>rL      sX    R R 
    / # 2 2dG
 
q h  r   