Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/Crypto/Hash/__pycache__/KMAC128.cpython-311.pyc



]j=xddlmZddlmZmZmZddlmZddlm	Z	m
Z
ddl	mZmZm
Z
GddeZd	Zd
S))	unhexlify)bordtobytesis_bytes)get_random_bytes)	cSHAKE128SHA3_256)_bytepad_encode_str
_right_encodec<eZdZdZdZdZdZdZdZdZ	dZ
d	S)
	KMAC_Hashz[A KMAC hash object.
    Do not instantiate directly.
    Use the :func:`new` function.
    cd|z|_||_d|_tt	t||}|||d|_|r|j|dSdS)Nz2.16.840.1.101.3.4.2.sKMAC)	oiddigest_size_macrrr_new_cshakeupdate)	selfdatakeymac_lencustomoid_variantcshakeratepartial_newXs	         u/builddir/build/BUILD/imunify360-venv-2.6.3/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Hash/KMAC128.py__init__zKMAC_Hash.__init__.s+[8"	GCLL 9 94@@{{<AA	&L%%%%%	&	&cf|jrtd|j||S)zAuthenticate the next chunk of message.

        Args:
            data (bytes/bytearray/memoryview): The next chunk of the message to
            authenticate.
        z8You can only call 'digest' or 'hexdigest' on this object)r	TypeErrorrr)rrs  r rzKMAC_Hash.update=s99	XVWWWD!!!r"c|jsS|jt|jdz|j|j|_|jS)zReturn the **binary** (non-printable) MAC tag of the message.

        :return: The MAC tag. Binary form.
        :rtype: byte string
        )rrrr
rreadrs r digestzKMAC_Hash.digestKsVy	<L
d.>.B C CDDD))$*:;;DIyr"c~ddt|DS)zReturn the **printable** MAC tag of the message.

        :return: The MAC tag. Hexadecimal encoded.
        :rtype: string
        c2g|]}dt|zS)z%02x)r).0xs  r 
<listcomp>z'KMAC_Hash.hexdigest.<locals>.<listcomp>_s#GGGQa(GGGr")jointupler)r(s r 	hexdigestzKMAC_Hash.hexdigestXs5wwGG%

2F2FGGGHHHr"ctd}tj||z}tj||z}||krt	ddS)a`Verify that a given **binary** MAC (computed by another party)
        is valid.

        Args:
          mac_tag (bytes/bytearray/memoryview): the expected MAC of the message.

        Raises:
            ValueError: if the MAC does not match. It means that the message
                has been tampered with or that the MAC key is incorrect.
        zMAC check failedN)rr
newr)
ValueError)rmac_tagsecretmac1mac2s     r verifyzKMAC_Hash.verifyass""%%|FW,--|FT[[]]233;;==DKKMM))/000*)r"cd|tt|dS)anVerify that a given **printable** MAC (computed by another party)
        is valid.

        Args:
            hex_mac_tag (string): the expected MAC of the message, as a hexadecimal string.

        Raises:
            ValueError: if the MAC does not match. It means that the message
                has been tampered with or that the MAC key is incorrect.
        N)r;rr)rhex_mac_tags  r 	hexverifyzKMAC_Hash.hexverifyus,	
Igk223344444r"c6d|vr
|j|d<tdi|S)zNReturn a new instance of a KMAC hash object.
        See :func:`new`.
        r)rr5)rkwargss  r r5z
KMAC_Hash.news,
F"" $ 0F9}}V}}r"N)__name__
__module____qualname____doc__r!rr)r2r;r>r5r@r"r rr(s

&
&
&III111(555r"rc	|dd}t|stdt|dkrt	d|dd}|dd}|d	krt	d
|dd}|rtd
t|zt
||||dtdS)aCreate a new KMAC128 object.

    Args:
        key (bytes/bytearray/memoryview):
            The key to use to compute the MAC.
            It must be at least 128 bits long (16 bytes).
        data (bytes/bytearray/memoryview):
            Optional. The very first chunk of the message to authenticate.
            It is equivalent to an early call to :meth:`KMAC_Hash.update`.
        mac_len (integer):
            Optional. The size of the authentication tag, in bytes.
            Default is 64. Minimum is 8.
        custom (bytes/bytearray/memoryview):
            Optional. A customization byte string (``S`` in SP 800-185).

    Returns:
        A :class:`KMAC_Hash` hash object
    rNzYou must pass a key to KMAC128r4z1The key must be at least 128 bits long (16 bytes)rr@r&z!'mac_len' must be 8 bytes or morerr"zUnknown parameters: 19)poprr$lenr6strrr	)rArrrrs     r r5r5s(**UD
!
!CC==:8999
3xx"}}LMMM::fd##DjjB''G{{<===
ZZ#
&
&F
>.V<===T3y#FFFr"N)binasciirCrypto.Util.py3compatrrr
Crypto.Randomrr+r	r
rrr
objectrr5r@r"r <module>rQs>9999999999******!!!!!!!!;;;;;;;;;;ccccccccL%G%G%G%G%Gr"
Back to Directory File Manager