89f53d685dbb380f4e1438012f7e4c99ee3cfb6e
[openssl.git] / doc / man3 / SSL_CIPHER_get_name.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_CIPHER_get_name,
6 SSL_CIPHER_standard_name,
7 OPENSSL_cipher_name,
8 SSL_CIPHER_get_bits,
9 SSL_CIPHER_get_version,
10 SSL_CIPHER_description,
11 SSL_CIPHER_get_cipher_nid,
12 SSL_CIPHER_get_digest_nid,
13 SSL_CIPHER_get_handshake_digest,
14 SSL_CIPHER_get_kx_nid,
15 SSL_CIPHER_get_auth_nid,
16 SSL_CIPHER_is_aead
17 - get SSL_CIPHER properties
18
19 =head1 SYNOPSIS
20
21  #include <openssl/ssl.h>
22
23  const char *SSL_CIPHER_get_name(const SSL_CIPHER *cipher);
24  const char *SSL_CIPHER_standard_name(const SSL_CIPHER *cipher);
25  const char *OPENSSL_cipher_name(const char *stdname);
26  int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, int *alg_bits);
27  char *SSL_CIPHER_get_version(const SSL_CIPHER *cipher);
28  char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int size);
29  int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c);
30  int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c);
31  const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c);
32  int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c);
33  int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c);
34  int SSL_CIPHER_is_aead(const SSL_CIPHER *c);
35
36 =head1 DESCRIPTION
37
38 SSL_CIPHER_get_name() returns a pointer to the name of B<cipher>. If the
39 B<cipher> is NULL, it returns "(NONE)".
40
41 SSL_CIPHER_standard_name() returns a pointer to the standard RFC name of
42 B<cipher>. If the B<cipher> is NULL, it returns "(NONE)". If the B<cipher>
43 has no standard name, it returns B<NULL>. If B<cipher> was defined in both
44 SSLv3 and TLS, it returns the TLS name.
45
46 OPENSSL_cipher_name() returns a pointer to the OpenSSL name of B<stdname>.
47 If the B<stdname> is NULL, or B<stdname> has no corresponding OpenSSL name,
48 it returns "(NONE)". Where both exist, B<stdname> should be the TLS name rather
49 than the SSLv3 name.
50
51 SSL_CIPHER_get_bits() returns the number of secret bits used for B<cipher>.
52 If B<cipher> is NULL, 0 is returned.
53
54 SSL_CIPHER_get_version() returns string which indicates the SSL/TLS protocol
55 version that first defined the cipher.  It returns "(NONE)" if B<cipher> is NULL.
56
57 SSL_CIPHER_get_cipher_nid() returns the cipher NID corresponding to B<c>.
58 If there is no cipher (e.g. for cipher suites with no encryption) then
59 B<NID_undef> is returned.
60
61 SSL_CIPHER_get_digest_nid() returns the digest NID corresponding to the MAC
62 used by B<c> during record encryption/decryption. If there is no digest (e.g.
63 for AEAD cipher suites) then B<NID_undef> is returned.
64
65 SSL_CIPHER_get_handshake_digest() returns an EVP_MD for the digest used during
66 the SSL/TLS handshake when using the SSL_CIPHER B<c>. Note that this may be
67 different to the digest used to calculate the MAC for encrypted records.
68
69 SSL_CIPHER_get_kx_nid() returns the key exchange NID corresponding to the method
70 used by B<c>. If there is no key exchange, then B<NID_undef> is returned.
71 If any appropriate key exchange algorithm can be used (as in the case of TLS 1.3
72 cipher suites) B<NID_kx_any> is returned. Examples (not comprehensive):
73
74  NID_kx_rsa
75  NID_kx_ecdhe
76  NID_kx_dhe
77  NID_kx_psk
78
79 SSL_CIPHER_get_auth_nid() returns the authentication NID corresponding to the method
80 used by B<c>. If there is no authentication, then B<NID_undef> is returned.
81 If any appropriate authentication algorithm can be used (as in the case of
82 TLS 1.3 cipher suites) B<NID_auth_any> is returned. 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 B<c> is AEAD (e.g. GCM or
89 ChaCha20/Poly1305), and 0 if it is not AEAD.
90
91 SSL_CIPHER_description() returns a textual description of the cipher used
92 into the buffer B<buf> of length B<len> provided.  If B<buf> is provided, it
93 must be at least 128 bytes, otherwise a buffer will be allocated using
94 OPENSSL_malloc().  If the provided buffer is too small, or the allocation fails,
95 B<NULL> is returned.
96
97 The string returned by SSL_CIPHER_description() consists of several fields
98 separated by whitespace:
99
100 =over 4
101
102 =item <ciphername>
103
104 Textual representation of the cipher name.
105
106 =item <protocol version>
107
108 Protocol version, such as B<TLSv1.2>, when the cipher was first defined.
109
110 =item Kx=<key exchange>
111
112 Key exchange method such as B<RSA>, B<ECDHE>, etc.
113
114 =item Au=<authentication>
115
116 Authentication method such as B<RSA>, B<None>, etc.. None is the
117 representation of anonymous ciphers.
118
119 =item Enc=<symmetric encryption method>
120
121 Encryption method, with number of secret bits, such as B<AESGCM(128)>.
122
123 =item Mac=<message authentication code>
124
125 Message digest, such as B<SHA256>.
126
127 =back
128
129 Some examples for the output of SSL_CIPHER_description():
130
131  ECDHE-RSA-AES256-GCM-SHA256 TLSv1.2 Kx=ECDH     Au=RSA  Enc=AESGCM(256) Mac=AEAD
132  RSA-PSK-AES256-CBC-SHA384 TLSv1.0 Kx=RSAPSK   Au=RSA  Enc=AES(256)  Mac=SHA384
133
134 =head1 HISTORY
135
136 SSL_CIPHER_get_version() was updated to always return the correct protocol
137 string in OpenSSL 1.1.0.
138
139 SSL_CIPHER_description() was changed to return B<NULL> on error,
140 rather than a fixed string, in OpenSSL 1.1.0.
141
142 SSL_CIPHER_get_handshake_digest() was added in OpenSSL 1.1.1.
143
144 SSL_CIPHER_standard_name() was globally available in OpenSSL 1.1.1. Before
145 OpenSSL 1.1.1, tracing (B<enable-ssl-trace> argument to Configure) was
146 required to enable this function.
147
148 OPENSSL_cipher_name() was added in OpenSSL 1.1.1.
149
150 =head1 SEE ALSO
151
152 L<ssl(7)>, L<SSL_get_current_cipher(3)>,
153 L<SSL_get_ciphers(3)>, L<ciphers(1)>
154
155 =head1 COPYRIGHT
156
157 Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
158
159 Licensed under the OpenSSL license (the "License").  You may not use
160 this file except in compliance with the License.  You can obtain a copy
161 in the file LICENSE in the source distribution or at
162 L<https://www.openssl.org/source/license.html>.
163
164 =cut