SSL_CTX_set1_curves.3ossl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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 "SSL_CTX_SET1_CURVES 3ossl"
  58. .TH SSL_CTX_SET1_CURVES 3ossl 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. SSL_CTX_set1_groups, SSL_CTX_set1_groups_list, SSL_set1_groups,
  65. SSL_set1_groups_list, SSL_get1_groups, SSL_get0_iana_groups,
  66. SSL_get_shared_group, SSL_get_negotiated_group, SSL_CTX_set1_curves,
  67. SSL_CTX_set1_curves_list, SSL_set1_curves, SSL_set1_curves_list,
  68. SSL_get1_curves, SSL_get_shared_curve
  69. \&\- EC supported curve functions
  70. .SH SYNOPSIS
  71. .IX Header "SYNOPSIS"
  72. .Vb 1
  73. \& #include <openssl/ssl.h>
  74. \&
  75. \& int SSL_CTX_set1_groups(SSL_CTX *ctx, int *glist, int glistlen);
  76. \& int SSL_CTX_set1_groups_list(SSL_CTX *ctx, char *list);
  77. \&
  78. \& int SSL_set1_groups(SSL *ssl, int *glist, int glistlen);
  79. \& int SSL_set1_groups_list(SSL *ssl, char *list);
  80. \&
  81. \& int SSL_get1_groups(SSL *ssl, int *groups);
  82. \& int SSL_get0_iana_groups(SSL *ssl, uint16_t **out);
  83. \& int SSL_get_shared_group(SSL *s, int n);
  84. \& int SSL_get_negotiated_group(SSL *s);
  85. \&
  86. \& int SSL_CTX_set1_curves(SSL_CTX *ctx, int *clist, int clistlen);
  87. \& int SSL_CTX_set1_curves_list(SSL_CTX *ctx, char *list);
  88. \&
  89. \& int SSL_set1_curves(SSL *ssl, int *clist, int clistlen);
  90. \& int SSL_set1_curves_list(SSL *ssl, char *list);
  91. \&
  92. \& int SSL_get1_curves(SSL *ssl, int *curves);
  93. \& int SSL_get_shared_curve(SSL *s, int n);
  94. .Ve
  95. .SH DESCRIPTION
  96. .IX Header "DESCRIPTION"
  97. For all of the functions below that set the supported groups there must be at
  98. least one group in the list. A number of these functions identify groups via a
  99. unique integer NID value. However, support for some groups may be added by
  100. external providers. In this case there will be no NID assigned for the group.
  101. When setting such groups applications should use the "list" form of these
  102. functions (i.e. \fBSSL_CTX_set1_groups_list()\fR and SSL_set1_groups_list).
  103. .PP
  104. \&\fBSSL_CTX_set1_groups()\fR sets the supported groups for \fBctx\fR to \fBglistlen\fR
  105. groups in the array \fBglist\fR. The array consist of all NIDs of supported groups.
  106. Currently supported groups for \fBTLSv1.3\fR are \fBNID_X9_62_prime256v1\fR,
  107. \&\fBNID_secp384r1\fR, \fBNID_secp521r1\fR, \fBNID_X25519\fR, \fBNID_X448\fR,
  108. \&\fBNID_brainpoolP256r1tls13\fR, \fBNID_brainpoolP384r1tls13\fR,
  109. \&\fBNID_brainpoolP512r1tls13\fR, \fBNID_ffdhe2048\fR, \fBNID_ffdhe3072\fR,
  110. \&\fBNID_ffdhe4096\fR, \fBNID_ffdhe6144\fR and \fBNID_ffdhe8192\fR.
  111. OpenSSL will use this array in different ways depending on TLS role and version:
  112. .IP "For a TLS client, the groups are used directly in the supported groups extension. The extension's preference order, to be evaluated by the server, is determined by the order of the elements in the array." 4
  113. .IX Item "For a TLS client, the groups are used directly in the supported groups extension. The extension's preference order, to be evaluated by the server, is determined by the order of the elements in the array."
  114. .PD 0
  115. .IP "For a TLS 1.2 server, the groups determine the selected group. If \fBSSL_OP_CIPHER_SERVER_PREFERENCE\fR is set, the order of the elements in the array determines the selected group. Otherwise, the order is ignored and the client's order determines the selection." 4
  116. .IX Item "For a TLS 1.2 server, the groups determine the selected group. If SSL_OP_CIPHER_SERVER_PREFERENCE is set, the order of the elements in the array determines the selected group. Otherwise, the order is ignored and the client's order determines the selection."
  117. .IP "For a TLS 1.3 server, the groups determine the selected group, but selection is more complex. A TLS 1.3 client sends both a group list as well as a predicted subset of groups. Choosing a group outside the predicted subset incurs an extra roundtrip. However, in some situations, the most preferred group may not be predicted. OpenSSL considers all supported groups to be comparable in security and prioritizes avoiding roundtrips above either client or server preference order. If an application uses an external provider to extend OpenSSL with, e.g., a post-quantum algorithm, this behavior may allow a network attacker to downgrade connections to a weaker algorithm." 4
  118. .IX Item "For a TLS 1.3 server, the groups determine the selected group, but selection is more complex. A TLS 1.3 client sends both a group list as well as a predicted subset of groups. Choosing a group outside the predicted subset incurs an extra roundtrip. However, in some situations, the most preferred group may not be predicted. OpenSSL considers all supported groups to be comparable in security and prioritizes avoiding roundtrips above either client or server preference order. If an application uses an external provider to extend OpenSSL with, e.g., a post-quantum algorithm, this behavior may allow a network attacker to downgrade connections to a weaker algorithm."
  119. .PD
  120. .PP
  121. \&\fBSSL_CTX_set1_groups_list()\fR sets the supported groups for \fBctx\fR to
  122. string \fBlist\fR. The string is a colon separated list of group names, for example
  123. "P\-521:P\-384:P\-256:X25519:ffdhe2048". The groups are used as in
  124. \&\fBSSL_CTX_set1_groups()\fR, described above. Currently supported groups for
  125. \&\fBTLSv1.3\fR are \fBP\-256\fR, \fBP\-384\fR, \fBP\-521\fR, \fBX25519\fR, \fBX448\fR,
  126. \&\fBbrainpoolP256r1tls13\fR, \fBbrainpoolP384r1tls13\fR, \fBbrainpoolP512r1tls13\fR,
  127. \&\fBffdhe2048\fR, \fBffdhe3072\fR, \fBffdhe4096\fR, \fBffdhe6144\fR and \fBffdhe8192\fR. Support
  128. for other groups may be added by external providers, however note the discussion
  129. on TLS 1.3 selection criteria above. If a group name is preceded with the \f(CW\*(C`?\*(C'\fR
  130. character, it will be ignored if an implementation is missing.
  131. .PP
  132. \&\fBSSL_set1_groups()\fR and \fBSSL_set1_groups_list()\fR are similar except they set
  133. supported groups for the SSL structure \fBssl\fR.
  134. .PP
  135. \&\fBSSL_get1_groups()\fR returns the set of supported groups sent by a client
  136. in the supported groups extension. It returns the total number of
  137. supported groups. The \fBgroups\fR parameter can be \fBNULL\fR to simply
  138. return the number of groups for memory allocation purposes. The
  139. \&\fBgroups\fR array is in the form of a set of group NIDs in preference
  140. order. It can return zero if the client did not send a supported groups
  141. extension. If a supported group NID is unknown then the value is set to the
  142. bitwise OR of TLSEXT_nid_unknown (0x1000000) and the id of the group.
  143. .PP
  144. \&\fBSSL_get0_iana_groups()\fR retrieves the list of groups sent by the
  145. client in the supported_groups extension. The \fB*out\fR array of bytes
  146. is populated with the host-byte-order representation of the uint16_t group
  147. identifiers, as assigned by IANA. The group list is returned in the same order
  148. that was received in the ClientHello. The return value is the number of groups,
  149. not the number of bytes written.
  150. .PP
  151. \&\fBSSL_get_shared_group()\fR returns the NID of the shared group \fBn\fR for a
  152. server-side SSL \fBssl\fR. If \fBn\fR is \-1 then the total number of shared groups is
  153. returned, which may be zero. Other than for diagnostic purposes,
  154. most applications will only be interested in the first shared group
  155. so \fBn\fR is normally set to zero. If the value \fBn\fR is out of range,
  156. NID_undef is returned. If the NID for the shared group is unknown then the value
  157. is set to the bitwise OR of TLSEXT_nid_unknown (0x1000000) and the id of the
  158. group.
  159. .PP
  160. \&\fBSSL_get_negotiated_group()\fR returns the NID of the negotiated group used for
  161. the handshake key exchange process. For TLSv1.3 connections this typically
  162. reflects the state of the current connection, though in the case of PSK-only
  163. resumption, the returned value will be from a previous connection. For earlier
  164. TLS versions, when a session has been resumed, it always reflects the group
  165. used for key exchange during the initial handshake (otherwise it is from the
  166. current, non-resumption, connection). This can be called by either client or
  167. server. If the NID for the shared group is unknown then the value is set to the
  168. bitwise OR of TLSEXT_nid_unknown (0x1000000) and the id of the group.
  169. .PP
  170. All these functions are implemented as macros.
  171. .PP
  172. The curve functions are synonyms for the equivalently named group functions and
  173. are identical in every respect. They exist because, prior to TLS1.3, there was
  174. only the concept of supported curves. In TLS1.3 this was renamed to supported
  175. groups, and extended to include Diffie Hellman groups. The group functions
  176. should be used in preference.
  177. .SH NOTES
  178. .IX Header "NOTES"
  179. If an application wishes to make use of several of these functions for
  180. configuration purposes either on a command line or in a file it should
  181. consider using the SSL_CONF interface instead of manually parsing options.
  182. .SH "RETURN VALUES"
  183. .IX Header "RETURN VALUES"
  184. \&\fBSSL_CTX_set1_groups()\fR, \fBSSL_CTX_set1_groups_list()\fR, \fBSSL_set1_groups()\fR and
  185. \&\fBSSL_set1_groups_list()\fR, return 1 for success and 0 for failure.
  186. .PP
  187. \&\fBSSL_get1_groups()\fR returns the number of groups, which may be zero.
  188. .PP
  189. \&\fBSSL_get0_iana_groups()\fR returns the number of (uint16_t) groups, which may be zero.
  190. .PP
  191. \&\fBSSL_get_shared_group()\fR returns the NID of shared group \fBn\fR or NID_undef if there
  192. is no shared group \fBn\fR; or the total number of shared groups if \fBn\fR
  193. is \-1.
  194. .PP
  195. When called on a client \fBssl\fR, \fBSSL_get_shared_group()\fR has no meaning and
  196. returns \-1.
  197. .PP
  198. \&\fBSSL_get_negotiated_group()\fR returns the NID of the negotiated group used for
  199. key exchange, or NID_undef if there was no negotiated group.
  200. .SH "SEE ALSO"
  201. .IX Header "SEE ALSO"
  202. \&\fBssl\fR\|(7),
  203. \&\fBSSL_CTX_add_extra_chain_cert\fR\|(3)
  204. .SH HISTORY
  205. .IX Header "HISTORY"
  206. The curve functions were added in OpenSSL 1.0.2. The equivalent group
  207. functions were added in OpenSSL 1.1.1. The \fBSSL_get_negotiated_group()\fR function
  208. was added in OpenSSL 3.0.0.
  209. .PP
  210. Support for ignoring unknown groups in \fBSSL_CTX_set1_groups_list()\fR and
  211. \&\fBSSL_set1_groups_list()\fR was added in OpenSSL 3.3.
  212. .PP
  213. Earlier versions of this document described the list as a preference order.
  214. However, OpenSSL's behavior as a TLS 1.3 server is to consider \fIall\fR
  215. supported groups as comparable in security.
  216. .SH COPYRIGHT
  217. .IX Header "COPYRIGHT"
  218. Copyright 2013\-2024 The OpenSSL Project Authors. All Rights Reserved.
  219. .PP
  220. Licensed under the Apache License 2.0 (the "License"). You may not use
  221. this file except in compliance with the License. You can obtain a copy
  222. in the file LICENSE in the source distribution or at
  223. <https://www.openssl.org/source/license.html>.