Module ImportFrom alias alias Import alias FunctionDef arguments args NameParam defaults body Expr Str If BoolOpAnd Call NameLoad NameLoad NameLoad CompareEq NameLoad Num body Return If BoolOpAnd Call NameLoad NameLoad NameLoad CompareEq NameLoad NameLoad body Return Raise Call NameLoad BinOpMod Str TupleLoad Call NameLoad Call NameLoad NameLoad Call NameLoad NameLoad decorator_list ClassDef bases NameLoad body Expr Str Assign NameStore ListLoad Str Str FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If NameLoad body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Return orelse Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr NameLoad If CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Raise Call NameLoad BinOpMod Str NameLoad If CompareIn Str Call AttributeLoad NameLoad attr body Assign AttributeStore NameLoad attr NameLoad If CompareIn Str Call AttributeLoad NameLoad attr body Raise Call NameLoad Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Num body Expr Str Assign NameStore Call NameLoad NameLoad Expr Call NameLoad CompareEq Call NameLoad NameLoad Call AttributeLoad NameLoad attr Expr Call NameLoad CompareIn NameLoad ListLoad Num Num If UnaryOpNot AttributeLoad NameLoad attr body Expr Call NameLoad CompareEq Call NameLoad NameLoad Call AttributeLoad NameLoad attr Expr Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad NameLoad orelse Expr Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad NameLoad AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Num NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Num NameLoad Expr Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Assign AttributeStore NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr NameLoad NameLoad keyword Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr NameLoad NameLoad keyword Num decorator_list FunctionDef arguments args NameParam defaults body Pass decorator_list FunctionDef arguments args defaults body Expr Str Return Call NameLoad NameLoad Call AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args defaults body Expr Str Return Call NameLoad NameLoad Call AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args defaults body Expr Str Return Call NameLoad NameLoad Call AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad Num body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad AugAssignAdd NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad TryExcept body AugAssignAdd NameStore Call AttributeLoad NameLoad attr handlers ExceptHandler body Raise Call NameLoad Str Return NameLoad decorator_list decorator_list ClassDef bases NameLoad body Assign NameStore ListLoad Str Str Str FunctionDef arguments args NameParam NameParam defaults body Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore BinOpAdd BinOpAdd Call NameLoad NameLoad NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr Str Assign SubscriptStore NameLoad Index Num NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad Expr Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Call NameLoad NameLoad Assign NameStore Call NameLoad SubscriptLoad Call AttributeLoad NameLoad attr NameLoad Slice Call NameLoad SubscriptLoad NameLoad Index Num Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Assign SubscriptStore NameLoad Index Num NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad TryExcept body Expr Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad If CompareEq SubscriptLoad NameLoad Index Num Num body Return Str Assign NameStore Call NameLoad SubscriptLoad Call AttributeLoad NameLoad attr NameLoad Slice Call NameLoad SubscriptLoad NameLoad Index Num Return NameLoad handlers ExceptHandler body Raise Call NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If CompareEq AttributeLoad NameLoad attr Num body Expr Call AttributeLoad NameLoad attr BinOpMult Str Num Assign NameStore Call AttributeLoad NameLoad attr Str Expr Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad Call NameLoad NameLoad Expr Call NameLoad CompareEq SubscriptLoad NameLoad Index Num Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults Num body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad Expr Call NameLoad NameLoad Assign NameStore Call NameLoad SubscriptLoad Call AttributeLoad NameLoad attr NameLoad Slice Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list decorator_list FunctionDef arguments args defaults body Assign NameStore Call NameLoad Str Assert CompareNotEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assert CompareEq Call AttributeLoad NameLoad attr Num Assert CompareEq Call AttributeLoad NameLoad attr Num Assert CompareEq Call AttributeLoad NameLoad attr Num Assert CompareEq Call AttributeLoad NameLoad attr Num Delete NameDel decorator_list FunctionDef arguments args defaults body With Call AttributeLoad NameLoad attr NameLoad NameStore body Assign NameStore Call NameLoad Str Assert CompareIn Str Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args defaults body Assign NameStore Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Assign NameStore BinOpMult Str Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad AugAssignAdd NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num keyword Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad AugAssignAdd NameStore Call AttributeLoad NameLoad attr Assert CompareEq NameLoad NameLoad decorator_list FunctionDef arguments args defaults body Assign NameStore Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Assign NameStore BinOpMult Str Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad AugAssignAdd NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num keyword Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad AugAssignAdd NameStore Call AttributeLoad NameLoad attr Assert CompareEq NameLoad NameLoad decorator_list FunctionDef arguments args defaults body Assign NameStore Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Assign NameStore BinOpMult Str Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad AugAssignAdd NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad AugAssignAdd NameStore Call AttributeLoad NameLoad attr Assert CompareEq NameLoad NameLoad decorator_list FunctionDef arguments args defaults body Assign NameStore Call AttributeLoad NameLoad attr Assert AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assert CompareEq NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Num Assert CompareEq Call NameLoad NameLoad Num decorator_list FunctionDef arguments args defaults body Assign NameStore Call AttributeLoad NameLoad attr Assert AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assert CompareEq NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Num Assert CompareEq Call NameLoad NameLoad Num decorator_list FunctionDef arguments args defaults body Assign NameStore Call AttributeLoad NameLoad attr Assert AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assert CompareEq NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Num Assert CompareEq Call NameLoad NameLoad Num decorator_list FunctionDef arguments args defaults body Assign NameStore Call AttributeLoad NameLoad attr Assert AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assert CompareEq NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Num Assert CompareEq Call NameLoad NameLoad Num Return TupleLoad NameLoad NameLoad NameLoad NameLoad decorator_list AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Assert CompareEq NameLoad Str decorator_list FunctionDef arguments args NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad With Call AttributeLoad NameLoad attr NameLoad NameStore body Expr Call AttributeLoad NameLoad attr Assert CompareIn Str Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad With Call AttributeLoad NameLoad attr NameLoad NameStore body Expr Call AttributeLoad NameLoad attr Assert CompareIn Str Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Assign TupleStore NameStore NameStore NameStore NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad With Call AttributeLoad NameLoad attr NameLoad NameStore body Expr Call AttributeLoad NameLoad attr Assert CompareIn Str Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args defaults body Assign NameStore Call NameLoad Str Assert AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assert CompareEq NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Num Assert CompareEq Call NameLoad NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Assert CompareEq NameLoad Str decorator_list FunctionDef arguments args defaults body Assign NameStore Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Num Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Num Assign NameStore Call AttributeLoad NameLoad attr keyword BinOpMult Str Num keyword BinOpMult Str Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Num Assert CompareEq NameLoad NameLoad Assert CompareNotEq NameLoad NameLoad decorator_list FunctionDef arguments args defaults body Assign NameStore Call NameLoad Str Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr BinOpMult Str Num BinOpMult Str Num Str Assign NameStore Call AttributeLoad NameLoad attr BinOpMult Str Num BinOpMult Str Num NameLoad NameLoad Assert CompareEq NameLoad Str decorator_list FunctionDef arguments args defaults body Assign NameStore Call NameLoad Str Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr BinOpMult Str Num BinOpMult Str Num Str keyword Str Assign NameStore Call AttributeLoad NameLoad attr BinOpMult Str Num BinOpMult Str Num NameLoad NameLoad keyword Str Assert CompareEq NameLoad Str decorator_list
N/A bindings _FFI _C N/A pytest _check N/A N/A return_val N/A N/A N/A Checks the return code of the C calls N/A N/A N/A isinstance return_val int N/A return_val 1 N/A N/A N/A N/A N/A isinstance return_val bool N/A return_val True N/A N/A N/A N/A Exception N/A Cipher exception: Unknown type %s or value %s N/A N/A str N/A type return_val N/A str return_val N/A Cipher N/A object N/A N/A  A class representing a symmetric cipher and mode.

    Example:
        An example of encryption and decryption using AES in counter mode.

        >>> from os import urandom
        >>> aes = Cipher("AES-128-CTR")     # Init AES in Counter mode
        >>> key = urandom(16)
        >>> iv  = urandom(16)
        >>>
        >>> # Get a CipherOperation object for encryption
        >>> enc = aes.enc(key, iv)
        >>> ref = b"Hello World"
        >>> ciphertext = enc.update(ref)
        >>> ciphertext += enc.finalize()
        >>>
        >>> # Get a CipherOperation object for decryption
        >>> dec = aes.dec(key, iv)
        >>> plaintext = dec.update(ciphertext)
        >>> plaintext += dec.finalize()
        >>> plaintext == ref # Check resulting plaintest matches referece one.
        True

     N/A __slots__ N/A alg gcm __init__ N/A N/A self name _alg N/A None N/A N/A Initialize the cipher by name. N/A _alg N/A N/A N/A self alg _alg N/A N/A self gcm True N/A N/A N/A N/A self alg N/A N/A _C EVP_get_cipherbyname N/A N/A name encode utf8 N/A N/A self gcm False N/A N/A N/A self alg N/A _FFI NULL N/A N/A N/A Exception N/A Unknown cipher: %s name N/A N/A gcm N/A N/A name lower N/A N/A N/A self gcm True N/A N/A ccm N/A N/A name lower N/A N/A N/A Exception CCM mode not supported N/A len_IV N/A N/A self N/A N/A N/A Return the Initialization Vector length in bytes. N/A N/A int N/A N/A self alg iv_len N/A len_key N/A N/A self N/A N/A N/A Return the secret key length in bytes. N/A N/A int N/A N/A self alg key_len N/A len_block N/A N/A self N/A N/A N/A Return the block size in bytes. N/A N/A int N/A N/A self alg block_size N/A get_nid N/A N/A self N/A N/A N/A Return the OpenSSL nid of the cipher and mode. N/A N/A int N/A N/A self alg nid N/A op N/A N/A self key iv enc N/A 1 N/A N/A Initializes a cipher operation, either encrypt or decrypt 
        and returns a CipherOperation object

        Args:
            key (str): the block cipher symmetric key. Length depends on block cipher choice.
            iv (str): an Initialization Vector of up to the block size. (Can be shorter.)
            enc (int): set to 1 to perform encryption, or 0 to perform decryption.

         N/A c_op N/A CipherOperation enc N/A N/A _check N/A N/A len key N/A N/A self len_key N/A N/A _check N/A enc N/A 0 1 N/A N/A N/A self gcm N/A N/A N/A _check N/A N/A len iv N/A N/A self len_IV N/A N/A _check N/A N/A _C EVP_CipherInit_ex N/A c_op ctx N/A self alg N/A _FFI NULL key iv enc N/A N/A N/A _check N/A N/A _C EVP_CipherInit_ex N/A c_op ctx N/A self alg N/A _FFI NULL N/A _FFI NULL N/A _FFI NULL enc N/A N/A _check N/A N/A _C EVP_CIPHER_CTX_ctrl N/A c_op ctx N/A _C EVP_CTRL_GCM_SET_IVLEN N/A len iv N/A _FFI NULL N/A N/A N/A _C EVP_CIPHER_CTX_ctrl N/A c_op ctx N/A _C EVP_CTRL_GCM_SET_IV_FIXED -1 iv N/A N/A N/A _C EVP_CIPHER_CTX_ctrl N/A c_op ctx N/A _C EVP_CTRL_GCM_IV_GEN 0 iv N/A N/A _check N/A N/A _C EVP_CipherInit_ex N/A c_op ctx N/A _FFI NULL N/A _FFI NULL key iv enc N/A N/A c_op cipher self N/A c_op N/A enc N/A N/A self key iv N/A N/A N/A Initializes an encryption engine with the cipher with a specific key and Initialization Vector (IV). 
        Returns the CipherOperation engine.

        Args:
            key (str): the block cipher symmetric key. Length depends on block cipher choice.
            iv (str): an Initialization Vector of up to the block size. (Can be shorter.)

         N/A N/A N/A self op key iv enc 1 N/A dec N/A N/A self key iv N/A N/A N/A Initializes a decryption engine with the cipher with a specific key and Initialization Vector (IV). 
        Returns the CipherOperation engine.

        Args:
            key (str): the block cipher symmetric key. Length depends on block cipher choice.
            iv (str): an Initialization Vector of up to the block size. (Can be shorter.)

         N/A N/A N/A self op key iv enc 0 N/A __del__ N/A N/A self N/A N/A N/A N/A aes_128_gcm N/A N/A N/A N/A N/A Returns a pre-initalized AES-GCM cipher with 128 bits key size N/A N/A Cipher None N/A N/A _C EVP_aes_128_gcm N/A staticmethod aes_192_gcm N/A N/A N/A N/A N/A Returns a pre-initalized AES-GCM cipher with 192 bits key size N/A N/A Cipher None N/A N/A _C EVP_aes_192_gcm N/A staticmethod aes_256_gcm N/A N/A N/A N/A N/A Returns a pre-initalized AES-GCM cipher with 256 bits key size N/A N/A Cipher None N/A N/A _C EVP_aes_256_gcm N/A staticmethod quick_gcm_enc N/A N/A self key iv msg assoc tagl N/A None 16 N/A N/A One operation GCM encryption.

        Args:
            key (str): the AES symmetric key. Length depends on block cipher choice.
            iv (str): an Initialization Vector of up to the block size. (Can be shorter.)
            msg (str): the message to encrypt.
            assoc (str): associated data that will be integrity protected, but not encrypted.
            tagl (int): the length of the tag, up to the block length.

        Example: 
            Use of `quick_gcm_enc` and `quick_gcm_dec` for AES-GCM operations.

            >>> from os import urandom      # Secure OS random source
            >>> aes = Cipher("aes-128-gcm") # Initialize AES-GCM with 128 bit keys
            >>> iv = urandom(16)
            >>> key = urandom(16)
            >>> # Encryption using AES-GCM returns a ciphertext and a tag
            >>> ciphertext, tag = aes.quick_gcm_enc(key, iv, b"Hello")
            >>> # Decrytion using AES-GCM
            >>> p = aes.quick_gcm_dec(key, iv, ciphertext, tag)
            >>> assert p == b'Hello'

         N/A enc N/A N/A self enc key iv N/A assoc N/A N/A N/A N/A enc update_associated assoc N/A ciphertext N/A N/A enc update msg N/A ciphertext N/A N/A enc finalize N/A tag N/A N/A enc get_tag tagl N/A N/A ciphertext tag N/A quick_gcm_dec N/A N/A self key iv cip tag assoc N/A None N/A N/A One operation GCM decrypt. See usage example in "quick_gcm_enc". 
        Throws an exception on failure of decryption

        Args:
            key (str): the AES symmetric key. Length depends on block cipher choice.
            iv (str): an Initialization Vector of up to the block size. (Can be shorter.)
            cip (str): the ciphertext to decrypt.
            tag (int): the integrity tag.
            assoc (str): associated data that will be integrity protected, but not encrypted.

         N/A dec N/A N/A self dec key iv N/A assoc N/A N/A N/A N/A dec update_associated assoc N/A N/A N/A dec set_tag tag N/A plain N/A N/A dec update cip N/A N/A N/A plain N/A N/A dec finalize N/A N/A N/A N/A N/A Exception Cipher: decryption failed. N/A plain N/A N/A CipherOperation N/A object N/A N/A __slots__ N/A ctx cipher xenc __init__ N/A N/A self xenc N/A N/A N/A N/A self ctx N/A N/A _C EVP_CIPHER_CTX_new N/A N/A N/A _C EVP_CIPHER_CTX_init N/A self ctx N/A N/A self cipher None N/A N/A self xenc xenc N/A update N/A N/A self data N/A N/A N/A Processes some data, and returns a partial result. N/A block_len N/A N/A N/A self cipher len_block N/A alloc_len N/A N/A N/A len data block_len 1 N/A outl N/A N/A _FFI new int * N/A N/A outl N/A 0 alloc_len N/A out N/A N/A _FFI new unsigned char[] alloc_len N/A N/A _check N/A N/A _C EVP_CipherUpdate N/A self ctx out outl data N/A len data N/A ret N/A bytes N/A N/A N/A _FFI buffer out N/A N/A int N/A outl N/A 0 N/A ret N/A finalize N/A N/A self N/A N/A N/A Finalizes the operation and may return some additional data. 
        Throws an exception if the authenticator tag is different from the expected value.
        
        Example:
            Example of the exception thrown when an invalid tag is provided.
            
            >>> from os import urandom
            >>> aes = Cipher.aes_128_gcm()              # Define an AES-GCM cipher
            >>> iv = urandom(16)
            >>> key = urandom(16)
            >>> ciphertext, tag = aes.quick_gcm_enc(key, iv, b"Hello")
            >>>
            >>> dec = aes.dec(key, iv)                  # Get a decryption CipherOperation
            >>> dec.set_tag(urandom(len(tag)))          # Provide an invalid tag.
            >>> plaintext = dec.update(ciphertext)      # Feed in the ciphertext for decryption.
            >>> try:
            ...    dec.finalize()                       # Check and Finalize.
            ... except:
            ...    print("Failure")
            Failure
            
            Throws an exception since integrity check fails due to the invalid tag.
        
         N/A block_len N/A N/A N/A self cipher len_block N/A alloc_len block_len N/A outl N/A N/A _FFI new int * N/A N/A outl N/A 0 alloc_len N/A out N/A N/A _FFI new unsigned char[] alloc_len N/A N/A N/A N/A _check N/A N/A _C EVP_CipherFinal_ex N/A self ctx out outl N/A N/A N/A outl N/A 0 0 N/A N/A N/A ret N/A bytes N/A N/A N/A _FFI buffer out N/A N/A int N/A outl N/A 0 N/A ret N/A N/A N/A N/A N/A Exception Cipher: decryption failed. N/A update_associated N/A N/A self data N/A N/A N/A Processes some GCM associated data, and returns nothing. N/A N/A N/A self xenc 0 N/A N/A N/A N/A self set_tag N/A 16 N/A outl N/A N/A _FFI new int * N/A N/A _check N/A N/A _C EVP_CipherUpdate N/A self ctx N/A _FFI NULL outl data N/A len data N/A N/A _check N/A N/A outl N/A 0 N/A len data N/A get_tag N/A N/A self tag_len N/A 16 N/A N/A Get the GCM authentication tag. Execute after finalizing the encryption.

        Example: 
            AES-GCM encryption usage:

            >>> from os import urandom
            >>> aes = Cipher.aes_128_gcm()          # Initialize AES cipher
            >>> key = urandom(16)
            >>> iv = urandom(16)
            >>> enc = aes.enc(key, iv)              # Get an encryption CipherOperation
            >>> enc.update_associated(b"Hello")     # Include some associated data
            >>> ciphertext = enc.update(b"World!")  # Include some plaintext
            >>> nothing = enc.finalize()            # Finalize
            >>> tag = enc.get_tag(16)               # Get the AES-GCM tag

         N/A tag N/A N/A _FFI new unsigned char [] tag_len N/A ret N/A N/A _C EVP_CIPHER_CTX_ctrl N/A self ctx N/A _C EVP_CTRL_GCM_GET_TAG tag_len tag N/A N/A _check ret N/A s N/A bytes N/A N/A N/A _FFI buffer tag N/A N/A s N/A set_tag N/A N/A self tag N/A N/A N/A Specify the GCM authenticator tag. Must be done before finalizing decryption

        Example:
            AES-GCM decryption and check:

            >>> aes = Cipher.aes_128_gcm()              # Define an AES-GCM cipher
            >>> ciphertext, tag = (b'dV\xb9:\xd0\xbe', b'pA\xbe?\xfc\xd1&\x03\x1438\xc5\xf8In\xaa')
            >>> dec = aes.dec(key=b"A"*16, iv=b"A"*16)  # Get a decryption CipherOperation
            >>> dec.update_associated(b"Hello")         # Feed in the non-secret assciated data.
            >>> plaintext = dec.update(ciphertext)      # Feed in the ciphertext for decryption.
            >>> dec.set_tag(tag)                        # Provide the AES-GCM tag for integrity. 
            >>> nothing = dec.finalize()                # Check and finalize.
            >>> assert plaintext == b'World!'

         N/A N/A _check N/A N/A _C EVP_CIPHER_CTX_ctrl N/A self ctx N/A _C EVP_CTRL_GCM_SET_TAG N/A len tag tag N/A __del__ N/A N/A self N/A N/A N/A N/A _check N/A N/A _C EVP_CIPHER_CTX_cleanup N/A self ctx N/A N/A N/A _C EVP_CIPHER_CTX_free N/A self ctx N/A N/A test_aes_init N/A N/A N/A N/A N/A aes N/A Cipher AES-128-CBC N/A N/A N/A aes alg N/A _FFI NULL N/A N/A N/A N/A aes len_IV 16 N/A N/A N/A N/A aes len_block 16 N/A N/A N/A N/A aes len_key 16 N/A N/A N/A N/A aes get_nid 419 N/A aes N/A test_errors N/A N/A N/A N/A N/A N/A N/A pytest raises Exception excinfo N/A N/A aes N/A Cipher AES-128-XXF N/A N/A Unknown N/A str N/A excinfo value N/A test_aes_enc N/A N/A N/A N/A N/A aes N/A Cipher AES-128-CBC N/A enc N/A N/A aes op key N/A A 16 iv N/A A 16 N/A ref N/A Hello World 10000 N/A ciphertext N/A N/A enc update ref N/A ciphertext N/A N/A enc finalize N/A dec N/A N/A aes op key N/A A 16 iv N/A A 16 enc 0 N/A plaintext N/A N/A dec update ciphertext N/A plaintext N/A N/A dec finalize N/A N/A plaintext ref N/A test_aes_ctr N/A N/A N/A N/A N/A aes N/A Cipher AES-128-CTR N/A enc N/A N/A aes op key N/A A 16 iv N/A A 16 N/A ref N/A Hello World 10000 N/A ciphertext N/A N/A enc update ref N/A ciphertext N/A N/A enc finalize N/A dec N/A N/A aes op key N/A A 16 iv N/A A 16 enc 0 N/A plaintext N/A N/A dec update ciphertext N/A plaintext N/A N/A dec finalize N/A N/A plaintext ref N/A test_aes_ops N/A N/A N/A N/A N/A aes N/A Cipher AES-128-CTR N/A enc N/A N/A aes enc key N/A A 16 iv N/A A 16 N/A ref N/A Hello World 10000 N/A ciphertext N/A N/A enc update ref N/A ciphertext N/A N/A enc finalize N/A dec N/A N/A aes dec key N/A A 16 iv N/A A 16 N/A plaintext N/A N/A dec update ciphertext N/A plaintext N/A N/A dec finalize N/A N/A plaintext ref N/A test_aes_gcm_encrypt N/A N/A N/A N/A N/A aes N/A N/A Cipher aes_128_gcm N/A N/A aes gcm N/A enc N/A N/A aes op key N/A A 16 iv N/A A 16 N/A N/A N/A enc update_associated Hello N/A ciphertext N/A N/A enc update World! N/A c2 N/A N/A enc finalize N/A N/A c2 N/A tag N/A N/A enc get_tag 16 N/A N/A N/A len tag 16 N/A test_aes_gcm_encrypt_192 N/A N/A N/A N/A N/A aes N/A N/A Cipher aes_192_gcm N/A N/A aes gcm N/A enc N/A N/A aes op key N/A A 24 iv N/A A 16 N/A N/A N/A enc update_associated Hello N/A ciphertext N/A N/A enc update World! N/A c2 N/A N/A enc finalize N/A N/A c2 N/A tag N/A N/A enc get_tag 16 N/A N/A N/A len tag 16 N/A test_aes_gcm_encrypt_256 N/A N/A N/A N/A N/A aes N/A N/A Cipher aes_256_gcm N/A N/A aes gcm N/A enc N/A N/A aes op key N/A A 32 iv N/A A 16 N/A N/A N/A enc update_associated Hello N/A ciphertext N/A N/A enc update World! N/A c2 N/A N/A enc finalize N/A N/A c2 N/A tag N/A N/A enc get_tag 16 N/A N/A N/A len tag 16 N/A aesenc N/A N/A N/A N/A N/A aes N/A N/A Cipher aes_128_gcm N/A N/A aes gcm N/A enc N/A N/A aes op key N/A A 16 iv N/A A 16 N/A N/A N/A enc update_associated Hello N/A ciphertext N/A N/A enc update World! N/A c2 N/A N/A enc finalize N/A N/A c2 N/A tag N/A N/A enc get_tag 16 N/A N/A N/A len tag 16 N/A N/A aes enc ciphertext tag N/A N/A pytest fixture test_gcm_dec N/A N/A aesenc N/A N/A N/A N/A aes enc ciphertext tag aesenc N/A dec N/A N/A aes dec key N/A A 16 iv N/A A 16 N/A N/A N/A dec update_associated Hello N/A plaintext N/A N/A dec update ciphertext N/A N/A N/A dec set_tag tag N/A N/A N/A dec finalize N/A N/A plaintext World! N/A test_gcm_dec_badassoc N/A N/A aesenc N/A N/A N/A N/A aes enc ciphertext tag aesenc N/A dec N/A N/A aes dec key N/A A 16 iv N/A A 16 N/A N/A N/A dec update_associated H4llo N/A plaintext N/A N/A dec update ciphertext N/A N/A N/A dec set_tag tag N/A N/A N/A pytest raises Exception excinfo N/A N/A N/A N/A dec finalize N/A N/A Cipher N/A str N/A excinfo value N/A test_gcm_dec_badkey N/A N/A aesenc N/A N/A N/A N/A aes enc ciphertext tag aesenc N/A dec N/A N/A aes dec key N/A B 16 iv N/A A 16 N/A N/A N/A dec update_associated Hello N/A plaintext N/A N/A dec update ciphertext N/A N/A N/A dec set_tag tag N/A N/A N/A pytest raises Exception excinfo N/A N/A N/A N/A dec finalize N/A N/A Cipher N/A str N/A excinfo value N/A test_gcm_dec_badiv N/A N/A aesenc N/A N/A N/A N/A aes enc ciphertext tag aesenc N/A dec N/A N/A aes dec key N/A A 16 iv N/A B 16 N/A N/A N/A dec update_associated Hello N/A plaintext N/A N/A dec update ciphertext N/A N/A N/A dec set_tag tag N/A N/A N/A pytest raises Exception excinfo N/A N/A N/A N/A dec finalize N/A N/A Cipher N/A str N/A excinfo value N/A test_aes_gcm_byname N/A N/A N/A N/A N/A aes N/A Cipher aes-128-gcm N/A N/A aes gcm N/A enc N/A N/A aes op key N/A A 16 iv N/A A 16 N/A N/A N/A enc update_associated Hello N/A ciphertext N/A N/A enc update World! N/A c2 N/A N/A enc finalize N/A N/A c2 N/A tag N/A N/A enc get_tag 16 N/A N/A N/A len tag 16 N/A dec N/A N/A aes dec key N/A A 16 iv N/A A 16 N/A N/A N/A dec update_associated Hello N/A plaintext N/A N/A dec update ciphertext N/A N/A N/A dec set_tag tag N/A N/A N/A dec finalize N/A N/A plaintext World! N/A test_aes_gcm_different_IV N/A N/A N/A N/A N/A aes N/A Cipher aes-128-gcm N/A enc N/A N/A aes op key N/A A 16 iv N/A A 16 N/A N/A N/A enc update_associated Hello N/A ciphertext N/A N/A enc update World! N/A c2 N/A N/A enc finalize N/A tag N/A N/A enc get_tag 16 N/A enc N/A N/A aes op key N/A A 16 iv N/A A 16 N/A N/A N/A enc update_associated Hello N/A ciphertext2 N/A N/A enc update World! N/A c2 N/A N/A enc finalize N/A tag2 N/A N/A enc get_tag 16 N/A enc N/A N/A aes op key N/A A 16 iv N/A B 16 N/A N/A N/A enc update_associated Hello N/A ciphertext3 N/A N/A enc update World! N/A c2 N/A N/A enc finalize N/A tag3 N/A N/A enc get_tag 16 N/A N/A ciphertext ciphertext2 N/A N/A ciphertext ciphertext3 N/A test_quick N/A N/A N/A N/A N/A aes N/A Cipher aes-128-gcm N/A N/A c t N/A N/A aes quick_gcm_enc N/A A 16 N/A A 16 Hello N/A p N/A N/A aes quick_gcm_dec N/A A 16 N/A A 16 c t N/A N/A p Hello N/A test_quick_assoc N/A N/A N/A N/A N/A aes N/A Cipher aes-128-gcm N/A N/A c t N/A N/A aes quick_gcm_enc N/A A 16 N/A A 16 Hello assoc blah N/A p N/A N/A aes quick_gcm_dec N/A A 16 N/A A 16 c t assoc blah N/A N/A p Hello N/A