pylibressl.mac¶
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¶
Package Contents¶
Attributes¶
- class pylibressl.mac.HMAC(private_key)¶
Bases:
objectGeneric HMAC class.
- classmethod new(cls, hash_type, name='NewHMAC')¶
Create new HMAC class with specified digest.
- _sign(self, data)¶
- sign(self, data)¶
Sign a message using HMAC.
- verify(self, data, auth_code)¶
Verify message authencity using HMAC signature.
- sign_size(self)¶
Return size of an authentication code.
- pylibressl.mac.HMAC_Streebog512¶