Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2160797

Summary: openssl smime and cms commands default to 3DES and PKCS#1v1.5 encryption in FIPS mode
Product: Red Hat Enterprise Linux 9 Reporter: Alicja Kario <hkario>
Component: opensslAssignee: Dmitry Belyavskiy <dbelyavs>
Status: CLOSED ERRATA QA Contact: Alicja Kario <hkario>
Severity: low Docs Contact: Petr Hybl <phybl>
Priority: low    
Version: 9.0CC: cllang, dbelyavs, jafiala
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: openssl-3.0.7-18.el9 Doc Type: Bug Fix
Doc Text:
.OpenSSL commands `cms` and `smime` can encrypt files in FIPS mode Previously, the default configuration of the `cms` and `smime` OpenSSL commands used legacy encryption algorithms, such as 3DES or PKCS #1 v1.5. These algorithms are disabled in FIPS mode. As a result, encrypting files by using the `smime` command with the default settings did not work on systems in FIPS mode. This update introduces the following changes: * In FIPS mode, OpenSSL APIs create CMS data by using OAEP with RSA keys by default. * In FIPS mode, the `cms` OpenSSL command creates CMS files encrypted with `aes-128-cbc` and OAEP when provided RSA keys. The use of ECDSA keys is unaffected. In non-FIPS mode, OpenSSL APIs and the `cms` command continue to use PKCS#1 v1.5 padding and 3DES encryption by default. As a consequence, you can use the `cms` and `smime` OpenSSL commands in FIPS mode to encrypt files.
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-07 08:52:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Alicja Kario 2023-01-13 18:14:09 UTC
Description of problem:
When the openssl smime command is used to encrypt email in FIPS mode, it still uses 3DES. Since that algorithm is not allowed in FIPS mode, the operation fails.

Version-Release number of selected component (if applicable):
openssl-3.0.7-2.el9.x86_64

How reproducible:
always

Steps to Reproduce:
Steps to Reproduce:
1. wget https://raw.githubusercontent.com/redhat-qe-security/certgen/master/certgen/lib.sh
2. source lib.sh
3. x509KeyGen ca
4. x509KeyGen client
5. x509SelfSign ca
6. x509CertSign --CA ca -t webclient client
7. echo 'Hello world' > message.txt
8. openssl smime -encrypt -in message.txt -out message.enc client/cert.pem

Actual results:
Error creating PKCS#7 structure
408C0F8F017F0000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:crypto/evp/evp_fetch.c:373:Global default library context, Algorithm (DES-EDE3-CBC : 27), Properties ()
408C0F8F017F0000:error:108C0100:PKCS7 routines:PKCS7_final:malloc failure:crypto/pkcs7/pk7_smime.c:80:

Expected results:
Email encrypted with an AES cipher and RSA-OAEP

Additional info:

setting -aes128 explicitly doesn't help as (I'm assuming) it's trying to use PKCS#1 v1.5 encryption with the provided RSA key, instead of RSA-OEAP:

Error creating PKCS#7 structure
40ACB4D62A7F0000:error:1C8000A5:Provider routines:rsa_encrypt:illegal or unsupported padding mode:providers/implementations/asymciphers/rsa_enc.c:163:
40ACB4D62A7F0000:error:108C0100:PKCS7 routines:PKCS7_final:malloc failure:crypto/pkcs7/pk7_smime.c:80:

Comment 1 Alicja Kario 2023-01-13 19:52:07 UTC
Same issue for cms command:

# openssl cms -encrypt -in message.txt -out message.enc client/cert.pem

403C7406297F0000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:crypto/evp/evp_fetch.c:373:Global default library context, Algorithm (DES-EDE3-CBC : 27), Properties ()
403C7406297F0000:error:17000065:CMS routines:ossl_cms_EncryptedContent_init_bio:cipher initialisation error:crypto/cms/cms_enc.c:78:
403C7406297F0000:error:17000068:CMS routines:CMS_final:cms lib:crypto/cms/cms_smime.c:882:


# openssl cms -encrypt -in message.txt -out message.enc -aes128 client/cert.pem

404C8805B77F0000:error:1C8000A5:Provider routines:rsa_encrypt:illegal or unsupported padding mode:providers/implementations/asymciphers/rsa_enc.c:163:
404C8805B77F0000:error:17000074:CMS routines:cms_EnvelopedData_Encryption_init_bio:error setting recipientinfo:crypto/cms/cms_env.c:1142:
404C8805B77F0000:error:17000068:CMS routines:CMS_final:cms lib:crypto/cms/cms_smime.c:882:

Comment 32 errata-xmlrpc 2023-11-07 08:52:59 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (openssl bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:6627