Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Handling FIPS mode in upstream projects for RHEL

February 27, 2024
Jakub Jelen
Related topics:
LinuxSecurity
Related products:
Red Hat Enterprise Linux

Share:

    This article is intended for the upstream developers or upstream contributors that are interested in adding or improving the support of their component for Red Hat Enterprise Linux (RHEL) in FIPS mode, outlining best practices or examples of behavior that is being discouraged.

    Federal Information Processing Standards (FIPS) 140

    The FIPS Publication 140 is a series of computer security standards developed by the National Institute of Standards and Technology (NIST) to ensure the quality of cryptographic modules. The FIPS 140 standard ensures that cryptographic tools implement their algorithms correctly. Runtime cryptographic algorithms and integrity self-tests are some of the mechanisms to ensure a system uses cryptography that meets the requirements of the standard. For more information about FIPS 140, see the specific chapter in Red Hat Enterprise Linux documentation.

    FIPS mode in Red Hat Enterprise Linux

    Red Hat Enterprise Linux implements the FIPS mode as a system-wide property. This means that the whole system is either in the FIPS mode or not, from kernel through the crypto modules to the applications. This might not apply to all other Linux distributions or generally to other FIPS modules out there though.

    FIPS mode is relevant not only to the validated modules (cryptographic libraries and kernel), but also to applications that are using some cryptographic algorithms or protocols. These applications might need to do some adjustments to the cryptographic algorithms used, provide graceful fallback and should not attempt to modify the FIPS status of the system with user-facing options.

    FIPS approved algorithms

    The Federal Information Processing Standard (FIPS) specification provides guidelines for cryptographic algorithms that are allowed while the applications or libraries are operating in FIPS mode. The guidance is evolving and differs among FIPS versions, libraries we certify, and Red Hat Enterprise Linux versions so I will not go into specific algorithms here. You can find the current certificates in an article on the Red Hat Customer Portal, describing approved algorithms in detail. Currently approved algorithms are also visible in the cryptographic policies, for example the current policy for Red Hat Enterprise Linux 9, providing human-readable summary of approved algorithms, sizes, modes, and more.

    FIPS mode in end-user applications

    Some applications provide a build-time configuration of the FIPS mode. This is not a good fit for Red Hat Enterprise Linux as we provide a single set of binaries that needs to work in both modes and using the FIPS mode by default might be too restricting for a general use case.

    Some upstream applications provide runtime options to switch the application to the FIPS compliant mode. From the certification point of view, this results in an unknown state that can’t be claimed as FIPS compliant. This is because the FIPS mode is managed on the system-wide level and applications can not affect this state. The applications need to query the cryptographic library for the FIPS status and behave based on this information (and not the other way round). For example in the case of OpenSSL, there is the EVP_default_properties_is_fips_enabled() function. In libgcrypt, there is the gcry_fips_mode_active() function for checking the system FIPS mode and GnuTLS provides a function gnutls_fips140_mode_enabled(). Without any cryptographic library, the kernel FIPS mode is identified by “1” in the file /proc/sys/crypto/fips_enabled.

    When the application detects the FIPS mode is enabled in the underlying cryptographic library, it should do the following:

    • When it is doing some high-level protocol algorithm negotiation, it should NOT negotiate any algorithm that is not FIPS approved (see above, for example Curve25519 key exchange). This includes both algorithms implemented by the cryptographic library itself but also bundled/custom implementations (if any). The crypto-policies should be able to help with selecting sane defaults for high-level protocols.
    • When using low-level cryptographic algorithms, it should use sane defaults and handle failures gracefully. Even though the algorithm or key size might be allowed now, it might be disallowed in the future. The key/algorithm might be also provided by the remote peer not aware of the local FIPS mode so the application needs to fall back to a different algorithm, if protocol permits.

    Testing applications in FIPS mode

    When upstreams are confronted with something they are not familiar with, they usually require a way to reproduce the issues and a way to test them. Most of them have some automated tests integrated in GitHub Actions so emulating the FIPS mode in this environment is fortunately pretty simple.

    • Use the quay.io/centos/centos:stream9 container for the most-recent experience (if you need to extend the coverage with different version, using stream8 is recommended)
    • The crypto policies should be changed to the FIPS policy (ignore the warnings):
      • update-crypto-policies --set FIPS
    • To simulate FIPS mode for all userspace applications, bind-mount a file containing non-zero value to /proc/sys/crypto/fips_enabled. Note that this won’t switch the kernel to the FIPS mode! For example:
      mkdir -p /var/tmp/userspace-fips
      
      echo 1 > /var/tmp/userspace-fips/fips_enabled
      
      mount --bind /var/tmp/userspace-fips/fips_enabled /proc/sys/crypto/fips_enabled
    • If the above does not work in your CI (for example, GitLab), you can use the environment variables to enforce FIPS mode in our libraries:
      • OPENSSL_FORCE_FIPS_MODE=1 will force OpenSSL into FIPS mode.
      • LIBGCRYPT_FORCE_FIPS_MODE=1 will force libgcrypt into FIPS mode.
      • GNUTLS_FORCE_FIPS_MODE=1 will force GnuTLS into FIPS mode.
    • Run the application testsuite as usual.
     

    Warning alert: Warning

    Do not use the above steps in production! They are meant only to emulate FIPS mode for testing and simple integration into the CI. To use FIPS mode in a production environment, see the official documentation.

    Related Posts

    • Is your Go application FIPS compliant?

    • Red Hat build of Keycloak provides FIPS-140-2 support

    • Go and FIPS 140-2 on Red Hat Enterprise Linux

    • How to improve Go FIPS test coverage with Packit

    • Why you should use io_uring for network I/O

    • Recommended compiler and linker flags for GCC

    Recent Posts

    • How to enable Ansible Lightspeed intelligent assistant

    • Why some agentic AI developers are moving code from Python to Rust

    • Confidential VMs: The core of confidential containers

    • Benchmarking with GuideLLM in air-gapped OpenShift clusters

    • Run Qwen3-Next on vLLM with Red Hat AI: A step-by-step guide

    What’s up next?

    Read A developer's guide to setting supply chain security in DevSecOps for a short introduction to software supply chain security, including the key principles, tools, and techniques you need to know to better audit and act on vulnerabilities in open source software components.

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue