Ñò
µ!ÝLc @ sM d Z d Z d d k Z d „ Z d Z d d d „ ƒ YZ d d d „ Z d S( sé HMAC (Keyed-Hashing for Message Authentication) Python module.
Implements the HMAC algorithm as described by RFC 2104.
This is just a copy of the Python 2.2 HMAC module, modified to work when
used on versions of Python before 2.2.
s0 $Id: HMAC.py,v 1.5 2002/07/25 17:19:02 z3p Exp $iÿÿÿÿNc C s d i t d „ | | ƒ ƒ S( sK Utility method. XOR the two strings s1 and s2 (must have same length).
t c S s t t | ƒ t | ƒ Aƒ S( ( t chrt ord( t xt y( ( s6 /usr/lib64/python2.6/site-packages/Crypto/Hash/HMAC.pyt s ( t joint map( t s1t s2( ( s6 /usr/lib64/python2.6/site-packages/Crypto/Hash/HMAC.pyt _strxor
s t HMACc B sA e Z d Z d d d „ Z d „ Z d „ Z d „ Z d „ Z RS( s_ RFC2104 HMAC class.
This supports the API for Cryptographic Hash Functions (PEP 247).
c C s: | d j o d d k } | } n | | _ | i ƒ | _ | i ƒ | _ y | i | _ Wn+ t j
o t | i i ƒ ƒ | _ n Xd } d | } d | } t | ƒ | j o | i | ƒ i ƒ } n | t
d ƒ | t | ƒ } | i i t | | ƒ ƒ | i i t | | ƒ ƒ | o | i | ƒ n d S( sÝ Create a new HMAC object.
key: key for the keyed hash object.
msg: Initial input for the hash, if provided.
digestmod: A module supporting PEP 247. Defaults to the md5 module.
iÿÿÿÿNi@ t 6s \i (
t Nonet MD5t digestmodt newt outert innert digest_sizet AttributeErrort lent digestR t updateR
( t selft keyt msgR R t blocksizet ipadt opad( ( s6 /usr/lib64/python2.6/site-packages/Crypto/Hash/HMAC.pyt __init__ s(
c C s | i i | ƒ d S( s8 Update this hashing object with the string msg.
N( R R ( R R ( ( s6 /usr/lib64/python2.6/site-packages/Crypto/Hash/HMAC.pyR ? s c C s@ t d ƒ } | i | _ | i i ƒ | _ | i i ƒ | _ | S( sy Return a separate copy of this hashing object.
An update to this copy won't affect the original object.
R ( R R R t copyR ( R t other( ( s6 /usr/lib64/python2.6/site-packages/Crypto/Hash/HMAC.pyR D s
c C s/ | i i ƒ } | i | i i ƒ ƒ | i ƒ S( sö Return the hash value of this hashing object.
This returns a string containing 8-bit data. The object is
not altered in any way by this function; you can continue
updating the object after calling this function.
( R R R R R ( R t h( ( s6 /usr/lib64/python2.6/site-packages/Crypto/Hash/HMAC.pyR O s c C sP d i g } t | i ƒ ƒ D]) } | t i t t | ƒ ƒ d d ƒ q ~ ƒ S( sK Like digest(), but returns a string of hexadecimal digits instead.
R i ( R t tupleR t stringt zfillt hexR ( R t _[1]R ( ( s6 /usr/lib64/python2.6/site-packages/Crypto/Hash/HMAC.pyt hexdigestZ s
N( t __name__t
__module__t __doc__R
R R R R R' ( ( ( s6 /usr/lib64/python2.6/site-packages/Crypto/Hash/HMAC.pyR s # c C s t | | | ƒ S( sV Create a new hashing object and return it.
key: The starting key for the hash.
msg: if available, will immediately be hashed into the object's starting
state.
You can now feed arbitrary strings into the object using its update()
method, and can ask for the hash value at any time by calling its digest()
method.
( R ( R R R ( ( s6 /usr/lib64/python2.6/site-packages/Crypto/Hash/HMAC.pyR ` s ( ( R* t __revision__R# R
R
R R R ( ( ( s6 /usr/lib64/python2.6/site-packages/Crypto/Hash/HMAC.pyt s J