OSSL_PROVIDER-FIPS.pod 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. =pod
  2. =head1 NAME
  3. OSSL_PROVIDER-FIPS - OpenSSL FIPS provider
  4. =head1 DESCRIPTION
  5. The OpenSSL FIPS provider is a special provider that conforms to the Federal
  6. Information Processing Standards (FIPS) specified in FIPS 140-3. This 'module'
  7. contains an approved set of cryptographic algorithms that is validated by an
  8. accredited testing laboratory.
  9. =head2 Properties
  10. The implementations in this provider specifically have these properties
  11. defined:
  12. =over 4
  13. =item "provider=fips"
  14. =item "fips=yes"
  15. =back
  16. It may be used in a property query string with fetching functions such as
  17. L<EVP_MD_fetch(3)> or L<EVP_CIPHER_fetch(3)>, as well as with other
  18. functions that take a property query string, such as
  19. L<EVP_PKEY_CTX_new_from_name(3)>.
  20. To be FIPS compliant, it is mandatory to include C<fips=yes> as
  21. part of all property queries. This ensures that only FIPS approved
  22. implementations are used for cryptographic operations. The C<fips=yes>
  23. query may also include other non-crypto support operations that
  24. are not in the FIPS provider, such as asymmetric key encoders, see
  25. L<OSSL_PROVIDER-default(7)/Asymmetric Key Management>.
  26. It is not mandatory to include C<provider=fips> as part of your property
  27. query. Including C<provider=fips> in your property query guarantees
  28. that the OpenSSL FIPS provider is used for cryptographic operations
  29. rather than other FIPS capable providers.
  30. =head2 Provider parameters
  31. See L<provider-base(7)/Provider parameters> for a list of base parameters.
  32. Additionally the OpenSSL FIPS provider also supports the following gettable
  33. parameters:
  34. =over 4
  35. =item "security-checks" (B<OSSL_OSSL_PROV_PARAM_SECURITY_CHECKS>) <unsigned integer>
  36. For further information refer to the L<openssl-fipsinstall(1)> option
  37. B<-no_security_checks>.
  38. =back
  39. =head1 OPERATIONS AND ALGORITHMS
  40. The OpenSSL FIPS provider supports these operations and algorithms:
  41. =head2 Hashing Algorithms / Message Digests
  42. =over 4
  43. =item SHA1, see L<EVP_MD-SHA1(7)>
  44. =item SHA2, see L<EVP_MD-SHA2(7)>
  45. =item SHA3, see L<EVP_MD-SHA3(7)>
  46. =item KECCAK-KMAC, see L<EVP_MD-KECCAK-KMAC(7)>
  47. =back
  48. =head2 Symmetric Ciphers
  49. =over 4
  50. =item AES, see L<EVP_CIPHER-AES(7)>
  51. =item DES-EDE3 (TripleDES), see L<EVP_CIPHER-DES(7)>
  52. =back
  53. =head2 Message Authentication Code (MAC)
  54. =over 4
  55. =item CMAC, see L<EVP_MAC-CMAC(7)>
  56. =item GMAC, see L<EVP_MAC-GMAC(7)>
  57. =item HMAC, see L<EVP_MAC-HMAC(7)>
  58. =item KMAC, see L<EVP_MAC-KMAC(7)>
  59. =back
  60. =head2 Key Derivation Function (KDF)
  61. =over 4
  62. =item HKDF, see L<EVP_KDF-HKDF(7)>
  63. =item TLS13-KDF, see L<EVP_KDF-TLS13_KDF(7)>
  64. =item SSKDF, see L<EVP_KDF-SS(7)>
  65. =item PBKDF2, see L<EVP_KDF-PBKDF2(7)>
  66. =item SSHKDF, see L<EVP_KDF-SSHKDF(7)>
  67. =item TLS1-PRF, see L<EVP_KDF-TLS1_PRF(7)>
  68. =item KBKDF, see L<EVP_KDF-KB(7)>
  69. =item X942KDF-ASN1, see L<EVP_KDF-X942-ASN1(7)>
  70. =item X942KDF-CONCAT, see L<EVP_KDF-X942-CONCAT(7)>
  71. =item X963KDF, see L<EVP_KDF-X963(7)>
  72. =back
  73. =head2 Key Exchange
  74. =over 4
  75. =item DH, see L<EVP_KEYEXCH-DH(7)>
  76. =item ECDH, see L<EVP_KEYEXCH-ECDH(7)>
  77. =item X25519, see L<EVP_KEYEXCH-X25519(7)>
  78. =item X448, see L<EVP_KEYEXCH-X448(7)>
  79. =back
  80. =head2 Asymmetric Signature
  81. =over 4
  82. =item RSA, see L<EVP_SIGNATURE-RSA(7)>
  83. =item X25519, see L<EVP_SIGNATURE-ED25519(7)>
  84. =item X448, see L<EVP_SIGNATURE-ED448(7)>
  85. =item HMAC, see L<EVP_SIGNATURE-HMAC(7)>
  86. =item CMAC, see L<EVP_SIGNATURE-CMAC(7)>
  87. =back
  88. =head2 Asymmetric Cipher
  89. =over 4
  90. =item RSA, see L<EVP_ASYM_CIPHER-RSA(7)>
  91. =back
  92. =head2 Asymmetric Key Encapsulation
  93. =over 4
  94. =item RSA, see L<EVP_KEM-RSA(7)>
  95. =back
  96. =head2 Asymmetric Key Management
  97. =over 4
  98. =item DH, see L<EVP_KEYMGMT-DH(7)>
  99. =item DHX, see L<EVP_KEYMGMT-DHX(7)>
  100. =item DSA, see L<EVP_KEYMGMT-DSA(7)>
  101. =item RSA, see L<EVP_KEYMGMT-RSA(7)>
  102. =item EC, see L<EVP_KEYMGMT-EC(7)>
  103. =item X25519, see L<EVP_KEYMGMT-X25519(7)>
  104. =item X448, see L<EVP_KEYMGMT-X448(7)>
  105. =back
  106. =head2 Random Number Generation
  107. =over 4
  108. =item CTR-DRBG, see L<EVP_RAND-CTR-DRBG(7)>
  109. =item HASH-DRBG, see L<EVP_RAND-HASH-DRBG(7)>
  110. =item HMAC-DRBG, see L<EVP_RAND-HMAC-DRBG(7)>
  111. =item TEST-RAND, see L<EVP_RAND-TEST-RAND(7)>
  112. TEST-RAND is an unapproved algorithm.
  113. =back
  114. =head1 SELF TESTING
  115. One of the requirements for the FIPS module is self testing. An optional callback
  116. mechanism is available to return information to the user using
  117. L<OSSL_SELF_TEST_set_callback(3)>.
  118. The parameters passed to the callback are described in L<OSSL_SELF_TEST_new(3)>
  119. The OpenSSL FIPS module uses the following mechanism to provide information
  120. about the self tests as they run.
  121. This is useful for debugging if a self test is failing.
  122. The callback also allows forcing any self test to fail, in order to check that
  123. it operates correctly on failure.
  124. Note that all self tests run even if a self test failure occurs.
  125. The FIPS module passes the following type(s) to OSSL_SELF_TEST_onbegin().
  126. =over 4
  127. =item "Module_Integrity" (B<OSSL_SELF_TEST_TYPE_MODULE_INTEGRITY>)
  128. Uses HMAC SHA256 on the module file to validate that the module has not been
  129. modified. The integrity value is compared to a value written to a configuration
  130. file during installation.
  131. =item "Install_Integrity" (B<OSSL_SELF_TEST_TYPE_INSTALL_INTEGRITY>)
  132. Uses HMAC SHA256 on a fixed string to validate that the installation process
  133. has already been performed and the self test KATS have already been tested,
  134. The integrity value is compared to a value written to a configuration
  135. file after successfully running the self tests during installation.
  136. =item "KAT_Cipher" (B<OSSL_SELF_TEST_TYPE_KAT_CIPHER>)
  137. Known answer test for a symmetric cipher.
  138. =item "KAT_AsymmetricCipher" (B<OSSL_SELF_TEST_TYPE_KAT_ASYM_CIPHER>)
  139. Known answer test for a asymmetric cipher.
  140. =item "KAT_Digest" (B<OSSL_SELF_TEST_TYPE_KAT_DIGEST>)
  141. Known answer test for a digest.
  142. =item "KAT_Signature" (B<OSSL_SELF_TEST_TYPE_KAT_SIGNATURE>)
  143. Known answer test for a signature.
  144. =item "PCT_Signature" (B<OSSL_SELF_TEST_TYPE_PCT_SIGNATURE>)
  145. Pairwise Consistency check for a signature.
  146. =item "KAT_KDF" (B<OSSL_SELF_TEST_TYPE_KAT_KDF>)
  147. Known answer test for a key derivation function.
  148. =item "KAT_KA" (B<OSSL_SELF_TEST_TYPE_KAT_KA>)
  149. Known answer test for key agreement.
  150. =item "DRBG" (B<OSSL_SELF_TEST_TYPE_DRBG>)
  151. Known answer test for a Deterministic Random Bit Generator.
  152. =item "Conditional_PCT" (B<OSSL_SELF_TEST_TYPE_PCT>)
  153. Conditional test that is run during the generation of key pairs.
  154. =item "Continuous_RNG_Test" (B<OSSL_SELF_TEST_TYPE_CRNG>)
  155. Continuous random number generator test.
  156. =back
  157. The "Module_Integrity" self test is always run at startup.
  158. The "Install_Integrity" self test is used to check if the self tests have
  159. already been run at installation time. If they have already run then the
  160. self tests are not run on subsequent startups.
  161. All other self test categories are run once at installation time, except for the
  162. "Pairwise_Consistency_Test".
  163. There is only one instance of the "Module_Integrity" and "Install_Integrity"
  164. self tests. All other self tests may have multiple instances.
  165. The FIPS module passes the following descriptions(s) to OSSL_SELF_TEST_onbegin().
  166. =over 4
  167. =item "HMAC" (B<OSSL_SELF_TEST_DESC_INTEGRITY_HMAC>)
  168. "Module_Integrity" and "Install_Integrity" use this.
  169. =item "RSA" (B<OSSL_SELF_TEST_DESC_PCT_RSA_PKCS1>)
  170. =item "ECDSA" (B<OSSL_SELF_TEST_DESC_PCT_ECDSA>)
  171. =item "DSA" (B<OSSL_SELF_TEST_DESC_PCT_DSA>)
  172. Key generation tests used with the "Pairwise_Consistency_Test" type.
  173. =item "RSA_Encrypt" (B<OSSL_SELF_TEST_DESC_ASYM_RSA_ENC>)
  174. =item "RSA_Decrypt" (B<OSSL_SELF_TEST_DESC_ASYM_RSA_DEC>)
  175. "KAT_AsymmetricCipher" uses this to indicate an encrypt or decrypt KAT.
  176. =item "AES_GCM" (B<OSSL_SELF_TEST_DESC_CIPHER_AES_GCM>)
  177. =item "AES_ECB_Decrypt" (B<OSSL_SELF_TEST_DESC_CIPHER_AES_ECB>)
  178. =item "TDES" (B<OSSL_SELF_TEST_DESC_CIPHER_TDES>)
  179. Symmetric cipher tests used with the "KAT_Cipher" type.
  180. =item "SHA1" (B<OSSL_SELF_TEST_DESC_MD_SHA1>)
  181. =item "SHA2" (B<OSSL_SELF_TEST_DESC_MD_SHA2>)
  182. =item "SHA3" (B<OSSL_SELF_TEST_DESC_MD_SHA3>)
  183. Digest tests used with the "KAT_Digest" type.
  184. =item "DSA" (B<OSSL_SELF_TEST_DESC_SIGN_DSA>)
  185. =item "RSA" (B<OSSL_SELF_TEST_DESC_SIGN_RSA>)
  186. =item "ECDSA" (B<OSSL_SELF_TEST_DESC_SIGN_ECDSA>)
  187. Signature tests used with the "KAT_Signature" type.
  188. =item "ECDH" (B<OSSL_SELF_TEST_DESC_KA_ECDH>)
  189. =item "DH" (B<OSSL_SELF_TEST_DESC_KA_DH>)
  190. Key agreement tests used with the "KAT_KA" type.
  191. =item "HKDF" (B<OSSL_SELF_TEST_DESC_KDF_HKDF>)
  192. =item "TLS13_KDF_EXTRACT" (B<OSSL_SELF_TEST_DESC_KDF_TLS13_EXTRACT>)
  193. =item "TLS13_KDF_EXPAND" (B<OSSL_SELF_TEST_DESC_KDF_TLS13_EXPAND>)
  194. =item "SSKDF" (B<OSSL_SELF_TEST_DESC_KDF_SSKDF>)
  195. =item "X963KDF" (B<OSSL_SELF_TEST_DESC_KDF_X963KDF>)
  196. =item "X942KDF" (B<OSSL_SELF_TEST_DESC_KDF_X942KDF>)
  197. =item "PBKDF2" (B<OSSL_SELF_TEST_DESC_KDF_PBKDF2>)
  198. =item "SSHKDF" (B<OSSL_SELF_TEST_DESC_KDF_SSHKDF>)
  199. =item "TLS12_PRF" (B<OSSL_SELF_TEST_DESC_KDF_TLS12_PRF>)
  200. =item "KBKDF" (B<OSSL_SELF_TEST_DESC_KDF_KBKDF>)
  201. Key Derivation Function tests used with the "KAT_KDF" type.
  202. =item "CTR" (B<OSSL_SELF_TEST_DESC_DRBG_CTR>)
  203. =item "HASH" (B<OSSL_SELF_TEST_DESC_DRBG_HASH>)
  204. =item "HMAC" (B<OSSL_SELF_TEST_DESC_DRBG_HMAC>)
  205. DRBG tests used with the "DRBG" type.
  206. = item "RNG" (B<OSSL_SELF_TEST_DESC_RNG>)
  207. "Continuous_RNG_Test" uses this.
  208. =back
  209. =head1 EXAMPLES
  210. A simple self test callback is shown below for illustrative purposes.
  211. #include <openssl/self_test.h>
  212. static OSSL_CALLBACK self_test_cb;
  213. static int self_test_cb(const OSSL_PARAM params[], void *arg)
  214. {
  215. int ret = 0;
  216. const OSSL_PARAM *p = NULL;
  217. const char *phase = NULL, *type = NULL, *desc = NULL;
  218. p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_PHASE);
  219. if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
  220. goto err;
  221. phase = (const char *)p->data;
  222. p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_DESC);
  223. if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
  224. goto err;
  225. desc = (const char *)p->data;
  226. p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_TYPE);
  227. if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
  228. goto err;
  229. type = (const char *)p->data;
  230. /* Do some logging */
  231. if (strcmp(phase, OSSL_SELF_TEST_PHASE_START) == 0)
  232. BIO_printf(bio_out, "%s : (%s) : ", desc, type);
  233. if (strcmp(phase, OSSL_SELF_TEST_PHASE_PASS) == 0
  234. || strcmp(phase, OSSL_SELF_TEST_PHASE_FAIL) == 0)
  235. BIO_printf(bio_out, "%s\n", phase);
  236. /* Corrupt the SHA1 self test during the 'corrupt' phase by returning 0 */
  237. if (strcmp(phase, OSSL_SELF_TEST_PHASE_CORRUPT) == 0
  238. && strcmp(desc, OSSL_SELF_TEST_DESC_MD_SHA1) == 0) {
  239. BIO_printf(bio_out, "%s %s", phase, desc);
  240. return 0;
  241. }
  242. ret = 1;
  243. err:
  244. return ret;
  245. }
  246. =head1 NOTES
  247. Some released versions of OpenSSL do not include a validated
  248. FIPS provider. To determine which versions have undergone
  249. the validation process, please refer to the
  250. L<OpenSSL Downloads page|https://www.openssl.org/source/>. If you
  251. require FIPS-approved functionality, it is essential to build your FIPS
  252. provider using one of the validated versions listed there. Normally,
  253. it is possible to utilize a FIPS provider constructed from one of the
  254. validated versions alongside F<libcrypto> and F<libssl> compiled from any
  255. release within the same major release series. This flexibility enables
  256. you to address bug fixes and CVEs that fall outside the FIPS boundary.
  257. The FIPS provider in OpenSSL 3.1 includes some non-FIPS validated algorithms,
  258. consequently the property query C<fips=yes> is mandatory for applications that
  259. want to operate in a FIPS approved manner. The algorithms are:
  260. =over 4
  261. =item Triple DES ECB
  262. =item Triple DES CBC
  263. =item EdDSA
  264. =back
  265. =head1 SEE ALSO
  266. L<openssl-fipsinstall(1)>,
  267. L<fips_config(5)>,
  268. L<OSSL_SELF_TEST_set_callback(3)>,
  269. L<OSSL_SELF_TEST_new(3)>,
  270. L<OSSL_PARAM(3)>,
  271. L<openssl-core.h(7)>,
  272. L<openssl-core_dispatch.h(7)>,
  273. L<provider(7)>,
  274. L<https://www.openssl.org/source/>
  275. =head1 HISTORY
  276. This functionality was added in OpenSSL 3.0.
  277. =head1 COPYRIGHT
  278. Copyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
  279. Licensed under the Apache License 2.0 (the "License"). You may not use
  280. this file except in compliance with the License. You can obtain a copy
  281. in the file LICENSE in the source distribution or at
  282. L<https://www.openssl.org/source/license.html>.
  283. =cut