{
    "mode": "man",
    "parameter": "fips_module",
    "section": "7ssl",
    "url": "https://www.chedong.com/phpMan.php/man/fips_module/7ssl/json",
    "generated": "2026-06-03T02:31:40Z",
    "synopsis": "See the individual manual pages for details.",
    "sections": {
        "NAME": {
            "content": "fipsmodule - OpenSSL fips module guide\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "See the individual manual pages for details.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This guide details different ways that OpenSSL can be used in conjunction with the FIPS\nmodule. Which is the correct approach to use will depend on your own specific circumstances\nand what you are attempting to achieve.\n\nNote that the old functions FIPSmode() and FIPSmodeset() are no longer present so you must\nremove them from your application if you use them.\n\nApplications written to use the OpenSSL 3.0 FIPS module should not use any legacy APIs or\nfeatures that avoid the FIPS module. Specifically this includes:\n\n•   Low level cryptographic APIs (use the high level APIs, such as EVP, instead)\n\n•   Engines\n\n•   Any functions that create or modify custom \"METHODS\" (for example EVPMDmethnew(),\nEVPCIPHERmethnew(), EVPPKEYmethnew(), RSAmethnew(), ECKEYMETHODnew(), etc.)\n\nAll of the above APIs are deprecated in OpenSSL 3.0 - so a simple rule is to avoid using all\ndeprecated functions. See migrationguide(7) for a list of deprecated functions.\n",
            "subsections": [
                {
                    "name": "Making all applications use the FIPS module by default",
                    "content": "One simple approach is to cause all applications that are using OpenSSL to only use the FIPS\nmodule for cryptographic algorithms by default.\n\nThis approach can be done purely via configuration. As long as applications are built and\nlinked against OpenSSL 3.0 and do not override the loading of the default config file or its\nsettings then they can automatically start using the FIPS module without the need for any\nfurther code changes.\n\nTo do this the default OpenSSL config file will have to be modified. The location of this\nconfig file will depend on the platform, and any options that were given during the build\nprocess. You can check the location of the config file by running this command:\n\n$ openssl version -d\nOPENSSLDIR: \"/usr/local/ssl\"\n\nCaution: Many Operating Systems install OpenSSL by default. It is a common error to not have\nthe correct version of OpenSSL in your $PATH. Check that you are running an OpenSSL 3.0\nversion like this:\n\n$ openssl version -v\nOpenSSL 3.0.0-dev xx XXX xxxx (Library: OpenSSL 3.0.0-dev xx XXX xxxx)\n\nThe OPENSSLDIR value above gives the directory name for where the default config file is\nstored. So in this case the default config file will be called /usr/local/ssl/openssl.cnf.\n\nEdit the config file to add the following lines near the beginning:\n\nconfigdiagnostics = 1\nopensslconf = opensslinit\n\n.include /usr/local/ssl/fipsmodule.cnf\n\n[opensslinit]\nproviders = providersect\n\n[providersect]\nfips = fipssect\nbase = basesect\n\n[basesect]\nactivate = 1\n\nObviously the include file location above should match the path and name of the FIPS module\nconfig file that you installed earlier.  See\n<https://github.com/openssl/openssl/blob/master/README-FIPS.md>.\n\nFor FIPS usage, it is recommened that the configdiagnostics option is enabled to prevent\naccidental use of non-FIPS validated algorithms via broken or mistaken configuration.  See\nconfig(5).\n\nAny applications that use OpenSSL 3.0 and are started after these changes are made will start\nusing only the FIPS module unless those applications take explicit steps to avoid this\ndefault behaviour. Note that this configuration also activates the \"base\" provider. The base\nprovider does not include any cryptographic algorithms (and therefore does not impact the\nvalidation status of any cryptographic operations), but does include other supporting\nalgorithms that may be required. It is designed to be used in conjunction with the FIPS\nmodule.\n\nThis approach has the primary advantage that it is simple, and no code changes are required\nin applications in order to benefit from the FIPS module. There are some disadvantages to\nthis approach:\n\n•   You may not want all applications to use the FIPS module.\n\nIt may be the case that some applications should and some should not use the FIPS module.\n\n•   If applications take explicit steps to not load the default config file or set different\nsettings.\n\nThis method will not work for these cases.\n\n•   The algorithms available in the FIPS module are a subset of the algorithms that are\navailable in the default OpenSSL Provider.\n\nIf any applications attempt to use any algorithms that are not present, then they will\nfail.\n\n•   Usage of certain deprecated APIs avoids the use of the FIPS module.\n\nIf any applications use those APIs then the FIPS module will not be used.\n"
                },
                {
                    "name": "Selectively making applications use the FIPS module by default",
                    "content": "A variation on the above approach is to do the same thing on an individual application basis.\nThe default OpenSSL config file depends on the compiled in value for OPENSSLDIR as described\nin the section above. However it is also possible to override the config file to be used via\nthe OPENSSLCONF environment variable. For example the following, on Unix, will cause the\napplication to be executed with a non-standard config file location:\n\n$ OPENSSLCONF=/my/nondefault/openssl.cnf myapplication\n\nUsing this mechanism you can control which config file is loaded (and hence whether the FIPS\nmodule is loaded) on an application by application basis.\n\nThis removes the disadvantage listed above that you may not want all applications to use the\nFIPS module. All the other advantages and disadvantages still apply.\n"
                },
                {
                    "name": "Programmatically loading the FIPS module (default library context)",
                    "content": "Applications may choose to load the FIPS provider explicitly rather than relying on config to\ndo this. The config file is still necessary in order to hold the FIPS module config data\n(such as its self test status and integrity data). But in this case we do not automatically\nactivate the FIPS provider via that config file.\n\nTo do things this way configure as per \"Making all applications use the FIPS module by\ndefault\" above, but edit the fipsmodule.cnf file to remove or comment out the line which says\n\"activate = 1\" (note that setting this value to 0 is not sufficient).  This means all the\nrequired config information will be available to load the FIPS module, but it is not\nautomatically loaded when the application starts. The FIPS provider can then be loaded\nprogrammatically like this:\n\n#include <openssl/provider.h>\n\nint main(void)\n{\nOSSLPROVIDER *fips;\nOSSLPROVIDER *base;\n\nfips = OSSLPROVIDERload(NULL, \"fips\");\nif (fips == NULL) {\nprintf(\"Failed to load FIPS provider\\n\");\nexit(EXITFAILURE);\n}\nbase = OSSLPROVIDERload(NULL, \"base\");\nif (base == NULL) {\nOSSLPROVIDERunload(fips);\nprintf(\"Failed to load base provider\\n\");\nexit(EXITFAILURE);\n}\n\n/* Rest of application */\n\nOSSLPROVIDERunload(base);\nOSSLPROVIDERunload(fips);\nexit(EXITSUCCESS);\n}\n\nNote that this should be one of the first things that you do in your application. If any\nOpenSSL functions get called that require the use of cryptographic functions before this\noccurs then, if no provider has yet been loaded, then the default provider will be\nautomatically loaded. If you then later explicitly load the FIPS provider then you will have\nboth the FIPS and the default provider loaded at the same time. It is undefined which\nimplementation of an algorithm will be used if multiple implementations are available and you\nhave not explicitly specified via a property query (see below) which one should be used.\n\nAlso note that in this example we have additionally loaded the \"base\" provider.  This loads a\nsub-set of algorithms that are also available in the default provider - specifically non\ncryptographic ones which may be used in conjunction with the FIPS provider. For example this\ncontains algorithms for encoding and decoding keys. If you decide not to load the default\nprovider then you will usually want to load the base provider instead.\n\nIn this example we are using the \"default\" library context. OpenSSL functions operate within\nthe scope of a library context. If no library context is explicitly specified then the\ndefault library context is used. For further details about library contexts see the\nOSSLLIBCTX(3) man page.\n"
                },
                {
                    "name": "Loading the FIPS module at the same time as other providers",
                    "content": "It is possible to have the FIPS provider and other providers (such as the default provider)\nall loaded at the same time into the same library context. You can use a property query\nstring during algorithm fetches to specify which implementation you would like to use.\n\nFor example to fetch an implementation of SHA256 which conforms to FIPS standards you can\nspecify the property query \"fips=yes\" like this:\n\nEVPMD *sha256;\n\nsha256 = EVPMDfetch(NULL, \"SHA2-256\", \"fips=yes\");\n\nIf no property query is specified, or more than one implementation matches the property query\nthen it is undefined which implementation of a particular algorithm will be returned.\n\nThis example shows an explicit request for an implementation of SHA256 from the default\nprovider:\n\nEVPMD *sha256;\n\nsha256 = EVPMDfetch(NULL, \"SHA2-256\", \"provider=default\");\n\nIt is also possible to set a default property query string. The following example sets the\ndefault property query of \"fips=yes\" for all fetches within the default library context:\n\nEVPsetdefaultproperties(NULL, \"fips=yes\");\n\nIf a fetch function has both an explicit property query specified, and a default property\nquery is defined then the two queries are merged together and both apply. The local property\nquery overrides the default properties if the same property name is specified in both.\n\nThere are two important built-in properties that you should be aware of:\n\nThe \"provider\" property enables you to specify which provider you want an implementation to\nbe fetched from, e.g. \"provider=default\" or \"provider=fips\".  All algorithms implemented in a\nprovider have this property set on them.\n\nThere is also the \"fips\" property. All FIPS algorithms match against the property query\n\"fips=yes\". There are also some non-cryptographic algorithms available in the default and\nbase providers that also have the \"fips=yes\" property defined for them. These are the encoder\nand decoder algorithms that can (for example) be used to write out a key generated in the\nFIPS provider to a file. The encoder and decoder algorithms are not in the FIPS module itself\nbut are allowed to be used in conjunction with the FIPS algorithms.\n\nIt is possible to specify default properties within a config file. For example the following\nconfig file automatically loads the default and fips providers and sets the default property\nvalue to be \"fips=yes\". Note that this config file does not load the \"base\" provider. All\nsupporting algorithms that are in \"base\" are also in \"default\", so it is unnecessary in this\ncase:\n\nconfigdiagnostics = 1\nopensslconf = opensslinit\n\n.include /usr/local/ssl/fipsmodule.cnf\n\n[opensslinit]\nproviders = providersect\nalgsection = algorithmsect\n\n[providersect]\nfips = fipssect\ndefault = defaultsect\n\n[defaultsect]\nactivate = 1\n\n[algorithmsect]\ndefaultproperties = fips=yes\n"
                },
                {
                    "name": "Programmatically loading the FIPS module (nondefault library context)",
                    "content": "In addition to using properties to separate usage of the FIPS module from other usages this\ncan also be achieved using library contexts. In this example we create two library contexts.\nIn one we assume the existence of a config file called openssl-fips.cnf that automatically\nloads and configures the FIPS and base providers. The other library context will just use the\ndefault provider.\n\nOSSLLIBCTX *fipslibctx, *nonfipslibctx;\nOSSLPROVIDER *defctxnull = NULL;\nEVPMD *fipssha256 = NULL, *nonfipssha256 = NULL;\nint ret = 1;\n\n/*\n* Create two nondefault library contexts. One for fips usage and\n* one for non-fips usage\n*/\nfipslibctx = OSSLLIBCTXnew();\nnonfipslibctx = OSSLLIBCTXnew();\nif (fipslibctx == NULL || nonfipslibctx == NULL)\ngoto err;\n\n/* Prevent anything from using the default library context */\ndefctxnull = OSSLPROVIDERload(NULL, \"null\");\n\n/*\n* Load config file for the FIPS library context. We assume that\n* this config file will automatically activate the FIPS and base\n* providers so we don't need to explicitly load them here.\n*/\nif (!OSSLLIBCTXloadconfig(fipslibctx, \"openssl-fips.cnf\"))\ngoto err;\n\n/*\n* We don't need to do anything special to load the default\n* provider into nonfipslibctx. This happens automatically if no\n* other providers are loaded.\n* Because we don't call OSSLLIBCTXloadconfig() explicitly for\n* nonfipslibctx it will just use the default config file.\n*/\n\n/* As an example get some digests */\n\n/* Get a FIPS validated digest */\nfipssha256 = EVPMDfetch(fipslibctx, \"SHA2-256\", NULL);\nif (fipssha256 == NULL)\ngoto err;\n\n/* Get a non-FIPS validated digest */\nnonfipssha256 = EVPMDfetch(nonfipslibctx, \"SHA2-256\", NULL);\nif (nonfipssha256 == NULL)\ngoto err;\n\n/* Use the digests */\n\nprintf(\"Success\\n\");\nret = 0;\n\nerr:\nEVPMDfree(fipssha256);\nEVPMDfree(nonfipssha256);\nOSSLLIBCTXfree(fipslibctx);\nOSSLLIBCTXfree(nonfipslibctx);\nOSSLPROVIDERunload(defctxnull);\n\nreturn ret;\n\nNote that we have made use of the special \"null\" provider here which we load into the default\nlibrary context. We could have chosen to use the default library context for FIPS usage, and\njust create one additional library context for other usages - or vice versa. However if code\nhas not been converted to use library contexts then the default library context will be\nautomatically used.  This could be the case for your own existing applications as well as\ncertain parts of OpenSSL itself. Not all parts of OpenSSL are library context aware. If this\nhappens then you could \"accidentally\" use the wrong library context for a particular\noperation. To be sure this doesn't happen you can load the \"null\" provider into the default\nlibrary context. Because a provider has been explicitly loaded, the default provider will not\nautomatically load. This means code using the default context by accident will fail because\nno algorithms will be available.\n\nSee \"Library Context\" in migrationguide(7) for additional information about the Library\nContext.\n"
                },
                {
                    "name": "Using Encoders and Decoders with the FIPS module",
                    "content": "Encoders and decoders are used to read and write keys or parameters from or to some external\nformat (for example a PEM file). If your application generates keys or parameters that then\nneed to be written into PEM or DER format then it is likely that you will need to use an\nencoder to do this. Similarly you need a decoder to read previously saved keys and\nparameters. In most cases this will be invisible to you if you are using APIs that existed in\nOpenSSL 1.1.1 or earlier such as i2dPrivateKey(3). However the appropriate encoder/decoder\nwill need to be available in the library context associated with the key or parameter object.\nThe built-in OpenSSL encoders and decoders are implemented in both the default and base\nproviders and are not in the FIPS module boundary. However since they are not cryptographic\nalgorithms themselves it is still possible to use them in conjunction with the FIPS module,\nand therefore these encoders/decoders have the \"fips=yes\" property against them.  You should\nensure that either the default or base provider is loaded into the library context in this\ncase.\n"
                },
                {
                    "name": "Using the FIPS module in SSL/TLS",
                    "content": "Writing an application that uses libssl in conjunction with the FIPS module is much the same\nas writing a normal libssl application. If you are using global properties and the default\nlibrary context to specify usage of FIPS validated algorithms then this will happen\nautomatically for all cryptographic algorithms in libssl. If you are using a nondefault\nlibrary context to load the FIPS provider then you can supply this to libssl using the\nfunction SSLCTXnewex(3). This works as a drop in replacement for the function\nSSLCTXnew(3) except it provides you with the capability to specify the library context to\nbe used. You can also use the same function to specify libssl specific properties to use.\n\nIn this first example we create two SSLCTX objects using two different library contexts.\n\n/*\n* We assume that a nondefault library context with the FIPS\n* provider loaded has been created called fipslibctx.\n*/\nSSLCTX *fipssslctx = SSLCTXnewex(fipslibctx, NULL, TLSmethod());\n/*\n* We assume that a nondefault library context with the default\n* provider loaded has been created called nonfipslibctx.\n*/\nSSLCTX *nonfipssslctx = SSLCTXnewex(nonfipslibctx, NULL,\nTLSmethod());\n\nIn this second example we create two SSLCTX objects using different properties to specify\nFIPS usage:\n\n/*\n* The \"fips=yes\" property includes all FIPS approved algorithms\n* as well as encoders from the default provider that are allowed\n* to be used. The NULL below indicates that we are using the\n* default library context.\n*/\nSSLCTX *fipssslctx = SSLCTXnewex(NULL, \"fips=yes\", TLSmethod());\n/*\n* The \"provider!=fips\" property allows algorithms from any\n* provider except the FIPS provider\n*/\nSSLCTX *nonfipssslctx = SSLCTXnewex(NULL, \"provider!=fips\",\nTLSmethod());\n"
                },
                {
                    "name": "Confirming that an algorithm is being provided by the FIPS module",
                    "content": "A chain of links needs to be followed to go from an algorithm instance to the provider that\nimplements it. The process is similar for all algorithms. Here the example of a digest is\nused.\n\nTo go from an EVPMDCTX to an EVPMD, use EVPMDCTXmd(3) .  To go from the EVPMD to its\nOSSLPROVIDER, use EVPMDget0provider(3).  To extract the name from the OSSLPROVIDER, use\nOSSLPROVIDERget0name(3).\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "migrationguide(7), crypto(7), fipsconfig(5)\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.\n\nLicensed under the Apache License 2.0 (the \"License\").  You may not use this file except in\ncompliance with the License.  You can obtain a copy in the file LICENSE in the source\ndistribution or at <https://www.openssl.org/source/license.html>.\n\n\n\n3.0.2                                        2026-04-07                            FIPSMODULE(7SSL)",
            "subsections": []
        }
    },
    "summary": "fipsmodule - OpenSSL fips module guide",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "migrationguide",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/migrationguide/7/json"
        },
        {
            "name": "crypto",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/crypto/7/json"
        },
        {
            "name": "fipsconfig",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/fipsconfig/5/json"
        }
    ]
}