EVP_PKEY-FFC.pod 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. =pod
  2. =head1 NAME
  3. EVP_PKEY-FFC - EVP_PKEY DSA and DH shared FFC parameters.
  4. =head1 DESCRIPTION
  5. Finite field cryptography (FFC) is a method of implementing discrete logarithm
  6. cryptography using finite field mathematics. DSA is an example of FFC and
  7. Diffie-Hellman key establishment algorithms specified in SP800-56A can also be
  8. implemented as FFC.
  9. The B<DSA> and B<DH> keytypes are implemented in OpenSSL's default and FIPS
  10. providers.
  11. The implementations support the basic DSA and DH keys, containing the public
  12. and private keys I<pub> and I<priv> as well as the three main domain parameters
  13. I<p>, I<q> and I<g>.
  14. For B<DSA> (and B<DH> that is not a named group) the FIPS186-4 standard
  15. specifies that the values used for FFC parameter generation are also required
  16. for parameter validation.
  17. This means that optional FFC domain parameter values for I<seed>, I<pcounter>
  18. and I<gindex> may need to be stored for validation purposes.
  19. For B<DH> the I<seed> and I<pcounter> can be stored in ASN1 data
  20. (but the I<gindex> is not). For B<DSA> however, these fields are not stored in
  21. the ASN1 data so they need to be stored externally if validation is required.
  22. =head2 FFC parameters
  23. In addition to the common parameters that all keytypes should support (see
  24. L<provider-keymgmt(7)/Common parameters>), the B<DSA> and B<DH> keytype
  25. implementations support the following.
  26. =over 4
  27. =item "pub" (B<OSSL_PKEY_PARAM_PUB_KEY>) <unsigned integer>
  28. The public key value.
  29. =item "priv" (B<OSSL_PKEY_PARAM_PRIV_KEY>) <unsigned integer>
  30. The private key value.
  31. =item "p" (B<OSSL_PKEY_PARAM_FFC_P>) <unsigned integer>
  32. A DSA or Diffie-Hellman prime "p" value.
  33. =item "q" (B<OSSL_PKEY_PARAM_FFC_Q>) <unsigned integer>
  34. A DSA or Diffie-Hellman prime "q" value.
  35. =item "g" (B<OSSL_PKEY_PARAM_FFC_G>) <unsigned integer>
  36. A DSA or Diffie-Hellman generator "g" value.
  37. =item "seed" (B<OSSL_PKEY_PARAM_FFC_SEED>) <octet string>
  38. An optional domain parameter I<seed> value used during generation and validation
  39. of I<p>, I<q> and canonical I<g>.
  40. For validation this needs to set the I<seed> that was produced during generation.
  41. =item "gindex" (B<OSSL_PKEY_PARAM_FFC_GINDEX>) <integer>
  42. Sets the index to use for canonical generation and verification of the generator
  43. I<g>.
  44. Set this to a positive value from 0..FF to use this mode. This I<gindex> can
  45. then be reused during key validation to verify the value of I<g>. If this value
  46. is not set or is -1 then unverifiable generation of the generator I<g> will be
  47. used.
  48. =item "pcounter" (B<OSSL_PKEY_PARAM_FFC_PCOUNTER>) <integer>
  49. An optional domain parameter I<counter> value that is output during generation
  50. of I<p>. This value must be saved if domain parameter validation is required.
  51. =item "hindex" (B<OSSL_PKEY_PARAM_FFC_H>) <integer>
  52. For unverifiable generation of the generator I<g> this value is output during
  53. generation of I<g>. Its value is the first integer larger than one that
  54. satisfies g = h^j mod p (where g != 1 and "j" is the cofactor).
  55. =item "j" (B<OSSL_PKEY_PARAM_FFC_COFACTOR>) <unsigned integer>
  56. An optional informational cofactor parameter that should equal to (p - 1) / q.
  57. =back
  58. =head2 FFC key generation parameters
  59. The following key generation types are available for DSA and DH algorithms:
  60. =over 4
  61. =item "type" (B<OSSL_PKEY_PARAM_FFC_TYPE>) <utf8_string>
  62. Sets the type of parameter generation. The shared valid values are:
  63. =over 4
  64. =item "fips186_4"
  65. The current standard. This is the default value.
  66. =item "fips186_2"
  67. The old standard that should only be used for legacy purposes.
  68. =item "default"
  69. This is an alias to use the latest implemented standard.
  70. It is currently set to "fips186_4".
  71. =back
  72. =item "pbits" (B<OSSL_PKEY_PARAM_FFC_PBITS>) <unsigned integer>
  73. Sets the size (in bits) of the prime 'p'.
  74. =item "qbits" (B<OSSL_PKEY_PARAM_FFC_QBITS>) <unsigned integer>
  75. Sets the size (in bits) of the prime 'q'.
  76. For "fips186_4" this can be either 224 or 256.
  77. For "fips186_2" this has a size of 160.
  78. =item "digest" (B<OSSL_PKEY_PARAM_FFC_DIGEST>) <utf8_string>
  79. Sets the Digest algorithm to be used as part of the Key Generation Function
  80. associated with the given Key Generation I<ctx>.
  81. This must also be set for key validation.
  82. =item "properties" (B<OSSL_PKEY_PARAM_FFC_DIGEST_PROPS>) <utf8_string>
  83. Sets properties to be used upon look up of the implementation for the selected
  84. Digest algorithm for the Key Generation Function associated with the given key
  85. generation I<ctx>. This may also be set for key validation.
  86. =item "seed" (B<OSSL_PKEY_PARAM_FFC_SEED>) <octet string>
  87. For "fips186_4" or "fips186_2" generation this sets the I<seed> data to use
  88. instead of generating a random seed internally. This should be used for
  89. testing purposes only. This will either produce fixed values for the generated
  90. parameters OR it will fail if the seed did not generate valid primes.
  91. =item "gindex" (B<OSSL_PKEY_PARAM_FFC_GINDEX>) <integer>
  92. =item "pcounter" (B<OSSL_PKEY_PARAM_FFC_PCOUNTER>) <integer>
  93. =item "hindex" (B<OSSL_PKEY_PARAM_FFC_H>) <integer>
  94. These types are described above.
  95. =back
  96. =head1 CONFORMING TO
  97. The following sections of SP800-56Ar3:
  98. =over 4
  99. =item 5.5.1.1 FFC Domain Parameter Selection/Generation
  100. =back
  101. The following sections of FIPS 186-4:
  102. =over 4
  103. =item A.1.1.2 Generation of Probable Primes p and q Using an Approved Hash Function.
  104. =item A.2.3 Generation of canonical generator g.
  105. =item A.2.1 Unverifiable Generation of the Generator g.
  106. =back
  107. =head1 SEE ALSO
  108. L<EVP_PKEY-DSA(7)>,
  109. L<EVP_PKEY-DH(7)>,
  110. L<EVP_SIGNATURE-DSA(7)>,
  111. L<EVP_KEYEXCH-DH(7)>
  112. L<EVP_KEYMGMT(3)>,
  113. L<EVP_PKEY(3)>,
  114. L<provider-keymgmt(7)>,
  115. L<OSSL_PROVIDER-default(7)>,
  116. L<OSSL_PROVIDER-FIPS(7)>,
  117. =head1 COPYRIGHT
  118. Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
  119. Licensed under the Apache License 2.0 (the "License"). You may not use
  120. this file except in compliance with the License. You can obtain a copy
  121. in the file LICENSE in the source distribution or at
  122. L<https://www.openssl.org/source/license.html>.
  123. =cut