'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`'

def __init__(self, key, msg=None, digestmod=None):

    if (digestmod is None):
        import MD5
        digestmod = MD5
    self.digestmod = digestmod
    self.outer = digestmod.new()
    self.inner = digestmod.new()
    try:
        self.digest_size = digestmod.digest_size
    except AttributeError:
        self.digest_size = len(self.outer.digest())
    try:
        blocksize = digestmod.block_size
    except AttributeError:
        blocksize = 64
    ipad = 54
    opad = 92
    if (len(key) > blocksize):
        key = digestmod.new(key).digest()
    key = (key + (bchr(0) * (blocksize - len(key))))
    self.outer.update(strxor_c(key, opad))
    self.inner.update(strxor_c(key, ipad))
    if msg:
        self.update(msg)
