1SSL_CIPHER_GET_NAME(3) OpenSSL SSL_CIPHER_GET_NAME(3)
2
3
4
6 SSL_CIPHER_get_name, SSL_CIPHER_standard_name, OPENSSL_cipher_name,
7 SSL_CIPHER_get_bits, SSL_CIPHER_get_version, SSL_CIPHER_description,
8 SSL_CIPHER_get_cipher_nid, SSL_CIPHER_get_digest_nid,
9 SSL_CIPHER_get_handshake_digest, SSL_CIPHER_get_kx_nid,
10 SSL_CIPHER_get_auth_nid, SSL_CIPHER_is_aead, SSL_CIPHER_find,
11 SSL_CIPHER_get_id, SSL_CIPHER_get_protocol_id - get SSL_CIPHER
12 properties
13
15 #include <openssl/ssl.h>
16
17 const char *SSL_CIPHER_get_name(const SSL_CIPHER *cipher);
18 const char *SSL_CIPHER_standard_name(const SSL_CIPHER *cipher);
19 const char *OPENSSL_cipher_name(const char *stdname);
20 int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, int *alg_bits);
21 char *SSL_CIPHER_get_version(const SSL_CIPHER *cipher);
22 char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int size);
23 int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c);
24 int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c);
25 const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c);
26 int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c);
27 int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c);
28 int SSL_CIPHER_is_aead(const SSL_CIPHER *c);
29 const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr);
30 uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *c);
31 uint32_t SSL_CIPHER_get_protocol_id(const SSL_CIPHER *c);
32
34 SSL_CIPHER_get_name() returns a pointer to the name of cipher. If the
35 cipher is NULL, it returns "(NONE)".
36
37 SSL_CIPHER_standard_name() returns a pointer to the standard RFC name
38 of cipher. If the cipher is NULL, it returns "(NONE)". If the cipher
39 has no standard name, it returns NULL. If cipher was defined in both
40 SSLv3 and TLS, it returns the TLS name.
41
42 OPENSSL_cipher_name() returns a pointer to the OpenSSL name of stdname.
43 If the stdname is NULL, or stdname has no corresponding OpenSSL name,
44 it returns "(NONE)". Where both exist, stdname should be the TLS name
45 rather than the SSLv3 name.
46
47 SSL_CIPHER_get_bits() returns the number of secret bits used for
48 cipher. If cipher is NULL, 0 is returned.
49
50 SSL_CIPHER_get_version() returns string which indicates the SSL/TLS
51 protocol version that first defined the cipher. It returns "(NONE)" if
52 cipher is NULL.
53
54 SSL_CIPHER_get_cipher_nid() returns the cipher NID corresponding to c.
55 If there is no cipher (e.g. for cipher suites with no encryption) then
56 NID_undef is returned.
57
58 SSL_CIPHER_get_digest_nid() returns the digest NID corresponding to the
59 MAC used by c during record encryption/decryption. If there is no
60 digest (e.g. for AEAD cipher suites) then NID_undef is returned.
61
62 SSL_CIPHER_get_handshake_digest() returns an EVP_MD for the digest used
63 during the SSL/TLS handshake when using the SSL_CIPHER c. Note that
64 this may be different to the digest used to calculate the MAC for
65 encrypted records.
66
67 SSL_CIPHER_get_kx_nid() returns the key exchange NID corresponding to
68 the method used by c. If there is no key exchange, then NID_undef is
69 returned. If any appropriate key exchange algorithm can be used (as in
70 the case of TLS 1.3 cipher suites) NID_kx_any is returned. Examples
71 (not comprehensive):
72
73 NID_kx_rsa
74 NID_kx_ecdhe
75 NID_kx_dhe
76 NID_kx_psk
77
78 SSL_CIPHER_get_auth_nid() returns the authentication NID corresponding
79 to the method used by c. If there is no authentication, then NID_undef
80 is returned. If any appropriate authentication algorithm can be used
81 (as in the case of TLS 1.3 cipher suites) NID_auth_any is returned.
82 Examples (not comprehensive):
83
84 NID_auth_rsa
85 NID_auth_ecdsa
86 NID_auth_psk
87
88 SSL_CIPHER_is_aead() returns 1 if the cipher c is AEAD (e.g. GCM or
89 ChaCha20/Poly1305), and 0 if it is not AEAD.
90
91 SSL_CIPHER_find() returns a SSL_CIPHER structure which has the cipher
92 ID stored in ptr. The ptr parameter is a two element array of char,
93 which stores the two-byte TLS cipher ID (as allocated by IANA) in
94 network byte order. This parameter is usually retrieved from a TLS
95 packet by using functions like SSL_client_hello_get0_ciphers(3).
96 SSL_CIPHER_find() returns NULL if an error occurs or the indicated
97 cipher is not found.
98
99 SSL_CIPHER_get_id() returns the OpenSSL-specific ID of the given cipher
100 c. That ID is not the same as the IANA-specific ID.
101
102 SSL_CIPHER_get_protocol_id() returns the two-byte ID used in the TLS
103 protocol of the given cipher c.
104
105 SSL_CIPHER_description() returns a textual description of the cipher
106 used into the buffer buf of length len provided. If buf is provided,
107 it must be at least 128 bytes, otherwise a buffer will be allocated
108 using OPENSSL_malloc(). If the provided buffer is too small, or the
109 allocation fails, NULL is returned.
110
111 The string returned by SSL_CIPHER_description() consists of several
112 fields separated by whitespace:
113
114 <ciphername>
115 Textual representation of the cipher name.
116
117 <protocol version>
118 The minimum protocol version that the ciphersuite supports, such as
119 TLSv1.2. Note that this is not always the same as the protocol
120 version in which the ciphersuite was first defined because some
121 ciphersuites are backwards compatible with earlier protocol
122 versions.
123
124 Kx=<key exchange>
125 Key exchange method such as RSA, ECDHE, etc.
126
127 Au=<authentication>
128 Authentication method such as RSA, None, etc.. None is the
129 representation of anonymous ciphers.
130
131 Enc=<symmetric encryption method>
132 Encryption method, with number of secret bits, such as AESGCM(128).
133
134 Mac=<message authentication code>
135 Message digest, such as SHA256.
136
137 Some examples for the output of SSL_CIPHER_description():
138
139 ECDHE-RSA-AES256-GCM-SHA256 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(256) Mac=AEAD
140 RSA-PSK-AES256-CBC-SHA384 TLSv1.0 Kx=RSAPSK Au=RSA Enc=AES(256) Mac=SHA384
141
143 SSL_CIPHER_get_name(), SSL_CIPHER_standard_name(),
144 OPENSSL_cipher_name(), SSL_CIPHER_get_version() and
145 SSL_CIPHER_description() return the corresponding value in a null-
146 terminated string for a specific cipher or "(NONE)" if the cipher is
147 not found.
148
149 SSL_CIPHER_get_bits() returns a positive integer representing the
150 number of secret bits or 0 if an error occurred.
151
152 SSL_CIPHER_get_cipher_nid(), SSL_CIPHER_get_digest_nid(),
153 SSL_CIPHER_get_kx_nid() and SSL_CIPHER_get_auth_nid() return the NID
154 value or NID_undef if an error occurred.
155
156 SSL_CIPHER_get_handshake_digest() returns a valid EVP_MD structure or
157 NULL if an error occurred.
158
159 SSL_CIPHER_is_aead() returns 1 if the cipher is AEAD or 0 otherwise.
160
161 SSL_CIPHER_find() returns a valid SSL_CIPHER structure or NULL if an
162 error occurred.
163
164 SSL_CIPHER_get_id() returns a 4-byte integer representing the OpenSSL-
165 specific ID.
166
167 SSL_CIPHER_get_protocol_id() returns a 2-byte integer representing the
168 TLS protocol-specific ID.
169
171 ssl(7), SSL_get_current_cipher(3), SSL_get_ciphers(3), ciphers(1)
172
174 The SSL_CIPHER_get_version() function was updated to always return the
175 correct protocol string in OpenSSL 1.1.0.
176
177 The SSL_CIPHER_description() function was changed to return NULL on
178 error, rather than a fixed string, in OpenSSL 1.1.0.
179
180 The SSL_CIPHER_get_handshake_digest() function was added in OpenSSL
181 1.1.1.
182
183 The SSL_CIPHER_standard_name() function was globally available in
184 OpenSSL 1.1.1.
185 Before OpenSSL 1.1.1, tracing (enable-ssl-trace argument to Configure)
186 was required to enable this function.
187
188 The OPENSSL_cipher_name() function was added in OpenSSL 1.1.1.
189
191 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
192
193 Licensed under the OpenSSL license (the "License"). You may not use
194 this file except in compliance with the License. You can obtain a copy
195 in the file LICENSE in the source distribution or at
196 <https://www.openssl.org/source/license.html>.
197
198
199
2001.1.1i 2021-07-22 SSL_CIPHER_GET_NAME(3)