OSSL_PROVIDER-FIPS.pod 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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-2. 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=default"
  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. It isn't mandatory to query for any of these properties, except to
  21. make sure to get implementations of this provider and none other.
  22. The "fips=yes" property can be use to make sure only FIPS approved
  23. implementations are used for crypto operations. This may also include
  24. other non-crypto support operations that are not in the fips provider,
  25. such as asymmetric key encoders,
  26. see L<OSSL_PROVIDER-default(7)/Asymmetric Key Management>.
  27. =head1 OPERATIONS AND ALGORITHMS
  28. The OpenSSL FIPS provider supports these operations and algorithms:
  29. =head2 Hashing Algorithms / Message Digests
  30. =over 4
  31. =item SHA1, see L<EVP_MD-SHA1(7)>
  32. =item SHA2, see L<EVP_MD-SHA2(7)>
  33. =item SHA3, see L<EVP_MD-SHA3(7)>
  34. =item KECCAK-KMAC, see L<EVP_MD-KECCAK-KMAC(7)>
  35. =back
  36. =head2 Symmetric Ciphers
  37. =over 4
  38. =item AES, see L<EVP_CIPHER-AES(7)>
  39. =item DES-EDE3 (TrippleDES), see L<EVP_CIPHER-DES(7)>
  40. =back
  41. =head2 Message Authentication Code (MAC)
  42. =over 4
  43. =item CMAC, see L<EVP_MAC-CMAC(7)>
  44. =item GMAC, see L<EVP_MAC-GMAC(7)>
  45. =item HMAC, see L<EVP_MAC-HMAC(7)>
  46. =item KMAC, see L<EVP_MAC-KMAC(7)>
  47. =back
  48. =head2 Key Derivation Function (KDF)
  49. =over 4
  50. =item HKDF, see L<EVP_KDF-HKDF(7)>
  51. =item SSKDF, see L<EVP_KDF-SSKDF(7)>
  52. =item PBKDF2, see L<EVP_KDF-PBKDF2(7)>
  53. =item SSHKDF, see L<EVP_KDF-SSHKDF(7)>
  54. =item TLS1-PRF, see L<EVP_KDF-TLS1-PRF(7)>
  55. =item KBKDF, see L<EVP_KDF-KBKDF(7)>
  56. =item X942KDF-ASN1, see L<EVP_KDF-X942-ASN1(7)>
  57. =item X942KDF-CONCAT, see L<EVP_KDF-X942-CONCAT(7)>
  58. =item X963KDF, see L<EVP_KDF-X963(7)>
  59. =back
  60. =head2 Key Exchange
  61. =over 4
  62. =item DH, see L<EVP_KEYEXCH-DH(7)>
  63. =item ECDH, see L<EVP_KEYEXCH-ECDH(7)>
  64. =item X25519, see L<EVP_KEYEXCH-X25519(7)>
  65. This has the property "provider=fips,fips=no"
  66. =item X448, see L<EVP_KEYEXCH-X448(7)>
  67. This has the property "provider=fips,fips=no"
  68. =back
  69. =head2 Asymmetric Signature
  70. =over 4
  71. =item DSA, see L<EVP_KEYEXCH-DSA(7)>
  72. =item RSA, see L<EVP_SIGNATURE-RSA(7)>
  73. =item HMAC, see L<EVP_SIGNATURE-HMAC(7)>
  74. =item CMAC, see L<EVP_SIGNATURE-CMAC(7)>
  75. =back
  76. =head2 Asymmetric Cipher
  77. =over 4
  78. =item RSA, see L<EVP_KEYEXCH-RSA(7)>
  79. =back
  80. =head2 Asymmetric Key Encapsulation
  81. =over 4
  82. =item RSA, see L<EVP_KEM-RSA(7)>
  83. =back
  84. =head2 Asymmetric Key Management
  85. =over 4
  86. =item DH, see L<EVP_KEYMGMT-DH(7)>
  87. =item DSA, see L<EVP_KEYMGMT-DSA(7)>
  88. =item RSA, see L<EVP_KEYMGMT-RSA(7)>
  89. =back
  90. =head1 SELF TESTING
  91. One of the requirements for the FIPS module is self testing. An optional callback
  92. mechanism is available to return information to the user using
  93. L<OSSL_SELF_TEST_set_callback(3)>.
  94. The parameters passed to the callback are described in L<OSSL_SELF_TEST_new(3)>
  95. The OpenSSL FIPS module uses the following mechanism to provide information
  96. about the self tests as they run.
  97. This is useful for debugging if a self test is failing.
  98. The callback also allows forcing any self test to fail, in order to check that
  99. it operates correctly on failure.
  100. Note that all self tests run even if a self test failure occurs.
  101. The FIPS module passes the following type(s) to OSSL_SELF_TEST_onbegin().
  102. =over 4
  103. =item "Module_Integrity" (B<OSSL_SELF_TEST_TYPE_MODULE_INTEGRITY>)
  104. Uses HMAC SHA256 on the module file to validate that the module has not been
  105. modified. The integrity value is compared to a value written to a configuration
  106. file during installation.
  107. =item "Install_Integrity" (B<OSSL_SELF_TEST_TYPE_INSTALL_INTEGRITY>)
  108. Uses HMAC SHA256 on a fixed string to validate that the installation process
  109. has already been performed and the self test KATS have already been tested,
  110. The integrity value is compared to a value written to a configuration
  111. file after successfully running the self tests during installation.
  112. =item "KAT_Cipher" (B<OSSL_SELF_TEST_TYPE_KAT_CIPHER>)
  113. Known answer test for a symmetric cipher.
  114. =item "KAT_AsymmetricCipher" (B<OSSL_SELF_TEST_TYPE_KAT_ASYM_CIPHER>)
  115. Known answer test for a asymmetric cipher.
  116. =item "KAT_Digest" (B<OSSL_SELF_TEST_TYPE_KAT_DIGEST>)
  117. Known answer test for a digest.
  118. =item "KAT_Signature" (B<OSSL_SELF_TEST_TYPE_KAT_SIGNATURE>)
  119. Known answer test for a signature.
  120. =item "KAT_KDF" (B<OSSL_SELF_TEST_TYPE_KAT_KDF>)
  121. Known answer test for a key derivation function.
  122. =item "KAT_KA" (B<OSSL_SELF_TEST_TYPE_KAT_KA>)
  123. Known answer test for key agreement.
  124. =item "DRBG" (B<OSSL_SELF_TEST_TYPE_DRBG>)
  125. Known answer test for a Deterministic Random Bit Generator.
  126. =item "Pairwise_Consistency_Test" (B<OSSL_SELF_TEST_TYPE_PCT>)
  127. Conditional test that is run during the generation of key pairs.
  128. =item "Continuous_RNG_Test" (B<OSSL_SELF_TEST_TYPE_CRNG>)
  129. Continuous random number generator test.
  130. =back
  131. The "Module_Integrity" self test is always run at startup.
  132. The "Install_Integrity" self test is used to check if the self tests have
  133. already been run at installation time. If they have already run then the
  134. self tests are not run on subsequent startups.
  135. All other self test categories are run once at installation time, except for the
  136. "Pairwise_Consistency_Test".
  137. There is only one instance of the "Module_Integrity" and "Install_Integrity"
  138. self tests. All other self tests may have multiple instances.
  139. The FIPS module passes the following descriptions(s) to OSSL_SELF_TEST_onbegin().
  140. =over 4
  141. =item "HMAC" (B<OSSL_SELF_TEST_DESC_INTEGRITY_HMAC>)
  142. "Module_Integrity" and "Install_Integrity" use this.
  143. =item "RSA" (B<OSSL_SELF_TEST_DESC_PCT_RSA_PKCS1>)
  144. =item "ECDSA" (B<OSSL_SELF_TEST_DESC_PCT_ECDSA>)
  145. =item "DSA" (B<OSSL_SELF_TEST_DESC_PCT_DSA>)
  146. Key generation tests used with the "Pairwise_Consistency_Test" type.
  147. =item "RSA_Encrypt" (B<OSSL_SELF_TEST_DESC_ASYM_RSA_ENC>)
  148. =item "RSA_Decrypt" (B<OSSL_SELF_TEST_DESC_ASYM_RSA_DEC>)
  149. "KAT_AsymmetricCipher" uses this to indicate an encrypt or decrypt KAT.
  150. =item "AES_GCM" (B<OSSL_SELF_TEST_DESC_CIPHER_AES_GCM>)
  151. =item "TDES" (B<OSSL_SELF_TEST_DESC_CIPHER_TDES>)
  152. Symmetric cipher tests used with the "KAT_Cipher" type.
  153. =item "SHA1" (B<OSSL_SELF_TEST_DESC_MD_SHA1>)
  154. =item "SHA2" (B<OSSL_SELF_TEST_DESC_MD_SHA2>)
  155. =item "SHA3" (B<OSSL_SELF_TEST_DESC_MD_SHA3>)
  156. Digest tests used with the "KAT_Digest" type.
  157. =item "DSA" (B<OSSL_SELF_TEST_DESC_SIGN_DSA>)
  158. =item "RSA" (B<OSSL_SELF_TEST_DESC_SIGN_RSA>)
  159. =item "ECDSA" (B<OSSL_SELF_TEST_DESC_SIGN_ECDSA>)
  160. Signature tests used with the "KAT_Signature" type.
  161. =item "ECDH" (B<OSSL_SELF_TEST_DESC_KA_ECDH>)
  162. =item "DH" (B<OSSL_SELF_TEST_DESC_KA_DH>)
  163. Key agreement tests used with the "KAT_KA" type.
  164. =item "HKDF" (B<OSSL_SELF_TEST_DESC_KDF_HKDF>)
  165. =item "SSKDF" (B<OSSL_SELF_TEST_DESC_KDF_SSKDF>)
  166. =item "X963KDF" (B<OSSL_SELF_TEST_DESC_KDF_X963KDF>)
  167. =item "X942KDF" (B<OSSL_SELF_TEST_DESC_KDF_X942KDF>)
  168. =item "PBKDF2" (B<OSSL_SELF_TEST_DESC_KDF_PBKDF2>)
  169. =item "SSHKDF" (B<OSSL_SELF_TEST_DESC_KDF_SSHKDF>)
  170. =item "TLS12_PRF" (B<OSSL_SELF_TEST_DESC_KDF_TLS12_PRF>)
  171. =item "KBKDF" (B<OSSL_SELF_TEST_DESC_KDF_KBKDF>)
  172. Key Derivation Function tests used with the "KAT_KDF" type.
  173. =item "CTR" (B<OSSL_SELF_TEST_DESC_DRBG_CTR>)
  174. =item "HASH" (B<OSSL_SELF_TEST_DESC_DRBG_HASH>)
  175. =item "HMAC" (B<OSSL_SELF_TEST_DESC_DRBG_HMAC>)
  176. DRBG tests used with the "DRBG" type.
  177. = item "RNG" (B<OSSL_SELF_TEST_DESC_RNG>)
  178. "Continuous_RNG_Test" uses this.
  179. =back
  180. =head1 EXAMPLES
  181. A simple self test callback is shown below for illustrative purposes.
  182. #include <openssl/self_test.h>
  183. static OSSL_CALLBACK self_test_cb;
  184. static int self_test_cb(const OSSL_PARAM params[], void *arg)
  185. {
  186. int ret = 0;
  187. const OSSL_PARAM *p = NULL;
  188. const char *phase = NULL, *type = NULL, *desc = NULL;
  189. p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_PHASE);
  190. if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
  191. goto err;
  192. phase = (const char *)p->data;
  193. p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_DESC);
  194. if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
  195. goto err;
  196. desc = (const char *)p->data;
  197. p = OSSL_PARAM_locate_const(params, OSSL_PROV_PARAM_SELF_TEST_TYPE);
  198. if (p == NULL || p->data_type != OSSL_PARAM_UTF8_STRING)
  199. goto err;
  200. type = (const char *)p->data;
  201. /* Do some logging */
  202. if (strcmp(phase, OSSL_SELF_TEST_PHASE_START) == 0)
  203. BIO_printf(bio_out, "%s : (%s) : ", desc, type);
  204. if (strcmp(phase, OSSL_SELF_TEST_PHASE_PASS) == 0
  205. || strcmp(phase, OSSL_SELF_TEST_PHASE_FAIL) == 0)
  206. BIO_printf(bio_out, "%s\n", phase);
  207. /* Corrupt the SHA1 self test during the 'corrupt' phase by returning 0 */
  208. if (strcmp(phase, OSSL_SELF_TEST_PHASE_CORRUPT) == 0
  209. && strcmp(desc, OSSL_SELF_TEST_DESC_MD_SHA1) == 0) {
  210. BIO_printf(bio_out, "%s %s", phase, desc);
  211. return 0;
  212. }
  213. ret = 1;
  214. err:
  215. return ret;
  216. }
  217. =head1 SEE ALSO
  218. L<openssl-fipsinstall(1)>,
  219. L<fips_config(5)>,
  220. L<OSSL_SELF_TEST_set_callback(3)>,
  221. L<OSSL_SELF_TEST_new(3)>,
  222. L<OSSL_PARAM(3)>,
  223. L<openssl-core.h(7)>,
  224. L<openssl-core_dispatch.h(7)>,
  225. L<provider(7)>
  226. =head1 HISTORY
  227. The type and functions described here were added in OpenSSL 3.0.
  228. =head1 COPYRIGHT
  229. Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
  230. Licensed under the Apache License 2.0 (the "License"). You may not use
  231. this file except in compliance with the License. You can obtain a copy
  232. in the file LICENSE in the source distribution or at
  233. L<https://www.openssl.org/source/license.html>.
  234. =cut