EVP_PKEY-DH.7ossl 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. .\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .nr rF 0
  58. .if \n(.g .if rF .nr rF 1
  59. .if (\n(rF:(\n(.g==0)) \{\
  60. . if \nF \{\
  61. . de IX
  62. . tm Index:\\$1\t\\n%\t"\\$2"
  63. ..
  64. . if !\nF==2 \{\
  65. . nr % 0
  66. . nr F 2
  67. . \}
  68. . \}
  69. .\}
  70. .rr rF
  71. .\"
  72. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  73. .\" Fear. Run. Save yourself. No user-serviceable parts.
  74. . \" fudge factors for nroff and troff
  75. .if n \{\
  76. . ds #H 0
  77. . ds #V .8m
  78. . ds #F .3m
  79. . ds #[ \f1
  80. . ds #] \fP
  81. .\}
  82. .if t \{\
  83. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  84. . ds #V .6m
  85. . ds #F 0
  86. . ds #[ \&
  87. . ds #] \&
  88. .\}
  89. . \" simple accents for nroff and troff
  90. .if n \{\
  91. . ds ' \&
  92. . ds ` \&
  93. . ds ^ \&
  94. . ds , \&
  95. . ds ~ ~
  96. . ds /
  97. .\}
  98. .if t \{\
  99. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  100. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  101. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  102. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  103. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  104. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  105. .\}
  106. . \" troff and (daisy-wheel) nroff accents
  107. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  108. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  109. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  110. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  111. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  112. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  113. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  114. .ds ae a\h'-(\w'a'u*4/10)'e
  115. .ds Ae A\h'-(\w'A'u*4/10)'E
  116. . \" corrections for vroff
  117. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  118. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  119. . \" for low resolution devices (crt and lpr)
  120. .if \n(.H>23 .if \n(.V>19 \
  121. \{\
  122. . ds : e
  123. . ds 8 ss
  124. . ds o a
  125. . ds d- d\h'-1'\(ga
  126. . ds D- D\h'-1'\(hy
  127. . ds th \o'bp'
  128. . ds Th \o'LP'
  129. . ds ae ae
  130. . ds Ae AE
  131. .\}
  132. .rm #[ #] #H #V #F C
  133. .\" ========================================================================
  134. .\"
  135. .IX Title "EVP_PKEY-DH 7ossl"
  136. .TH EVP_PKEY-DH 7ossl "2024-09-03" "3.3.2" "OpenSSL"
  137. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  138. .\" way too many mistakes in technical documents.
  139. .if n .ad l
  140. .nh
  141. .SH "NAME"
  142. EVP_PKEY\-DH, EVP_PKEY\-DHX, EVP_KEYMGMT\-DH, EVP_KEYMGMT\-DHX
  143. \&\- EVP_PKEY DH and DHX keytype and algorithm support
  144. .SH "DESCRIPTION"
  145. .IX Header "DESCRIPTION"
  146. For finite field Diffie-Hellman key agreement, two classes of domain
  147. parameters can be used: \*(L"safe\*(R" domain parameters that are associated with
  148. approved named safe-prime groups, and a class of \*(L"FIPS186\-type\*(R" domain
  149. parameters. FIPS186\-type domain parameters should only be used for backward
  150. compatibility with existing applications that cannot be upgraded to use the
  151. approved safe-prime groups.
  152. .PP
  153. See \s-1\fBEVP_PKEY\-FFC\s0\fR\|(7) for more information about \s-1FFC\s0 keys.
  154. .PP
  155. The \fB\s-1DH\s0\fR key type uses PKCS#3 format which saves \fIp\fR and \fIg\fR, but not the
  156. \&\fIq\fR value.
  157. The \fB\s-1DHX\s0\fR key type uses X9.42 format which saves the value of \fIq\fR and this
  158. must be used for \s-1FIPS186\-4.\s0 If key validation is required, users should be aware
  159. of the nuances associated with \s-1FIPS186\-4\s0 style parameters as discussed in
  160. \&\*(L"\s-1DH\s0 and \s-1DHX\s0 key validation\*(R".
  161. .SS "\s-1DH\s0 and \s-1DHX\s0 domain parameters"
  162. .IX Subsection "DH and DHX domain parameters"
  163. In addition to the common \s-1FFC\s0 parameters that all \s-1FFC\s0 keytypes should support
  164. (see \*(L"\s-1FFC\s0 parameters\*(R" in \s-1\fBEVP_PKEY\-FFC\s0\fR\|(7)) the \fB\s-1DHX\s0\fR and \fB\s-1DH\s0\fR keytype
  165. implementations support the following:
  166. .ie n .IP """group"" (\fB\s-1OSSL_PKEY_PARAM_GROUP_NAME\s0\fR) <\s-1UTF8\s0 string>" 4
  167. .el .IP "``group'' (\fB\s-1OSSL_PKEY_PARAM_GROUP_NAME\s0\fR) <\s-1UTF8\s0 string>" 4
  168. .IX Item "group (OSSL_PKEY_PARAM_GROUP_NAME) <UTF8 string>"
  169. Sets or gets a string that associates a \fB\s-1DH\s0\fR or \fB\s-1DHX\s0\fR named safe prime group
  170. with known values for \fIp\fR, \fIq\fR and \fIg\fR.
  171. .Sp
  172. The following values can be used by the OpenSSL's default and \s-1FIPS\s0 providers:
  173. \&\*(L"ffdhe2048\*(R", \*(L"ffdhe3072\*(R", \*(L"ffdhe4096\*(R", \*(L"ffdhe6144\*(R", \*(L"ffdhe8192\*(R",
  174. \&\*(L"modp_2048\*(R", \*(L"modp_3072\*(R", \*(L"modp_4096\*(R", \*(L"modp_6144\*(R", \*(L"modp_8192\*(R".
  175. .Sp
  176. The following additional values can also be used by OpenSSL's default provider:
  177. \&\*(L"modp_1536\*(R", \*(L"dh_1024_160\*(R", \*(L"dh_2048_224\*(R", \*(L"dh_2048_256\*(R".
  178. .Sp
  179. \&\s-1DH/DHX\s0 named groups can be easily validated since the parameters are well known.
  180. For protocols that only transfer \fIp\fR and \fIg\fR the value of \fIq\fR can also be
  181. retrieved.
  182. .SS "\s-1DH\s0 and \s-1DHX\s0 additional parameters"
  183. .IX Subsection "DH and DHX additional parameters"
  184. .ie n .IP """encoded-pub-key"" (\fB\s-1OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY\s0\fR) <octet string>" 4
  185. .el .IP "``encoded-pub-key'' (\fB\s-1OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY\s0\fR) <octet string>" 4
  186. .IX Item "encoded-pub-key (OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY) <octet string>"
  187. Used for getting and setting the encoding of the \s-1DH\s0 public key used in a key
  188. exchange message for the \s-1TLS\s0 protocol.
  189. See \fBEVP_PKEY_set1_encoded_public_key()\fR and \fBEVP_PKEY_get1_encoded_public_key()\fR.
  190. .SS "\s-1DH\s0 additional domain parameters"
  191. .IX Subsection "DH additional domain parameters"
  192. .ie n .IP """safeprime-generator"" (\fB\s-1OSSL_PKEY_PARAM_DH_GENERATOR\s0\fR) <integer>" 4
  193. .el .IP "``safeprime-generator'' (\fB\s-1OSSL_PKEY_PARAM_DH_GENERATOR\s0\fR) <integer>" 4
  194. .IX Item "safeprime-generator (OSSL_PKEY_PARAM_DH_GENERATOR) <integer>"
  195. Used for \s-1DH\s0 generation of safe primes using the old safe prime generator code.
  196. The default value is 2.
  197. It is recommended to use a named safe prime group instead, if domain parameter
  198. validation is required.
  199. .Sp
  200. Randomly generated safe primes are not allowed by \s-1FIPS,\s0 so setting this value
  201. for the OpenSSL \s-1FIPS\s0 provider will instead choose a named safe prime group
  202. based on the size of \fIp\fR.
  203. .SS "\s-1DH\s0 and \s-1DHX\s0 domain parameter / key generation parameters"
  204. .IX Subsection "DH and DHX domain parameter / key generation parameters"
  205. In addition to the common \s-1FFC\s0 key generation parameters that all \s-1FFC\s0 key types
  206. should support (see \*(L"\s-1FFC\s0 key generation parameters\*(R" in \s-1\fBEVP_PKEY\-FFC\s0\fR\|(7)) the
  207. \&\fB\s-1DH\s0\fR and \fB\s-1DHX\s0\fR keytype implementation supports the following:
  208. .ie n .IP """type"" (\fB\s-1OSSL_PKEY_PARAM_FFC_TYPE\s0\fR) <\s-1UTF8\s0 string>" 4
  209. .el .IP "``type'' (\fB\s-1OSSL_PKEY_PARAM_FFC_TYPE\s0\fR) <\s-1UTF8\s0 string>" 4
  210. .IX Item "type (OSSL_PKEY_PARAM_FFC_TYPE) <UTF8 string>"
  211. Sets the type of parameter generation. For \fB\s-1DH\s0\fR valid values are:
  212. .RS 4
  213. .ie n .IP """fips186_4""" 4
  214. .el .IP "``fips186_4''" 4
  215. .IX Item "fips186_4"
  216. .PD 0
  217. .ie n .IP """default""" 4
  218. .el .IP "``default''" 4
  219. .IX Item "default"
  220. .ie n .IP """fips186_2""" 4
  221. .el .IP "``fips186_2''" 4
  222. .IX Item "fips186_2"
  223. .PD
  224. These are described in \*(L"\s-1FFC\s0 key generation parameters\*(R" in \s-1\fBEVP_PKEY\-FFC\s0\fR\|(7)
  225. .ie n .IP """group""" 4
  226. .el .IP "``group''" 4
  227. .IX Item "group"
  228. This specifies that a named safe prime name will be chosen using the \*(L"pbits\*(R"
  229. type.
  230. .ie n .IP """generator""" 4
  231. .el .IP "``generator''" 4
  232. .IX Item "generator"
  233. A safe prime generator. See the \*(L"safeprime-generator\*(R" type above.
  234. This is only valid for \fB\s-1DH\s0\fR keys.
  235. .RE
  236. .RS 4
  237. .RE
  238. .ie n .IP """pbits"" (\fB\s-1OSSL_PKEY_PARAM_FFC_PBITS\s0\fR) <unsigned integer>" 4
  239. .el .IP "``pbits'' (\fB\s-1OSSL_PKEY_PARAM_FFC_PBITS\s0\fR) <unsigned integer>" 4
  240. .IX Item "pbits (OSSL_PKEY_PARAM_FFC_PBITS) <unsigned integer>"
  241. Sets the size (in bits) of the prime 'p'.
  242. .Sp
  243. For \*(L"fips186_4\*(R" this must be 2048.
  244. For \*(L"fips186_2\*(R" this must be 1024.
  245. For \*(L"group\*(R" this can be any one of 2048, 3072, 4096, 6144 or 8192.
  246. .ie n .IP """priv_len"" (\fB\s-1OSSL_PKEY_PARAM_DH_PRIV_LEN\s0\fR) <integer>" 4
  247. .el .IP "``priv_len'' (\fB\s-1OSSL_PKEY_PARAM_DH_PRIV_LEN\s0\fR) <integer>" 4
  248. .IX Item "priv_len (OSSL_PKEY_PARAM_DH_PRIV_LEN) <integer>"
  249. An optional value to set the maximum length of the generated private key.
  250. The default value used if this is not set is the maximum value of
  251. BN_num_bits(\fIq\fR)). The minimum value that this can be set to is 2 * s.
  252. Where s is the security strength of the key which has values of
  253. 112, 128, 152, 176 and 200 for key sizes of 2048, 3072, 4096, 6144 and 8192.
  254. .SS "\s-1DH\s0 and \s-1DHX\s0 key validation"
  255. .IX Subsection "DH and DHX key validation"
  256. For keys that are not a named group the \s-1FIPS186\-4\s0 standard specifies that the
  257. values used for \s-1FFC\s0 parameter generation are also required for parameter
  258. validation. This means that optional \s-1FFC\s0 domain parameter values for
  259. \&\fIseed\fR, \fIpcounter\fR and \fIgindex\fR or \fIhindex\fR may need to be stored for
  260. validation purposes.
  261. For \fB\s-1DHX\s0\fR the \fIseed\fR and \fIpcounter\fR can be stored in \s-1ASN1\s0 data
  262. (but the \fIgindex\fR or \fIhindex\fR cannot be stored). It is recommended to use a
  263. \&\fB\s-1DH\s0\fR parameters with named safe prime group instead.
  264. .PP
  265. With the OpenSSL \s-1FIPS\s0 provider, \fBEVP_PKEY_param_check\fR\|(3) and
  266. \&\fBEVP_PKEY_param_check_quick\fR\|(3) behave in the following way: the parameters
  267. are tested if they are either an approved safe prime group \s-1OR\s0 that the \s-1FFC\s0
  268. parameters conform to \s-1FIPS186\-4\s0 as defined in SP800\-56Ar3 \fIAssurances of
  269. Domain-Parameter Validity\fR.
  270. .PP
  271. The OpenSSL default provider uses simpler checks that allows there to be no \fIq\fR
  272. value for backwards compatibility, however the \fBEVP_PKEY_param_check\fR\|(3) will
  273. test the \fIp\fR value for being a prime (and a safe prime if \fIq\fR is missing)
  274. which can take significant time. The \fBEVP_PKEY_param_check_quick\fR\|(3) avoids
  275. the prime tests.
  276. .PP
  277. \&\fBEVP_PKEY_public_check\fR\|(3) conforms to SP800\-56Ar3
  278. \&\fI\s-1FFC\s0 Full Public-Key Validation\fR.
  279. .PP
  280. \&\fBEVP_PKEY_public_check_quick\fR\|(3) conforms to SP800\-56Ar3
  281. \&\fI\s-1FFC\s0 Partial Public-Key Validation\fR when the key is an approved named safe
  282. prime group, otherwise it is the same as \fBEVP_PKEY_public_check\fR\|(3).
  283. .PP
  284. \&\fBEVP_PKEY_private_check\fR\|(3) tests that the private key is in the correct range
  285. according to SP800\-56Ar3. The OpenSSL \s-1FIPS\s0 provider requires the value of \fIq\fR
  286. to be set (note that this is implicitly set for named safe prime groups).
  287. For backwards compatibility the OpenSSL default provider only requires \fIp\fR to
  288. be set.
  289. .PP
  290. \&\fBEVP_PKEY_pairwise_check\fR\|(3) conforms to SP800\-56Ar3
  291. \&\fIOwner Assurance of Pair-wise Consistency\fR.
  292. .SH "EXAMPLES"
  293. .IX Header "EXAMPLES"
  294. An \fB\s-1EVP_PKEY\s0\fR context can be obtained by calling:
  295. .PP
  296. .Vb 1
  297. \& EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_from_name(NULL, "DH", NULL);
  298. .Ve
  299. .PP
  300. A \fB\s-1DH\s0\fR key can be generated with a named safe prime group by calling:
  301. .PP
  302. .Vb 4
  303. \& int priv_len = 2 * 112;
  304. \& OSSL_PARAM params[3];
  305. \& EVP_PKEY *pkey = NULL;
  306. \& EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_from_name(NULL, "DH", NULL);
  307. \&
  308. \& params[0] = OSSL_PARAM_construct_utf8_string("group", "ffdhe2048", 0);
  309. \& /* "priv_len" is optional */
  310. \& params[1] = OSSL_PARAM_construct_int("priv_len", &priv_len);
  311. \& params[2] = OSSL_PARAM_construct_end();
  312. \&
  313. \& EVP_PKEY_keygen_init(pctx);
  314. \& EVP_PKEY_CTX_set_params(pctx, params);
  315. \& EVP_PKEY_generate(pctx, &pkey);
  316. \& ...
  317. \& EVP_PKEY_free(pkey);
  318. \& EVP_PKEY_CTX_free(pctx);
  319. .Ve
  320. .PP
  321. \&\fB\s-1DHX\s0\fR domain parameters can be generated according to \fB\s-1FIPS186\-4\s0\fR by calling:
  322. .PP
  323. .Vb 6
  324. \& int gindex = 2;
  325. \& unsigned int pbits = 2048;
  326. \& unsigned int qbits = 256;
  327. \& OSSL_PARAM params[6];
  328. \& EVP_PKEY *param_key = NULL;
  329. \& EVP_PKEY_CTX *pctx = NULL;
  330. \&
  331. \& pctx = EVP_PKEY_CTX_new_from_name(NULL, "DHX", NULL);
  332. \& EVP_PKEY_paramgen_init(pctx);
  333. \&
  334. \& params[0] = OSSL_PARAM_construct_uint("pbits", &pbits);
  335. \& params[1] = OSSL_PARAM_construct_uint("qbits", &qbits);
  336. \& params[2] = OSSL_PARAM_construct_int("gindex", &gindex);
  337. \& params[3] = OSSL_PARAM_construct_utf8_string("type", "fips186_4", 0);
  338. \& params[4] = OSSL_PARAM_construct_utf8_string("digest", "SHA256", 0);
  339. \& params[5] = OSSL_PARAM_construct_end();
  340. \& EVP_PKEY_CTX_set_params(pctx, params);
  341. \&
  342. \& EVP_PKEY_generate(pctx, &param_key);
  343. \&
  344. \& EVP_PKEY_print_params(bio_out, param_key, 0, NULL);
  345. \& ...
  346. \& EVP_PKEY_free(param_key);
  347. \& EVP_PKEY_CTX_free(pctx);
  348. .Ve
  349. .PP
  350. A \fB\s-1DH\s0\fR key can be generated using domain parameters by calling:
  351. .PP
  352. .Vb 2
  353. \& EVP_PKEY *key = NULL;
  354. \& EVP_PKEY_CTX *gctx = EVP_PKEY_CTX_new_from_pkey(NULL, param_key, NULL);
  355. \&
  356. \& EVP_PKEY_keygen_init(gctx);
  357. \& EVP_PKEY_generate(gctx, &key);
  358. \& EVP_PKEY_print_private(bio_out, key, 0, NULL);
  359. \& ...
  360. \& EVP_PKEY_free(key);
  361. \& EVP_PKEY_CTX_free(gctx);
  362. .Ve
  363. .PP
  364. To validate \fB\s-1FIPS186\-4\s0\fR \fB\s-1DHX\s0\fR domain parameters decoded from \fB\s-1PEM\s0\fR or
  365. \&\fB\s-1DER\s0\fR data, additional values used during generation may be required to
  366. be set into the key.
  367. .PP
  368. \&\fBEVP_PKEY_todata()\fR, \fBOSSL_PARAM_merge()\fR, and \fBEVP_PKEY_fromdata()\fR are useful
  369. to add these parameters to the original key or domain parameters before
  370. the actual validation. In production code the return values should be checked.
  371. .PP
  372. .Vb 11
  373. \& EVP_PKEY *received_domp = ...; /* parameters received and decoded */
  374. \& unsigned char *seed = ...; /* and additional parameters received */
  375. \& size_t seedlen = ...; /* by other means, required */
  376. \& int gindex = ...; /* for the validation */
  377. \& int pcounter = ...;
  378. \& int hindex = ...;
  379. \& OSSL_PARAM extra_params[4];
  380. \& OSSL_PARAM *domain_params = NULL;
  381. \& OSSL_PARAM *merged_params = NULL;
  382. \& EVP_PKEY_CTX *ctx = NULL, *validate_ctx = NULL;
  383. \& EVP_PKEY *complete_domp = NULL;
  384. \&
  385. \& EVP_PKEY_todata(received_domp, OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS,
  386. \& &domain_params);
  387. \& extra_params[0] = OSSL_PARAM_construct_octet_string("seed", seed, seedlen);
  388. \& /*
  389. \& * NOTE: For unverifiable g use "hindex" instead of "gindex"
  390. \& * extra_params[1] = OSSL_PARAM_construct_int("hindex", &hindex);
  391. \& */
  392. \& extra_params[1] = OSSL_PARAM_construct_int("gindex", &gindex);
  393. \& extra_params[2] = OSSL_PARAM_construct_int("pcounter", &pcounter);
  394. \& extra_params[3] = OSSL_PARAM_construct_end();
  395. \& merged_params = OSSL_PARAM_merge(domain_params, extra_params);
  396. \&
  397. \& ctx = EVP_PKEY_CTX_new_from_name(NULL, "DHX", NULL);
  398. \& EVP_PKEY_fromdata_init(ctx);
  399. \& EVP_PKEY_fromdata(ctx, &complete_domp, OSSL_KEYMGMT_SELECT_ALL,
  400. \& merged_params);
  401. \&
  402. \& validate_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, complete_domp, NULL);
  403. \& if (EVP_PKEY_param_check(validate_ctx) > 0)
  404. \& /* validation_passed(); */
  405. \& else
  406. \& /* validation_failed(); */
  407. \&
  408. \& OSSL_PARAM_free(domain_params);
  409. \& OSSL_PARAM_free(merged_params);
  410. \& EVP_PKEY_CTX_free(ctx);
  411. \& EVP_PKEY_CTX_free(validate_ctx);
  412. \& EVP_PKEY_free(complete_domp);
  413. .Ve
  414. .SH "CONFORMING TO"
  415. .IX Header "CONFORMING TO"
  416. .IP "\s-1RFC 7919\s0 (\s-1TLS\s0 ffdhe named safe prime groups)" 4
  417. .IX Item "RFC 7919 (TLS ffdhe named safe prime groups)"
  418. .PD 0
  419. .IP "\s-1RFC 3526\s0 (\s-1IKE\s0 modp named safe prime groups)" 4
  420. .IX Item "RFC 3526 (IKE modp named safe prime groups)"
  421. .ie n .IP "\s-1RFC 5114\s0 (Additional \s-1DH\s0 named groups for dh_1024_160"", ""dh_2048_224"" and ""dh_2048_256"")." 4
  422. .el .IP "\s-1RFC 5114\s0 (Additional \s-1DH\s0 named groups for dh_1024_160``, ''dh_2048_224`` and ''dh_2048_256"")." 4
  423. .IX Item "RFC 5114 (Additional DH named groups for dh_1024_160, dh_2048_224 and dh_2048_256"")."
  424. .PD
  425. .PP
  426. The following sections of SP800\-56Ar3:
  427. .IP "5.5.1.1 \s-1FFC\s0 Domain Parameter Selection/Generation" 4
  428. .IX Item "5.5.1.1 FFC Domain Parameter Selection/Generation"
  429. .PD 0
  430. .IP "Appendix D: \s-1FFC\s0 Safe-prime Groups" 4
  431. .IX Item "Appendix D: FFC Safe-prime Groups"
  432. .PD
  433. .PP
  434. The following sections of \s-1FIPS186\-4:\s0
  435. .IP "A.1.1.2 Generation of Probable Primes p and q Using an Approved Hash Function." 4
  436. .IX Item "A.1.1.2 Generation of Probable Primes p and q Using an Approved Hash Function."
  437. .PD 0
  438. .IP "A.2.3 Generation of canonical generator g." 4
  439. .IX Item "A.2.3 Generation of canonical generator g."
  440. .IP "A.2.1 Unverifiable Generation of the Generator g." 4
  441. .IX Item "A.2.1 Unverifiable Generation of the Generator g."
  442. .PD
  443. .SH "SEE ALSO"
  444. .IX Header "SEE ALSO"
  445. \&\s-1\fBEVP_PKEY\-FFC\s0\fR\|(7),
  446. \&\s-1\fBEVP_KEYEXCH\-DH\s0\fR\|(7)
  447. \&\s-1\fBEVP_PKEY\s0\fR\|(3),
  448. \&\fBprovider\-keymgmt\fR\|(7),
  449. \&\s-1\fBEVP_KEYMGMT\s0\fR\|(3),
  450. \&\fBOSSL_PROVIDER\-default\fR\|(7),
  451. \&\s-1\fBOSSL_PROVIDER\-FIPS\s0\fR\|(7)
  452. .SH "COPYRIGHT"
  453. .IX Header "COPYRIGHT"
  454. Copyright 2020\-2024 The OpenSSL Project Authors. All Rights Reserved.
  455. .PP
  456. Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
  457. this file except in compliance with the License. You can obtain a copy
  458. in the file \s-1LICENSE\s0 in the source distribution or at
  459. <https://www.openssl.org/source/license.html>.