Skip to content

AESGCM fails on RHEL9 in FIPS mode #14795

@schwabe

Description

@schwabe

Precondition: Have RHEL9 running in FIPS mode and cryptography 46

Small unit test minimal example:

def test_aes_gcm_encrypt():
        from cryptography.hazmat.primitives.ciphers.aead import AESGCM
        import os
    
        key = os.urandom(16)
        aesgcm = AESGCM(key)
    
        iv = os.urandom(12)
>       encrypted = aesgcm.encrypt(iv, b"I am a test", None)
E       cryptography.exceptions.InternalError: Unknown OpenSSL error. This error is commonly encountered
E                           when another library is not cleaning up the OpenSSL error
E                           stack. If you are using cryptography with another library
E                           that uses OpenSSL try disabling it before reporting a bug.
E                           Otherwise please file an issue at
E                           https://github.com/pyca/cryptography/issues with
E                           information on how to reproduce this. (error:030000BE:digital envelope routines:EVP_CIPHER_CTX_copy:not able to copy ctx:crypto/evp/evp_enc.c:1792:)

This has been test with 46.0.7 but is likely a regression added by 98dfafe. The version 41.0.7 from the Red Hat package python3.12-cryptography does not exhibit this problem.

A possible workaround is to use aesgcm = Cipher(algorithms.AES(key), modes.GCM(iv)).encryptor() instead as that still works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions