Current File : //usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyc
�
�
5Xc@s�dZddlZeje�ZddlmZmZddlm	Z	ddl
mZmZm
Z
ddlmZddljjZgZdZdejejejejfd	��YZdS(
spasslib.handlers.sha1_crypt
i����N(t
safe_cryptt
test_crypt(th64(tutunicodetirange(tcompile_hmactt
sha1_cryptcBs�eZdZdZd'Zed�ZdZej	Z
dZdZej	Z
d	Zd
ZdZdZed
��Zed�Zd(Zed��Zd�Zed��Zd�Zdd
dddddddddddd d!d"d#d$dd%d&gZRS()s&This class implements the SHA1-Crypt password hash, and follows the :ref:`password-hash-api`.

    It supports a variable-length salt, and a variable number of rounds.

    The :meth:`~passlib.ifc.PasswordHash.using` method accepts the following optional keywords:

    :type salt: str
    :param salt:
        Optional salt string.
        If not specified, an 8 character one will be autogenerated (this is recommended).
        If specified, it must be 0-64 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to 8 bytes, but can be any value between 0 and 64.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 480000, must be between 1 and 4294967295, inclusive.

    :type relaxed: bool
    :param relaxed:
        By default, providing an invalid value for one of the other
        keywords will result in a :exc:`ValueError`. If ``relaxed=True``,
        and the error can be corrected, a :exc:`~passlib.exc.PasslibHashWarning`
        will be issued instead. Correctable errors include ``rounds``
        that are too small or too large, and ``salt`` strings that are too long.

        .. versionadded:: 1.6
    Rtsaltt	salt_sizetroundss$sha1$iii@iSiI����tlinearcCs=tj||jd|�\}}}|d|d|d|�S(NthandlerRR	tchecksum(tuht	parse_mc3tident(tclsthashRR	tchk((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pytfrom_stringSs$cCs4|rdn|j}tj|j|j|j|�S(N(tNoneRRt
render_mc3RRR	(tselftconfigR((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyt	to_stringXstos_crypttbuiltincCs+tdd�r#|j|j�tStSdS(Nttests-$sha1$1$Wq3GL2Vp$C8U25GvfHS8qGHimExLaiSFlGkAe(Rt_set_calc_checksum_backendt_calc_checksum_os_crypttTruetFalse(R((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyt_load_backend_os_cryptdscCsq|jdt�}t||�}|r`|j|�rRt|�t|�dksXt�|dS|j|�SdS(NRii��(RR Rt
startswithtlentAssertionErrort_calc_checksum_builtin(RtsecretRR((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyRms1cCs|j|j�tS(N(RR&R (R((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyt_load_backend_builtin{scCs�t|t�r!|jd�}nt|krBtjj|��n|j}td�|j	|fjd�}t
d|�}x t|�D]}||�}q�Wtj
||j�jd�S(Nsutf-8s
%s$sha1$%stasciitsha1(t
isinstanceRtencodet_BNULLRtexctNullPasswordErrorRRR	RRRtencode_transposed_bytest_chk_offsetstdecode(RR'Rtresultt
keyed_hmact_((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyR&�s	"iiiiiiiii
i	ii
iiiiii(ssaltR
srounds(RR(t__name__t
__module__t__doc__tnametsetting_kwdsRRt
checksum_sizeRtHASH64_CHARStchecksum_charstdefault_salt_sizet
max_salt_sizet
salt_charstdefault_roundst
min_roundst
max_roundstrounds_costtclassmethodRR!RtbackendsR"RR(R&R1(((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyRs6 											(R8tloggingt	getLoggerR6tlogt
passlib.utilsRRtpasslib.utils.binaryRtpasslib.utils.compatRRRtpasslib.crypto.digestRtpasslib.utils.handlerstutilsthandlersRt__all__R-tHasManyBackendst	HasRoundstHasSalttGenericHandlerR(((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyt<module>s