SSL_CIPHER_get_name.3ossl 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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_CIPHER_GET_NAME 3ossl"
  58. .TH SSL_CIPHER_GET_NAME 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_CIPHER_get_name,
  65. SSL_CIPHER_standard_name,
  66. OPENSSL_cipher_name,
  67. SSL_CIPHER_get_bits,
  68. SSL_CIPHER_get_version,
  69. SSL_CIPHER_description,
  70. SSL_CIPHER_get_cipher_nid,
  71. SSL_CIPHER_get_digest_nid,
  72. SSL_CIPHER_get_handshake_digest,
  73. SSL_CIPHER_get_kx_nid,
  74. SSL_CIPHER_get_auth_nid,
  75. SSL_CIPHER_is_aead,
  76. SSL_CIPHER_find,
  77. SSL_CIPHER_get_id,
  78. SSL_CIPHER_get_protocol_id
  79. \&\- get SSL_CIPHER properties
  80. .SH SYNOPSIS
  81. .IX Header "SYNOPSIS"
  82. .Vb 1
  83. \& #include <openssl/ssl.h>
  84. \&
  85. \& const char *SSL_CIPHER_get_name(const SSL_CIPHER *cipher);
  86. \& const char *SSL_CIPHER_standard_name(const SSL_CIPHER *cipher);
  87. \& const char *OPENSSL_cipher_name(const char *stdname);
  88. \& int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, int *alg_bits);
  89. \& const char *SSL_CIPHER_get_version(const SSL_CIPHER *cipher);
  90. \& char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int size);
  91. \& int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c);
  92. \& int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c);
  93. \& const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c);
  94. \& int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c);
  95. \& int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c);
  96. \& int SSL_CIPHER_is_aead(const SSL_CIPHER *c);
  97. \& const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr);
  98. \& uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *c);
  99. \& uint32_t SSL_CIPHER_get_protocol_id(const SSL_CIPHER *c);
  100. .Ve
  101. .SH DESCRIPTION
  102. .IX Header "DESCRIPTION"
  103. \&\fBSSL_CIPHER_get_name()\fR returns a pointer to the name of \fBcipher\fR. If the
  104. \&\fBcipher\fR is NULL, it returns "(NONE)".
  105. .PP
  106. \&\fBSSL_CIPHER_standard_name()\fR returns a pointer to the standard RFC name of
  107. \&\fBcipher\fR. If the \fBcipher\fR is NULL, it returns "(NONE)". If the \fBcipher\fR
  108. has no standard name, it returns \fBNULL\fR. If \fBcipher\fR was defined in both
  109. SSLv3 and TLS, it returns the TLS name.
  110. .PP
  111. \&\fBOPENSSL_cipher_name()\fR returns a pointer to the OpenSSL name of \fBstdname\fR.
  112. If the \fBstdname\fR is NULL, or \fBstdname\fR has no corresponding OpenSSL name,
  113. it returns "(NONE)". Where both exist, \fBstdname\fR should be the TLS name rather
  114. than the SSLv3 name.
  115. .PP
  116. \&\fBSSL_CIPHER_get_bits()\fR returns the number of secret bits used for \fBcipher\fR.
  117. If \fBcipher\fR is NULL, 0 is returned.
  118. .PP
  119. \&\fBSSL_CIPHER_get_version()\fR returns string which indicates the SSL/TLS protocol
  120. version that first defined the cipher. It returns "(NONE)" if \fBcipher\fR is NULL.
  121. .PP
  122. \&\fBSSL_CIPHER_get_cipher_nid()\fR returns the cipher NID corresponding to \fBc\fR.
  123. If there is no cipher (e.g. for cipher suites with no encryption) then
  124. \&\fBNID_undef\fR is returned.
  125. .PP
  126. \&\fBSSL_CIPHER_get_digest_nid()\fR returns the digest NID corresponding to the MAC
  127. used by \fBc\fR during record encryption/decryption. If there is no digest (e.g.
  128. for AEAD cipher suites) then \fBNID_undef\fR is returned.
  129. .PP
  130. \&\fBSSL_CIPHER_get_handshake_digest()\fR returns an EVP_MD for the digest used during
  131. the SSL/TLS handshake when using the SSL_CIPHER \fBc\fR. Note that this may be
  132. different to the digest used to calculate the MAC for encrypted records.
  133. .PP
  134. \&\fBSSL_CIPHER_get_kx_nid()\fR returns the key exchange NID corresponding to the method
  135. used by \fBc\fR. If there is no key exchange, then \fBNID_undef\fR is returned.
  136. If any appropriate key exchange algorithm can be used (as in the case of TLS 1.3
  137. cipher suites) \fBNID_kx_any\fR is returned. Examples (not comprehensive):
  138. .PP
  139. .Vb 4
  140. \& NID_kx_rsa
  141. \& NID_kx_ecdhe
  142. \& NID_kx_dhe
  143. \& NID_kx_psk
  144. .Ve
  145. .PP
  146. \&\fBSSL_CIPHER_get_auth_nid()\fR returns the authentication NID corresponding to the method
  147. used by \fBc\fR. If there is no authentication, then \fBNID_undef\fR is returned.
  148. If any appropriate authentication algorithm can be used (as in the case of
  149. TLS 1.3 cipher suites) \fBNID_auth_any\fR is returned. Examples (not comprehensive):
  150. .PP
  151. .Vb 3
  152. \& NID_auth_rsa
  153. \& NID_auth_ecdsa
  154. \& NID_auth_psk
  155. .Ve
  156. .PP
  157. \&\fBSSL_CIPHER_is_aead()\fR returns 1 if the cipher \fBc\fR is AEAD (e.g. GCM or
  158. ChaCha20/Poly1305), and 0 if it is not AEAD.
  159. .PP
  160. \&\fBSSL_CIPHER_find()\fR returns a \fBSSL_CIPHER\fR structure which has the cipher ID stored
  161. in \fBptr\fR. The \fBptr\fR parameter is a two element array of \fBchar\fR, which stores the
  162. two-byte TLS cipher ID (as allocated by IANA) in network byte order. This parameter
  163. is usually retrieved from a TLS packet by using functions like
  164. \&\fBSSL_client_hello_get0_ciphers\fR\|(3). \fBSSL_CIPHER_find()\fR returns NULL if an
  165. error occurs or the indicated cipher is not found.
  166. .PP
  167. \&\fBSSL_CIPHER_get_id()\fR returns the OpenSSL-specific ID of the given cipher \fBc\fR. That ID is
  168. not the same as the IANA-specific ID.
  169. .PP
  170. \&\fBSSL_CIPHER_get_protocol_id()\fR returns the two-byte ID used in the TLS protocol of the given
  171. cipher \fBc\fR.
  172. .PP
  173. \&\fBSSL_CIPHER_description()\fR returns a textual description of the cipher used
  174. into the buffer \fBbuf\fR of length \fBlen\fR provided. If \fBbuf\fR is provided, it
  175. must be at least 128 bytes. If \fBbuf\fR is NULL it will be allocated using
  176. \&\fBOPENSSL_malloc()\fR. If the provided buffer is too small, or the allocation fails,
  177. \&\fBNULL\fR is returned.
  178. .PP
  179. The string returned by \fBSSL_CIPHER_description()\fR consists of several fields
  180. separated by whitespace:
  181. .IP <ciphername> 4
  182. .IX Item "<ciphername>"
  183. Textual representation of the cipher name.
  184. .IP "<protocol version>" 4
  185. .IX Item "<protocol version>"
  186. The minimum protocol version that the ciphersuite supports, such as \fBTLSv1.2\fR.
  187. Note that this is not always the same as the protocol version in which the
  188. ciphersuite was first defined because some ciphersuites are backwards compatible
  189. with earlier protocol versions.
  190. .IP "Kx=<key exchange>" 4
  191. .IX Item "Kx=<key exchange>"
  192. Key exchange method such as \fBRSA\fR, \fBECDHE\fR, etc.
  193. .IP Au=<authentication> 4
  194. .IX Item "Au=<authentication>"
  195. Authentication method such as \fBRSA\fR, \fBNone\fR, etc.. None is the
  196. representation of anonymous ciphers.
  197. .IP "Enc=<symmetric encryption method>" 4
  198. .IX Item "Enc=<symmetric encryption method>"
  199. Encryption method, with number of secret bits, such as \fBAESGCM(128)\fR.
  200. .IP "Mac=<message authentication code>" 4
  201. .IX Item "Mac=<message authentication code>"
  202. Message digest, such as \fBSHA256\fR.
  203. .PP
  204. Some examples for the output of \fBSSL_CIPHER_description()\fR:
  205. .PP
  206. .Vb 2
  207. \& ECDHE\-RSA\-AES256\-GCM\-SHA256 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(256) Mac=AEAD
  208. \& RSA\-PSK\-AES256\-CBC\-SHA384 TLSv1.0 Kx=RSAPSK Au=RSA Enc=AES(256) Mac=SHA384
  209. .Ve
  210. .SH "RETURN VALUES"
  211. .IX Header "RETURN VALUES"
  212. \&\fBSSL_CIPHER_get_name()\fR, \fBSSL_CIPHER_standard_name()\fR, \fBOPENSSL_cipher_name()\fR,
  213. \&\fBSSL_CIPHER_get_version()\fR and \fBSSL_CIPHER_description()\fR return the corresponding
  214. value in a NUL-terminated string for a specific cipher or "(NONE)"
  215. if the cipher is not found.
  216. .PP
  217. \&\fBSSL_CIPHER_get_bits()\fR returns a positive integer representing the number of
  218. secret bits or 0 if an error occurred.
  219. .PP
  220. \&\fBSSL_CIPHER_get_cipher_nid()\fR, \fBSSL_CIPHER_get_digest_nid()\fR,
  221. \&\fBSSL_CIPHER_get_kx_nid()\fR and \fBSSL_CIPHER_get_auth_nid()\fR return the NID value or
  222. \&\fBNID_undef\fR if an error occurred.
  223. .PP
  224. \&\fBSSL_CIPHER_get_handshake_digest()\fR returns a valid \fBEVP_MD\fR structure or NULL
  225. if an error occurred.
  226. .PP
  227. \&\fBSSL_CIPHER_is_aead()\fR returns 1 if the cipher is AEAD or 0 otherwise.
  228. .PP
  229. \&\fBSSL_CIPHER_find()\fR returns a valid \fBSSL_CIPHER\fR structure or NULL if an error
  230. occurred.
  231. .PP
  232. \&\fBSSL_CIPHER_get_id()\fR returns a 4\-byte integer representing the OpenSSL-specific ID.
  233. .PP
  234. \&\fBSSL_CIPHER_get_protocol_id()\fR returns a 2\-byte integer representing the TLS
  235. protocol-specific ID.
  236. .SH "SEE ALSO"
  237. .IX Header "SEE ALSO"
  238. \&\fBssl\fR\|(7), \fBSSL_get_current_cipher\fR\|(3),
  239. \&\fBSSL_get_ciphers\fR\|(3), \fBopenssl\-ciphers\fR\|(1)
  240. .SH HISTORY
  241. .IX Header "HISTORY"
  242. The \fBSSL_CIPHER_get_version()\fR function was updated to always return the
  243. correct protocol string in OpenSSL 1.1.0.
  244. .PP
  245. The \fBSSL_CIPHER_description()\fR function was changed to return \fBNULL\fR on error,
  246. rather than a fixed string, in OpenSSL 1.1.0.
  247. .PP
  248. The \fBSSL_CIPHER_get_handshake_digest()\fR function was added in OpenSSL 1.1.1.
  249. .PP
  250. The \fBSSL_CIPHER_standard_name()\fR function was globally available in OpenSSL 1.1.1.
  251. Before OpenSSL 1.1.1, tracing (\fBenable-ssl-trace\fR argument to Configure) was
  252. required to enable this function.
  253. .PP
  254. The \fBOPENSSL_cipher_name()\fR function was added in OpenSSL 1.1.1.
  255. .SH COPYRIGHT
  256. .IX Header "COPYRIGHT"
  257. Copyright 2000\-2024 The OpenSSL Project Authors. All Rights Reserved.
  258. .PP
  259. Licensed under the Apache License 2.0 (the "License"). You may not use
  260. this file except in compliance with the License. You can obtain a copy
  261. in the file LICENSE in the source distribution or at
  262. <https://www.openssl.org/source/license.html>.