Server IP : 180.180.241.3 / Your IP : 216.73.216.252 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files (x86)/MySQL/MySQL Workbench 6.1 CE/python/site-packages/Crypto/Hash/ |
Upload File : |
ó ¤'Sc @ sa d Z d Z d d d g Z d d l m Z d d l Td Z d d d „ ƒ YZ d d d „ Z d S( sÊ HMAC (Hash-based Message Authentication Code) algorithm HMAC is a MAC defined in RFC2104_ and FIPS-198_ and constructed using a cryptograpic hash algorithm. It is usually named *HMAC-X*, where *X* is the hash algorithm; for instance *HMAC-SHA1* or *HMAC-MD5*. The strength of an HMAC depends on: - the strength of the hash algorithm - the length and entropy of the secret key An example of possible usage is the following: >>> from Crypto.Hash import HMAC >>> >>> secret = b'Swordfish' >>> h = HMAC.new(secret) >>> h.update(b'Hello') >>> print h.hexdigest() .. _RFC2104: http://www.ietf.org/rfc/rfc2104.txt .. _FIPS-198: http://csrc.nist.gov/publications/fips/fips198/fips-198a.pdf s $Id$t newt digest_sizet HMACiÿÿÿÿ( t strxor_c( t *c B sG e Z d Z d Z d d d „ Z d „ Z d „ Z d „ Z d „ Z RS( s Class that implements HMACc C sK | d k r! d d l } | } n | | _ | j ƒ | _ | j ƒ | _ y | j | _ Wn) t k rƒ t | j j ƒ ƒ | _ n Xy | j } Wn t k rª d } n Xd } d } t | ƒ | k rá | j | ƒ j ƒ } n | t d ƒ | t | ƒ } | j j t | | ƒ ƒ | j j t | | ƒ ƒ | rG| j | ƒ n d S( sÔ Create a new HMAC object. :Parameters: key : byte string secret key for the MAC object. It must be long enough to match the expected security level of the MAC. However, there is no benefit in using keys longer than the `digest_size` of the underlying hash algorithm. msg : byte string The very first chunk of the message to authenticate. It is equivalent to an early call to `update()`. Optional. :Parameter digestmod: The hash algorithm the HMAC is based on. Default is `Crypto.Hash.MD5`. :Type digestmod: A hash module or object instantiated from `Crypto.Hash` iÿÿÿÿNi@ i6 i\ i ( t Nonet MD5t digestmodR t outert innerR t AttributeErrort lent digestt block_sizet bchrt updateR ( t selft keyt msgR R t blocksizet ipadt opad( ( s\ C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE/python/site-packages\Crypto\Hash\HMAC.pyt __init__R s. c C s | j j | ƒ d S( s¼ Continue authentication of a message by consuming the next chunk of data. Repeated calls are equivalent to a single call with the concatenation of all the arguments. In other words: >>> m.update(a); m.update(b) is equivalent to: >>> m.update(a+b) :Parameters: msg : byte string The next chunk of the message being authenticated N( R R ( R R ( ( s\ C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE/python/site-packages\Crypto\Hash\HMAC.pyR ƒ s c C sF t t d ƒ ƒ } | j | _ | j j ƒ | _ | j j ƒ | _ | S( s! Return a copy ("clone") of the MAC object. The copy will have the same internal state as the original MAC object. This can be used to efficiently compute the MAC of strings that share a common initial substring. :Returns: An `HMAC` object t ( R t bR R t copyR ( R t other( ( s\ C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE/python/site-packages\Crypto\Hash\HMAC.pyR – s c C s/ | j j ƒ } | j | j j ƒ ƒ | j ƒ S( s} Return the **binary** (non-printable) MAC of the message that has been authenticated so far. This method does not change the state of the MAC object. You can continue updating the object after calling this function. :Return: A byte string of `digest_size` bytes. It may contain non-ASCII characters, including null bytes. ( R R R R R ( R t h( ( s\ C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE/python/site-packages\Crypto\Hash\HMAC.pyR ¦ s c C s6 d j g t | j ƒ ƒ D] } d t | ƒ ^ q ƒ S( s Return the **printable** MAC of the message that has been authenticated so far. This method does not change the state of the MAC object. :Return: A string of 2* `digest_size` bytes. It contains only hexadecimal ASCII digits. R s %02x( t joint tupleR t bord( R t x( ( s\ C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE/python/site-packages\Crypto\Hash\HMAC.pyt hexdigest´ s N( t __name__t __module__t __doc__R R R R R R R ( ( ( s\ C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE/python/site-packages\Crypto\Hash\HMAC.pyR J s 1 c C s t | | | ƒ S( s³ Create a new HMAC object. :Parameters: key : byte string key for the MAC object. It must be long enough to match the expected security level of the MAC. However, there is no benefit in using keys longer than the `digest_size` of the underlying hash algorithm. msg : byte string The very first chunk of the message to authenticate. It is equivalent to an early call to `HMAC.update()`. Optional. :Parameter digestmod: The hash to use to implement the HMAC. Default is `Crypto.Hash.MD5`. :Type digestmod: A hash module or instantiated object from `Crypto.Hash` :Returns: An `HMAC` object ( R ( R R R ( ( s\ C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE/python/site-packages\Crypto\Hash\HMAC.pyR À s N( ( R# t __revision__t __all__t Crypto.Util.strxorR t Crypto.Util.py3compatR R R R ( ( ( s\ C:\Program Files (x86)\MySQL\MySQL Workbench 6.1 CE/python/site-packages\Crypto\Hash\HMAC.pyt <module>9 s v