ó ö 5Xc@sUdZddlmZddlZddlZejeƒZddlm Z ddl m Z ddl m Z ddlmZmZmZmZmZmZddljjZdgZd aed ƒZed „eDƒƒed „eDƒƒed „eDƒƒed„eDƒƒgZ[d„Zd Zdej ej!ej"fd„ƒYZ#dS(!sÖpasslib.handlers.sun_md5_crypt - Sun's Md5 Crypt, used on Solaris .. warning:: This implementation may not reproduce the original Solaris behavior in some border cases. See documentation for details. iÿÿÿÿ(tmd5N(twarn(t to_unicode(th64(tbyte_elem_valuetirangetut uascii_to_strtunicodet str_to_basciit sun_md5_cryptsíTo be, or not to be,--that is the question:-- Whether 'tis nobler in the mind to suffer The slings and arrows of outrageous fortune Or to take arms against a sea of troubles, And by opposing end them?--To die,--to sleep,-- No more; and by a sleep to say we end The heartache, and the thousand natural shocks That flesh is heir to,--'tis a consummation Devoutly to be wish'd. To die,--to sleep;-- To sleep! perchance to dream:--ay, there's the rub; For in that sleep of death what dreams may come, When we have shuffled off this mortal coil, Must give us pause: there's the respect That makes calamity of so long life; For who would bear the whips and scorns of time, The oppressor's wrong, the proud man's contumely, The pangs of despis'd love, the law's delay, The insolence of office, and the spurns That patient merit of the unworthy takes, When he himself might his quietus make With a bare bodkin? who would these fardels bear, To grunt and sweat under a weary life, But that the dread of something after death,-- The undiscover'd country, from whose bourn No traveller returns,--puzzles the will, And makes us rather bear those ills we have Than fly to others that we know not of? Thus conscience does make cowards of us all; And thus the native hue of resolution Is sicklied o'er with the pale cast of thought; And enterprises of great pith and moment, With this regard, their currents turn awry, And lose the name of action.--Soft you now! The fair Ophelia!--Nymph, in thy orisons Be all my sins remember'd. iccs"|]}|||dfVqdS(iN((t.0ti((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pys Nsccs&|]}||d|dfVqdS(iiN((R R ((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pys Osccs*|] }||d|dd@fVqdS(ii iN((R R ((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pys Psccs.|]$}||dd@|dd@fVqdS(i ii N((R R ((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pys QscCsÆt|tƒst‚t|tƒs*t‚|dkr?d}nd|}t||ƒjƒ}t|ƒdkswt‚t\}}}}d} x$| |krµg|D]} t| ƒ^q¥j} d} | | d?d@ƒ| d@?d@rì|n|} x| D]w\}}}| |ƒ}| |ƒ}| ||d?d@ƒ||d@?d@?}| | |d?d@ƒ|d@?d@|>O} qùWd}| | d d?d@ƒ| d@?d@r¤|n|}x|D]w\}}}| |ƒ}| |ƒ}| ||d?d@ƒ||d@?d@?}|| |d?d@ƒ|d@?d@|>O}q±W| | d?ƒ| d@?| |d?ƒ|d@?Ad@}t|ƒ}|r€|j t ƒn|j t | ƒj d ƒƒ|jƒ}| d7} q’Wt j|tƒS( s:given secret & salt, return encoded sun-md5-crypt checksumiiiiiiiii@tascii(t isinstancetbytestAssertionErrorRtdigesttlent _XY_ROUNDSRt __getitem__tupdatet MAGIC_HAMLETRtencodeRtencode_transposed_bytest _chk_offsets(tsecrettroundstsaltt real_roundstresultt X_ROUNDS_0t X_ROUNDS_1t Y_ROUNDS_0t Y_ROUNDS_1troundtctrvaltxtxroundsR tiatibtatbtvtytyroundstcointh((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pytraw_sun_md5_cryptUsB   ",  (,0  (,2  i iii iiiiii iii ii cBs³eZdZdZdZejZdZdZ dZ ejZ dZ d Zd Zd Zed ƒed ƒfZeZed„Zed„ƒZed„ƒZed„Zd„ZRS(sPThis class implements the Sun-MD5-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, a salt will be autogenerated (this is recommended). If specified, it must be drawn from the regexp range ``[./0-9A-Za-z]``. :type salt_size: int :param salt_size: If no salt is specified, this parameter can be used to specify the size (in characters) of the autogenerated salt. It currently defaults to 8. :type rounds: int :param rounds: Optional number of rounds to use. Defaults to 34000, must be between 0 and 4294963199, inclusive. :type bare_salt: bool :param bare_salt: Optional flag used to enable an alternate salt digest behavior used by some hash strings in this scheme. This flag can be ignored by most users. Defaults to ``False``. (see :ref:`smc-bare-salt` for details). :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 R RRt bare_saltt salt_sizeiiiЄiIÿïÿÿtlinears$md5$s$md5,cKs#||_tt|ƒj|dS(N(R2tsuperR t__init__(tselfR2tkwds((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pyR6ús cCstj|ƒ}|j|jƒS(N(tuhtto_unicode_for_identifyt startswitht ident_values(tclsthash((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pytidentifysc Csnt|ddƒ}|jtdƒƒr6d}d}n|jtdƒƒr%|jtdƒdƒ}|d kr‡tjj|d ƒ‚n|d|!}yt|ƒ}Wn&tk rÌtjj|d ƒ‚nX|t |ƒkrôtjj |ƒ‚n|dkrtjj|d ƒ‚n|d }ntjj |ƒ‚|j tdƒ|ƒ}|d krt||}d}t} nÛ|t|ƒd krà||krÄ|dtdƒkrÄtjj|dƒ‚n||d !}d}t} no|dkr.||d tdƒkr.|||d !}||d }t} n!|||!}||d }t} |d|d|d|d| ƒS(NR R>s$md5$iis $md5,rounds=t$i iÿÿÿÿsunexpected end of roundss bad roundssexplicit zero roundsiiþÿÿÿstoo many '$' separatorsRRtchecksumR2(RR;RtfindR9texctMalformedHashErrortintt ValueErrorRtZeroPaddedRoundsErrortInvalidHashErrortrfindtNonetTrueRtFalse( R=R>Rtsalt_idxtidxtrstrtchk_idxRtchkR2((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pyt from_stringsT         "  &  cCs |jrtdƒn tdƒ}|j}|dkrUtdƒ||j|f}ntdƒ|j|f}|r–|j}tdƒ||f}nt|ƒS(NtR@is$md5,rounds=%d$%s%ss $md5$%s%ss%s$%s(R2RRRRAR(R7t_withchktssRR>RQ((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pyt to_stringJs!   cCsUt|tƒr!|jdƒ}nt|jdtƒƒ}t||j|ƒjdƒS(Nsutf-8RTR ( RRRR RVRLR1Rtdecode(R7Rtconfig((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pyt_calc_checksum^s(ssaltsroundss bare_saltR3N(t__name__t __module__t__doc__tnamet setting_kwdsR9t HASH64_CHARStchecksum_charst checksum_sizetdefault_salt_sizeRJt max_salt_sizet salt_charstdefault_roundst min_roundst max_roundst rounds_costRR<RLR2R6t classmethodR?RRRKRVRY(((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pyR ¯s&)   D (i iii iiiiiii iii ii ($R\thashlibRtretloggingt getLoggerRZtlogtwarningsRt passlib.utilsRtpasslib.utils.binaryRtpasslib.utils.compatRRRRRR tpasslib.utils.handlerstutilsthandlersR9t__all__RtxrttupleRR1Rt HasRoundstHasSalttGenericHandlerR (((sB/usr/lib/python2.7/site-packages/passlib/handlers/sun_md5_crypt.pyts2  . &  O