fips_module.7ossl 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "FIPS_MODULE 7ossl"
  58. .TH FIPS_MODULE 7ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. fips_module \- OpenSSL fips module guide
  65. .SH SYNOPSIS
  66. .IX Header "SYNOPSIS"
  67. See the individual manual pages for details.
  68. .SH DESCRIPTION
  69. .IX Header "DESCRIPTION"
  70. This guide details different ways that OpenSSL can be used in conjunction
  71. with the FIPS module. Which is the correct approach to use will depend on your
  72. own specific circumstances and what you are attempting to achieve.
  73. .PP
  74. For information related to installing the FIPS module see
  75. <https://github.com/openssl/openssl/blob/master/README\-FIPS.md>.
  76. .PP
  77. Note that the old functions \fBFIPS_mode()\fR and \fBFIPS_mode_set()\fR are no longer
  78. present so you must remove them from your application if you use them.
  79. .PP
  80. Applications written to use the OpenSSL 3.0 FIPS module should not use any
  81. legacy APIs or features that avoid the FIPS module. Specifically this includes:
  82. .IP \(bu 4
  83. Low level cryptographic APIs (use the high level APIs, such as EVP, instead)
  84. .IP \(bu 4
  85. Engines
  86. .IP \(bu 4
  87. Any functions that create or modify custom "METHODS" (for example
  88. \&\fBEVP_MD_meth_new()\fR, \fBEVP_CIPHER_meth_new()\fR, \fBEVP_PKEY_meth_new()\fR, \fBRSA_meth_new()\fR,
  89. \&\fBEC_KEY_METHOD_new()\fR, etc.)
  90. .PP
  91. All of the above APIs are deprecated in OpenSSL 3.0 \- so a simple rule is to
  92. avoid using all deprecated functions. See \fBossl\-guide\-migration\fR\|(7) for a list of
  93. deprecated functions.
  94. .SS "Making all applications use the FIPS module by default"
  95. .IX Subsection "Making all applications use the FIPS module by default"
  96. One simple approach is to cause all applications that are using OpenSSL to only
  97. use the FIPS module for cryptographic algorithms by default.
  98. .PP
  99. This approach can be done purely via configuration. As long as applications are
  100. built and linked against OpenSSL 3.0 and do not override the loading of the
  101. default config file or its settings then they can automatically start using the
  102. FIPS module without the need for any further code changes.
  103. .PP
  104. To do this the default OpenSSL config file will have to be modified. The
  105. location of this config file will depend on the platform, and any options that
  106. were given during the build process. You can check the location of the config
  107. file by running this command:
  108. .PP
  109. .Vb 2
  110. \& $ openssl version \-d
  111. \& OPENSSLDIR: "/usr/local/ssl"
  112. .Ve
  113. .PP
  114. Caution: Many Operating Systems install OpenSSL by default. It is a common error
  115. to not have the correct version of OpenSSL in your \f(CW$PATH\fR. Check that you are
  116. running an OpenSSL 3.0 version like this:
  117. .PP
  118. .Vb 2
  119. \& $ openssl version \-v
  120. \& OpenSSL 3.0.0\-dev xx XXX xxxx (Library: OpenSSL 3.0.0\-dev xx XXX xxxx)
  121. .Ve
  122. .PP
  123. The \fBOPENSSLDIR\fR value above gives the directory name for where the default
  124. config file is stored. So in this case the default config file will be called
  125. \&\fI/usr/local/ssl/openssl.cnf\fR.
  126. .PP
  127. Edit the config file to add the following lines near the beginning:
  128. .PP
  129. .Vb 2
  130. \& config_diagnostics = 1
  131. \& openssl_conf = openssl_init
  132. \&
  133. \& .include /usr/local/ssl/fipsmodule.cnf
  134. \&
  135. \& [openssl_init]
  136. \& providers = provider_sect
  137. \& alg_section = algorithm_sect
  138. \&
  139. \& [provider_sect]
  140. \& fips = fips_sect
  141. \& base = base_sect
  142. \&
  143. \& [base_sect]
  144. \& activate = 1
  145. \&
  146. \& [algorithm_sect]
  147. \& default_properties = fips=yes
  148. .Ve
  149. .PP
  150. Obviously the include file location above should match the path and name of the
  151. FIPS module config file that you installed earlier.
  152. See <https://github.com/openssl/openssl/blob/master/README\-FIPS.md>.
  153. .PP
  154. For FIPS usage, it is recommended that the \fBconfig_diagnostics\fR option is
  155. enabled to prevent accidental use of non-FIPS validated algorithms via broken
  156. or mistaken configuration. See \fBconfig\fR\|(5).
  157. .PP
  158. Any applications that use OpenSSL 3.0 and are started after these changes are
  159. made will start using only the FIPS module unless those applications take
  160. explicit steps to avoid this default behaviour. Note that this configuration
  161. also activates the "base" provider. The base provider does not include any
  162. cryptographic algorithms (and therefore does not impact the validation status of
  163. any cryptographic operations), but does include other supporting algorithms that
  164. may be required. It is designed to be used in conjunction with the FIPS module.
  165. .PP
  166. This approach has the primary advantage that it is simple, and no code changes
  167. are required in applications in order to benefit from the FIPS module. There are
  168. some disadvantages to this approach:
  169. .IP \(bu 4
  170. You may not want all applications to use the FIPS module.
  171. .Sp
  172. It may be the case that some applications should and some should not use the
  173. FIPS module.
  174. .IP \(bu 4
  175. If applications take explicit steps to not load the default config file or
  176. set different settings.
  177. .Sp
  178. This method will not work for these cases.
  179. .IP \(bu 4
  180. The algorithms available in the FIPS module are a subset of the algorithms
  181. that are available in the default OpenSSL Provider.
  182. .Sp
  183. If any applications attempt to use any algorithms that are not present,
  184. then they will fail.
  185. .IP \(bu 4
  186. Usage of certain deprecated APIs avoids the use of the FIPS module.
  187. .Sp
  188. If any applications use those APIs then the FIPS module will not be used.
  189. .SS "Selectively making applications use the FIPS module by default"
  190. .IX Subsection "Selectively making applications use the FIPS module by default"
  191. A variation on the above approach is to do the same thing on an individual
  192. application basis. The default OpenSSL config file depends on the compiled in
  193. value for \fBOPENSSLDIR\fR as described in the section above. However it is also
  194. possible to override the config file to be used via the \fBOPENSSL_CONF\fR
  195. environment variable. For example the following, on Unix, will cause the
  196. application to be executed with a non-standard config file location:
  197. .PP
  198. .Vb 1
  199. \& $ OPENSSL_CONF=/my/nondefault/openssl.cnf myapplication
  200. .Ve
  201. .PP
  202. Using this mechanism you can control which config file is loaded (and hence
  203. whether the FIPS module is loaded) on an application by application basis.
  204. .PP
  205. This removes the disadvantage listed above that you may not want all
  206. applications to use the FIPS module. All the other advantages and disadvantages
  207. still apply.
  208. .SS "Programmatically loading the FIPS module (default library context)"
  209. .IX Subsection "Programmatically loading the FIPS module (default library context)"
  210. Applications may choose to load the FIPS provider explicitly rather than relying
  211. on config to do this. The config file is still necessary in order to hold the
  212. FIPS module config data (such as its self test status and integrity data). But
  213. in this case we do not automatically activate the FIPS provider via that config
  214. file.
  215. .PP
  216. To do things this way configure as per
  217. "Making all applications use the FIPS module by default" above, but edit the
  218. \&\fIfipsmodule.cnf\fR file to remove or comment out the line which says
  219. \&\f(CW\*(C`activate = 1\*(C'\fR (note that setting this value to 0 is \fInot\fR sufficient).
  220. This means all the required config information will be available to load the
  221. FIPS module, but it is not automatically loaded when the application starts. The
  222. FIPS provider can then be loaded programmatically like this:
  223. .PP
  224. .Vb 1
  225. \& #include <openssl/provider.h>
  226. \&
  227. \& int main(void)
  228. \& {
  229. \& OSSL_PROVIDER *fips;
  230. \& OSSL_PROVIDER *base;
  231. \&
  232. \& fips = OSSL_PROVIDER_load(NULL, "fips");
  233. \& if (fips == NULL) {
  234. \& printf("Failed to load FIPS provider\en");
  235. \& exit(EXIT_FAILURE);
  236. \& }
  237. \& base = OSSL_PROVIDER_load(NULL, "base");
  238. \& if (base == NULL) {
  239. \& OSSL_PROVIDER_unload(fips);
  240. \& printf("Failed to load base provider\en");
  241. \& exit(EXIT_FAILURE);
  242. \& }
  243. \&
  244. \& /* Rest of application */
  245. \&
  246. \& OSSL_PROVIDER_unload(base);
  247. \& OSSL_PROVIDER_unload(fips);
  248. \& exit(EXIT_SUCCESS);
  249. \& }
  250. .Ve
  251. .PP
  252. Note that this should be one of the first things that you do in your
  253. application. If any OpenSSL functions get called that require the use of
  254. cryptographic functions before this occurs then, if no provider has yet been
  255. loaded, then the default provider will be automatically loaded. If you then
  256. later explicitly load the FIPS provider then you will have both the FIPS and the
  257. default provider loaded at the same time. It is undefined which implementation
  258. of an algorithm will be used if multiple implementations are available and you
  259. have not explicitly specified via a property query (see below) which one should
  260. be used.
  261. .PP
  262. Also note that in this example we have additionally loaded the "base" provider.
  263. This loads a sub-set of algorithms that are also available in the default
  264. provider \- specifically non cryptographic ones which may be used in conjunction
  265. with the FIPS provider. For example this contains algorithms for encoding and
  266. decoding keys. If you decide not to load the default provider then you
  267. will usually want to load the base provider instead.
  268. .PP
  269. In this example we are using the "default" library context. OpenSSL functions
  270. operate within the scope of a library context. If no library context is
  271. explicitly specified then the default library context is used. For further
  272. details about library contexts see the \fBOSSL_LIB_CTX\fR\|(3) man page.
  273. .SS "Loading the FIPS module at the same time as other providers"
  274. .IX Subsection "Loading the FIPS module at the same time as other providers"
  275. It is possible to have the FIPS provider and other providers (such as the
  276. default provider) all loaded at the same time into the same library context. You
  277. can use a property query string during algorithm fetches to specify which
  278. implementation you would like to use.
  279. .PP
  280. For example to fetch an implementation of SHA256 which conforms to FIPS
  281. standards you can specify the property query \f(CW\*(C`fips=yes\*(C'\fR like this:
  282. .PP
  283. .Vb 1
  284. \& EVP_MD *sha256;
  285. \&
  286. \& sha256 = EVP_MD_fetch(NULL, "SHA2\-256", "fips=yes");
  287. .Ve
  288. .PP
  289. If no property query is specified, or more than one implementation matches the
  290. property query then it is undefined which implementation of a particular
  291. algorithm will be returned.
  292. .PP
  293. This example shows an explicit request for an implementation of SHA256 from the
  294. default provider:
  295. .PP
  296. .Vb 1
  297. \& EVP_MD *sha256;
  298. \&
  299. \& sha256 = EVP_MD_fetch(NULL, "SHA2\-256", "provider=default");
  300. .Ve
  301. .PP
  302. It is also possible to set a default property query string. The following
  303. example sets the default property query of \f(CW\*(C`fips=yes\*(C'\fR for all fetches within
  304. the default library context:
  305. .PP
  306. .Vb 1
  307. \& EVP_set_default_properties(NULL, "fips=yes");
  308. .Ve
  309. .PP
  310. If a fetch function has both an explicit property query specified, and a
  311. default property query is defined then the two queries are merged together and
  312. both apply. The local property query overrides the default properties if the
  313. same property name is specified in both.
  314. .PP
  315. There are two important built-in properties that you should be aware of:
  316. .PP
  317. The "provider" property enables you to specify which provider you want an
  318. implementation to be fetched from, e.g. \f(CW\*(C`provider=default\*(C'\fR or \f(CW\*(C`provider=fips\*(C'\fR.
  319. All algorithms implemented in a provider have this property set on them.
  320. .PP
  321. There is also the \f(CW\*(C`fips\*(C'\fR property. All FIPS algorithms match against the
  322. property query \f(CW\*(C`fips=yes\*(C'\fR. There are also some non-cryptographic algorithms
  323. available in the default and base providers that also have the \f(CW\*(C`fips=yes\*(C'\fR
  324. property defined for them. These are the encoder and decoder algorithms that
  325. can (for example) be used to write out a key generated in the FIPS provider to a
  326. file. The encoder and decoder algorithms are not in the FIPS module itself but
  327. are allowed to be used in conjunction with the FIPS algorithms.
  328. .PP
  329. It is possible to specify default properties within a config file. For example
  330. the following config file automatically loads the default and FIPS providers and
  331. sets the default property value to be \f(CW\*(C`fips=yes\*(C'\fR. Note that this config file
  332. does not load the "base" provider. All supporting algorithms that are in "base"
  333. are also in "default", so it is unnecessary in this case:
  334. .PP
  335. .Vb 2
  336. \& config_diagnostics = 1
  337. \& openssl_conf = openssl_init
  338. \&
  339. \& .include /usr/local/ssl/fipsmodule.cnf
  340. \&
  341. \& [openssl_init]
  342. \& providers = provider_sect
  343. \& alg_section = algorithm_sect
  344. \&
  345. \& [provider_sect]
  346. \& fips = fips_sect
  347. \& default = default_sect
  348. \&
  349. \& [default_sect]
  350. \& activate = 1
  351. \&
  352. \& [algorithm_sect]
  353. \& default_properties = fips=yes
  354. .Ve
  355. .SS "Programmatically loading the FIPS module (nondefault library context)"
  356. .IX Subsection "Programmatically loading the FIPS module (nondefault library context)"
  357. In addition to using properties to separate usage of the FIPS module from other
  358. usages this can also be achieved using library contexts. In this example we
  359. create two library contexts. In one we assume the existence of a config file
  360. called \fIopenssl\-fips.cnf\fR that automatically loads and configures the FIPS and
  361. base providers. The other library context will just use the default provider.
  362. .PP
  363. .Vb 4
  364. \& OSSL_LIB_CTX *fips_libctx, *nonfips_libctx;
  365. \& OSSL_PROVIDER *defctxnull = NULL;
  366. \& EVP_MD *fipssha256 = NULL, *nonfipssha256 = NULL;
  367. \& int ret = 1;
  368. \&
  369. \& /*
  370. \& * Create two nondefault library contexts. One for fips usage and
  371. \& * one for non\-fips usage
  372. \& */
  373. \& fips_libctx = OSSL_LIB_CTX_new();
  374. \& nonfips_libctx = OSSL_LIB_CTX_new();
  375. \& if (fips_libctx == NULL || nonfips_libctx == NULL)
  376. \& goto err;
  377. \&
  378. \& /* Prevent anything from using the default library context */
  379. \& defctxnull = OSSL_PROVIDER_load(NULL, "null");
  380. \&
  381. \& /*
  382. \& * Load config file for the FIPS library context. We assume that
  383. \& * this config file will automatically activate the FIPS and base
  384. \& * providers so we don\*(Aqt need to explicitly load them here.
  385. \& */
  386. \& if (!OSSL_LIB_CTX_load_config(fips_libctx, "openssl\-fips.cnf"))
  387. \& goto err;
  388. \&
  389. \& /*
  390. \& * Set the default property query on the FIPS library context to
  391. \& * ensure that only FIPS algorithms can be used. There are a few non\-FIPS
  392. \& * approved algorithms in the FIPS provider for backward compatibility reasons.
  393. \& */
  394. \& if (!EVP_set_default_properties(fips_libctx, "fips=yes"))
  395. \& goto err;
  396. \&
  397. \& /*
  398. \& * We don\*(Aqt need to do anything special to load the default
  399. \& * provider into nonfips_libctx. This happens automatically if no
  400. \& * other providers are loaded.
  401. \& * Because we don\*(Aqt call OSSL_LIB_CTX_load_config() explicitly for
  402. \& * nonfips_libctx it will just use the default config file.
  403. \& */
  404. \&
  405. \& /* As an example get some digests */
  406. \&
  407. \& /* Get a FIPS validated digest */
  408. \& fipssha256 = EVP_MD_fetch(fips_libctx, "SHA2\-256", NULL);
  409. \& if (fipssha256 == NULL)
  410. \& goto err;
  411. \&
  412. \& /* Get a non\-FIPS validated digest */
  413. \& nonfipssha256 = EVP_MD_fetch(nonfips_libctx, "SHA2\-256", NULL);
  414. \& if (nonfipssha256 == NULL)
  415. \& goto err;
  416. \&
  417. \& /* Use the digests */
  418. \&
  419. \& printf("Success\en");
  420. \& ret = 0;
  421. \&
  422. \& err:
  423. \& EVP_MD_free(fipssha256);
  424. \& EVP_MD_free(nonfipssha256);
  425. \& OSSL_LIB_CTX_free(fips_libctx);
  426. \& OSSL_LIB_CTX_free(nonfips_libctx);
  427. \& OSSL_PROVIDER_unload(defctxnull);
  428. \&
  429. \& return ret;
  430. .Ve
  431. .PP
  432. Note that we have made use of the special "null" provider here which we load
  433. into the default library context. We could have chosen to use the default
  434. library context for FIPS usage, and just create one additional library context
  435. for other usages \- or vice versa. However if code has not been converted to use
  436. library contexts then the default library context will be automatically used.
  437. This could be the case for your own existing applications as well as certain
  438. parts of OpenSSL itself. Not all parts of OpenSSL are library context aware. If
  439. this happens then you could "accidentally" use the wrong library context for a
  440. particular operation. To be sure this doesn't happen you can load the "null"
  441. provider into the default library context. Because a provider has been
  442. explicitly loaded, the default provider will not automatically load. This means
  443. code using the default context by accident will fail because no algorithms will
  444. be available.
  445. .PP
  446. See "Library Context" in \fBossl\-guide\-migration\fR\|(7) for additional information about the
  447. Library Context.
  448. .SS "Using Encoders and Decoders with the FIPS module"
  449. .IX Subsection "Using Encoders and Decoders with the FIPS module"
  450. Encoders and decoders are used to read and write keys or parameters from or to
  451. some external format (for example a PEM file). If your application generates
  452. keys or parameters that then need to be written into PEM or DER format
  453. then it is likely that you will need to use an encoder to do this. Similarly
  454. you need a decoder to read previously saved keys and parameters. In most cases
  455. this will be invisible to you if you are using APIs that existed in
  456. OpenSSL 1.1.1 or earlier such as \fBi2d_PrivateKey\fR\|(3). However the appropriate
  457. encoder/decoder will need to be available in the library context associated with
  458. the key or parameter object. The built-in OpenSSL encoders and decoders are
  459. implemented in both the default and base providers and are not in the FIPS
  460. module boundary. However since they are not cryptographic algorithms themselves
  461. it is still possible to use them in conjunction with the FIPS module, and
  462. therefore these encoders/decoders have the \f(CW\*(C`fips=yes\*(C'\fR property against them.
  463. You should ensure that either the default or base provider is loaded into the
  464. library context in this case.
  465. .SS "Using the FIPS module in SSL/TLS"
  466. .IX Subsection "Using the FIPS module in SSL/TLS"
  467. Writing an application that uses libssl in conjunction with the FIPS module is
  468. much the same as writing a normal libssl application. If you are using global
  469. properties and the default library context to specify usage of FIPS validated
  470. algorithms then this will happen automatically for all cryptographic algorithms
  471. in libssl. If you are using a nondefault library context to load the FIPS
  472. provider then you can supply this to libssl using the function
  473. \&\fBSSL_CTX_new_ex\fR\|(3). This works as a drop in replacement for the function
  474. \&\fBSSL_CTX_new\fR\|(3) except it provides you with the capability to specify the
  475. library context to be used. You can also use the same function to specify
  476. libssl specific properties to use.
  477. .PP
  478. In this first example we create two SSL_CTX objects using two different library
  479. contexts.
  480. .PP
  481. .Vb 11
  482. \& /*
  483. \& * We assume that a nondefault library context with the FIPS
  484. \& * provider loaded has been created called fips_libctx.
  485. \& */
  486. \& SSL_CTX *fips_ssl_ctx = SSL_CTX_new_ex(fips_libctx, "fips=yes", TLS_method());
  487. \& /*
  488. \& * We assume that a nondefault library context with the default
  489. \& * provider loaded has been created called non_fips_libctx.
  490. \& */
  491. \& SSL_CTX *non_fips_ssl_ctx = SSL_CTX_new_ex(non_fips_libctx, NULL,
  492. \& TLS_method());
  493. .Ve
  494. .PP
  495. In this second example we create two SSL_CTX objects using different properties
  496. to specify FIPS usage:
  497. .PP
  498. .Vb 10
  499. \& /*
  500. \& * The "fips=yes" property includes all FIPS approved algorithms
  501. \& * as well as encoders from the default provider that are allowed
  502. \& * to be used. The NULL below indicates that we are using the
  503. \& * default library context.
  504. \& */
  505. \& SSL_CTX *fips_ssl_ctx = SSL_CTX_new_ex(NULL, "fips=yes", TLS_method());
  506. \& /*
  507. \& * The "provider!=fips" property allows algorithms from any
  508. \& * provider except the FIPS provider
  509. \& */
  510. \& SSL_CTX *non_fips_ssl_ctx = SSL_CTX_new_ex(NULL, "provider!=fips",
  511. \& TLS_method());
  512. .Ve
  513. .SS "Confirming that an algorithm is being provided by the FIPS module"
  514. .IX Subsection "Confirming that an algorithm is being provided by the FIPS module"
  515. A chain of links needs to be followed to go from an algorithm instance to the
  516. provider that implements it. The process is similar for all algorithms. Here the
  517. example of a digest is used.
  518. .PP
  519. To go from an \fBEVP_MD_CTX\fR to an \fBEVP_MD\fR, use \fBEVP_MD_CTX_md\fR\|(3) .
  520. To go from the \fBEVP_MD\fR to its \fBOSSL_PROVIDER\fR,
  521. use \fBEVP_MD_get0_provider\fR\|(3).
  522. To extract the name from the \fBOSSL_PROVIDER\fR, use
  523. \&\fBOSSL_PROVIDER_get0_name\fR\|(3).
  524. .SS "FIPS indicators"
  525. .IX Subsection "FIPS indicators"
  526. FIPS indicators have been added to the FIPS provider in OpenSSL 3.4.
  527. FIPS 140\-3 requires indicators to be used if the FIPS provider allows non
  528. approved algorithms. An algorithm is approved if it passes all required checks
  529. such as minimum key size. By default an error will occur if any check fails.
  530. For backwards compatibility individual algorithms may override the checks by
  531. using either an option in the FIPS configuration (See
  532. "FIPS indicator options" in \fBfips_config\fR\|(5)) OR in code using an algorithm context
  533. setter. Overriding the check means that the algorithm is not FIPS compliant.
  534. \&\fBOSSL_INDICATOR_set_callback\fR\|(3) can be called to register a callback to log
  535. unapproved algorithms. At the end of any algorithm operation the approved status
  536. can be queried using an algorithm context getter to retrieve the indicator
  537. (e.g. "fips-indicator").
  538. An example of an algorithm context setter is "key-check"
  539. in "Supported parameters" in \fBEVP_KDF\-HKDF\fR\|(7).
  540. .PP
  541. The following algorithms use "fips-indicator" to query if the algorithm
  542. is approved:
  543. .IP "DSA Key generation" 4
  544. .IX Item "DSA Key generation"
  545. DSA Key generation is no longer approved.
  546. See "DSA parameters" in \fBEVP_PKEY\-DSA\fR\|(7)
  547. .IP "DSA Signatures" 4
  548. .IX Item "DSA Signatures"
  549. DSA Signature generation is no longer approved.
  550. See "Signature Parameters" in \fBEVP_SIGNATURE\-DSA\fR\|(7)
  551. .IP "ECDSA Signatures" 4
  552. .IX Item "ECDSA Signatures"
  553. See "ECDSA Signature Parameters" in \fBEVP_SIGNATURE\-ECDSA\fR\|(7)
  554. .IP "EC Key Generation" 4
  555. .IX Item "EC Key Generation"
  556. See "Common EC parameters" in \fBEVP_PKEY\-EC\fR\|(7)
  557. .IP "RSA Encryption" 4
  558. .IX Item "RSA Encryption"
  559. "pkcs1" padding is no longer approved.
  560. .Sp
  561. See "RSA Asymmetric Cipher parameters" in \fBEVP_ASYM_CIPHER\-RSA\fR\|(7) and
  562. "RSA KEM parameters" in \fBEVP_KEM\-RSA\fR\|(7)
  563. .IP "RSA Signatures" 4
  564. .IX Item "RSA Signatures"
  565. See "Signature Parameters" in \fBEVP_SIGNATURE\-RSA\fR\|(7)
  566. .IP DRBGS 4
  567. .IX Item "DRBGS"
  568. See "Supported parameters" in \fBEVP_RAND\-HASH\-DRBG\fR\|(7) and
  569. \&\fBEVP_RAND\-HMAC\-DRBG\fR\|(7)/Supported parameters>
  570. .IP DES 4
  571. .IX Item "DES"
  572. Triple-DES is not longer approved for encryption.
  573. See "Parameters" in \fBEVP_CIPHER\-DES\fR\|(7)
  574. .IP DH 4
  575. .IX Item "DH"
  576. See "DH and DHX key exchange parameters" in \fBEVP_KEYEXCH\-DH\fR\|(7)
  577. .IP ECDH 4
  578. .IX Item "ECDH"
  579. See "ECDH Key Exchange parameters" in \fBEVP_KEYEXCH\-ECDH\fR\|(7)
  580. .IP KDFS 4
  581. .IX Item "KDFS"
  582. See relevant KDF documentation e.g. "Supported parameters" in \fBEVP_KDF\-HKDF\fR\|(7)
  583. .IP "CMAC and KMAC" 4
  584. .IX Item "CMAC and KMAC"
  585. See "Supported parameters" in \fBEVP_MAC\-CMAC\fR\|(7) and
  586. "Supported parameters" in \fBEVP_MAC\-KMAC\fR\|(7)
  587. .PP
  588. The following FIPS algorithms are unapproved and use the "fips-indicator".
  589. .IP RAND-TEST-RAND 4
  590. .IX Item "RAND-TEST-RAND"
  591. See "Supported parameters" in \fBEVP_RAND\-TEST\-RAND\fR\|(7)
  592. The indicator callback is NOT triggered for this algorithm since it is used
  593. internally for non security purposes.
  594. .IP "X25519 and X448 Key Generation and Key Exchange" 4
  595. .IX Item "X25519 and X448 Key Generation and Key Exchange"
  596. .PP
  597. The unapproved (non FIPS validated) algorithms have a property query value of
  598. "fips=no".
  599. .PP
  600. The following algorithms use a unique indicator and do not trigger the
  601. indicator callback.
  602. .IP "AES-GCM ciphers support the indicator ""iv-generated""" 4
  603. .IX Item "AES-GCM ciphers support the indicator ""iv-generated"""
  604. See "PARAMETERS" in \fBEVP_EncryptInit\fR\|(3) for further information.
  605. .IP "ECDSA and RSA Signatures support the indicator ""verify-message""." 4
  606. .IX Item "ECDSA and RSA Signatures support the indicator ""verify-message""."
  607. See "ECDSA Signature Parameters" in \fBEVP_SIGNATURE\-ECDSA\fR\|(7) and
  608. "Signature Parameters" in \fBEVP_SIGNATURE\-RSA\fR\|(7) /for further information.
  609. .SH NOTES
  610. .IX Header "NOTES"
  611. Some released versions of OpenSSL do not include a validated
  612. FIPS provider. To determine which versions have undergone
  613. the validation process, please refer to the
  614. OpenSSL Downloads page <https://www.openssl.org/source/>. If you
  615. require FIPS-approved functionality, it is essential to build your FIPS
  616. provider using one of the validated versions listed there. Normally,
  617. it is possible to utilize a FIPS provider constructed from one of the
  618. validated versions alongside \fIlibcrypto\fR and \fIlibssl\fR compiled from any
  619. release within the same major release series. This flexibility enables
  620. you to address bug fixes and CVEs that fall outside the FIPS boundary.
  621. .PP
  622. As the FIPS provider still supports non-FIPS validated algorithms,
  623. The property query \f(CW\*(C`fips=yes\*(C'\fR is mandatory for applications that
  624. want to operate in a FIPS approved manner.
  625. .SH "SEE ALSO"
  626. .IX Header "SEE ALSO"
  627. \&\fBossl\-guide\-migration\fR\|(7), \fBcrypto\fR\|(7), \fBfips_config\fR\|(5),
  628. <https://www.openssl.org/source/>
  629. .SH HISTORY
  630. .IX Header "HISTORY"
  631. The FIPS module guide was created for use with the new FIPS provider
  632. in OpenSSL 3.0.
  633. FIPS indicators were added in OpenSSL 3.4.
  634. .SH COPYRIGHT
  635. .IX Header "COPYRIGHT"
  636. Copyright 2021\-2024 The OpenSSL Project Authors. All Rights Reserved.
  637. .PP
  638. Licensed under the Apache License 2.0 (the "License"). You may not use
  639. this file except in compliance with the License. You can obtain a copy
  640. in the file LICENSE in the source distribution or at
  641. <https://www.openssl.org/source/license.html>.