pylibressl.cipher.auth

Module Contents

Classes

BaseCipherAuth

Base symmetric cipher class.

CipherHMAC

Ready to use cipher+HMAC combination.

BaseCipherGCM

Base GCM symmetric cipher class.

AES256_GCM

AES 256-bit cipher in GCM (Galois counter) mode.

Attributes

GOST89_HMAC_Streebog512

__doc__

AES256_HMAC_SHA512

__doc__

class pylibressl.cipher.auth.BaseCipherAuth(key, iv)

Bases: pylibressl.cipher.cipher.BaseCipher

Base symmetric cipher class.

abstract encrypt(self, data)
abstract decrypt(self, data, auth_code)
class pylibressl.cipher.auth.CipherHMAC(key, iv)

Bases: BaseCipherAuth

Ready to use cipher+HMAC combination.

classmethod new(cls, cipher_type, hash_type, name='NewCipherHMAC')

Create new cipher+HMAC type.

encrypt(self, data)

Encrypt a message.

Parameters

data – data to encrypt as a byte string

Returns

encrypted message and authencity code as byte strings

decrypt(self, data, auth_code)

Encrypt a message.

Parameters
  • data – data to encrypt as a byte string

  • auth_code – authencity code as byte strings

Returns

decrypted message

pylibressl.cipher.auth.GOST89_HMAC_Streebog512
pylibressl.cipher.auth.__doc__ = GOST89-HMAC-Streebog512
pylibressl.cipher.auth.AES256_HMAC_SHA512
pylibressl.cipher.auth.__doc__ = AES256-HMAC-SHA512
class pylibressl.cipher.auth.BaseCipherGCM(key, iv)

Bases: BaseCipherAuth

Base GCM symmetric cipher class.

_AEAD_TAG_SIZE = 16
classmethod iv_length(self)
_init_cipher_ctx(self, is_encrypt)

Initialise cipher context.

Should return cipher context cdata. It should be ready to do EVP_CipherUpdate.

encrypt(self, data, aad=None)

Encrypt a message.

Parameters
  • data – data to encrypt as a byte string

  • aad – AAD data for GCM mode

Returns

encrypted message and tag as byte strings

decrypt(self, data, tag, aad=None)

Decrypt a message.

Parameters
  • data – data to encrypt as a byte string

  • tag – tag value

  • aad – AAD data for GCM mode

Returns

decrypted message

class pylibressl.cipher.auth.AES256_GCM(key, iv)

Bases: BaseCipherGCM

AES 256-bit cipher in GCM (Galois counter) mode.

_CIPHER_ID
_MODE