:py:mod:`pylibressl.mac` ======================== .. py:module:: pylibressl.mac .. autoapi-nested-parse:: Message Authentication Codes. Signing example: >>> from pylibressl.mac import HMAC_Streebog512 >>> data = b'Some data to sign' >>> private_key = b'Some private key 12345678990asdfghjkl' >>> signature = HMAC_Streebog512(private_key).sign(data) Verifying example: >>> from pylibressl.mac import HMAC_Streebog512 >>> data = b'Some data to verify' >>> private_key = b'Some private key 12345678990asdfghjkl' >>> signature = b'signature' >>> >>> if HMAC_Streebog512(private_key).verify(data, signature): >>> print('Signature is ok') >>> else: >>> print('Data or signature are corrupt!') Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 hmac/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: pylibressl.mac.HMAC Attributes ~~~~~~~~~~ .. autoapisummary:: pylibressl.mac.HMAC_Streebog512 .. py:class:: HMAC(private_key) Bases: :py:obj:`object` Generic HMAC class. .. py:method:: new(cls, hash_type, name='NewHMAC') :classmethod: Create new HMAC class with specified digest. .. py:method:: _sign(self, data) .. py:method:: sign(self, data) Sign a message using HMAC. .. py:method:: verify(self, data, auth_code) Verify message authencity using HMAC signature. .. py:method:: sign_size(self) Return size of an authentication code. .. py:data:: HMAC_Streebog512