Current File : //usr/lib/python2.7/site-packages/passlib/crypto/_md4.pyo
�
�
5Xc@sydZddlmZddlZddlmZmZmZdgZd�Z	d�Z
d
Zdefd��YZ
dS(s�
passlib.crypto._md4 -- fallback implementation of MD4

Helper implementing insecure and obsolete md4 algorithm.
used for NTHASH format, which is also insecure and broken,
since it's just md4(password).

Implementated based on rfc at http://www.faqs.org/rfcs/rfc1320.html

.. note::

    This shouldn't be imported directly, it's merely used conditionally
    by ``passlib.crypto.lookup_hash()`` when a native implementation can't be found.
i����(thexlifyN(t
bascii_to_strtirangetPY3tmd4cCs||@||@BS(N((txtytz((s7/usr/lib/python2.7/site-packages/passlib/crypto/_md4.pytFscCs||@||@B||@BS(N((RRR((s7/usr/lib/python2.7/site-packages/passlib/crypto/_md4.pytG!sii icBsqeZdZdZdZZdZdZdZ	dZ
dd�Zddddddgdddddd	gdddddd
gddddddgddddddgddddd
d	gdddddd
gddddd	dgddddddgdddddd	gdddddd
gddddd
dgddddddgdddddd	gdddddd
gddddddggZddddddgdddddd
gddddddgddddddgddddddgddddd
d
gddddddgddddddgddddddgdddddd
gddddddgddddddgddddddgddddd	d
gddddd
dgddddddggZ
ddddddgddddddgdddddd
gddddddgddddddgddddddgdddddd
gddddddgddddddgddddddgddddd
d
gddddddgddddddgddddd
dgddddd	d
gddddddggZd�Zd�Zd�Zd�Zd�ZRS(s�pep-247 compatible implementation of MD4 hash algorithm

    .. attribute:: digest_size

        size of md4 digest in bytes (16 bytes)

    .. method:: update

        update digest by appending additional content

    .. method:: copy

        create clone of digest object, including current state

    .. method:: digest

        return bytes representing md4 digest of current content

    .. method:: hexdigest

        return hexadecimal version of digest
    Rii@icCsAd|_ddddg|_d|_|r=|j|�ndS(Nii#EgI����I�ܺ�ivT2t(t_countt_statet_buftupdate(tselftcontent((s7/usr/lib/python2.7/site-packages/passlib/crypto/_md4.pyt__init__Ns
		iiiiiiiiiii	i
ii
iic
Cs�tjd|�}|j}t|�}xs|jD]h\}}}}}	}
||t||||||�||	t@}||
>t@|d|
?||<q1Wxw|jD]l\}}}}}	}
||t||||||�||	dt@}||
>t@|d|
?||<q�Wxs|j	D]h\}}}}}	}
||||||A||A||	dt@}||
>t@|d|
?||<q!Wx.t
d�D] }||||t@||<q�WdS(sprocess 64 byte blocks<16Ii i�y�Zi���niN(tstructtunpackRtlistt_round1RtMASK_32t_round2R	t_round3R(
RtblocktXtorigtstatetatbtctdtktsttti((s7/usr/lib/python2.7/site-packages/passlib/crypto/_md4.pyt_process�s	"2""6""2"cCs�t|t�s6tr$td��q6|jd�}n|j}|rR||}nd}t|�}x]tr�|d}||kr�|j|||!�|j	d7_	|}qg|||_dSqgWdS(Nsexpected bytestasciiii@i(
t
isinstancetbytesRt	TypeErrortencodeR
tlentTrueR%R(RRtbuftidxtendtnext((s7/usr/lib/python2.7/site-packages/passlib/crypto/_md4.pyR�s"	
	
	
cCs7t�}|j|_t|j�|_|j|_|S(N(RRRRR
(Rtother((s7/usr/lib/python2.7/site-packages/passlib/crypto/_md4.pytcopy�s
	cCs�t|j�}|j}|jdt|�d}|dddt|�dtjd|t@|d?t@�}t|�d	kr�|j|d �|j|d�n
|j|�tjd
|j�}||_|S(Niis�tiwi@s<2Ii i�s<4I(	RRR
RR+RtpackRR%(RRR-tmsglenRtout((s7/usr/lib/python2.7/site-packages/passlib/crypto/_md4.pytdigest�s	"
	cCstt|j���S(N(RRR7(R((s7/usr/lib/python2.7/site-packages/passlib/crypto/_md4.pyt	hexdigest�sN(t__name__t
__module__t__doc__tnametdigest_sizet
digestsizet
block_sizeRtNoneRR
RRRRR%RR2R7R8(((s7/usr/lib/python2.7/site-packages/passlib/crypto/_md4.pyR,sz
					II����(R;tbinasciiRRtpasslib.utils.compatRRRt__all__RR	RtobjectR(((s7/usr/lib/python2.7/site-packages/passlib/crypto/_md4.pyt<module>s