ó ö 5Xc@sÀdZddlZejeƒZddlmZmZddlm Z ddl m Z m 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 dZ dZ ej Z d Zd Zd Zd 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(NthandlerR R tchecksum(tuht parse_mc3tident(tclsthashR R tchk((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyt from_stringSs$cCs4|r dn|j}tj|j|j|j|ƒS(N(tNoneRRt render_mc3RR R (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_cryptdscCs@|jdtƒ}t||ƒ}|r/|dS|j|ƒSdS(NRiäÿÿÿ(RR Rt_calc_checksum_builtin(RtsecretRR((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyRms cCs|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_BNULLRtexctNullPasswordErrorR RR RRRtencode_transposed_bytest _chk_offsetstdecode(RR$R tresultt keyed_hmact_((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyR#€s  "iiiiiiii i 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_roundst rounds_costt classmethodRR!RtbackendsR"RR%R#R.(((s?/usr/lib/python2.7/site-packages/passlib/handlers/sha1_crypt.pyRs6             (R5tloggingt getLoggerR3tlogt 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.pyts