1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5e71b7053SJung-uk KimSSL_CIPHER_get_name, 6e71b7053SJung-uk KimSSL_CIPHER_standard_name, 7e71b7053SJung-uk KimOPENSSL_cipher_name, 8e71b7053SJung-uk KimSSL_CIPHER_get_bits, 9e71b7053SJung-uk KimSSL_CIPHER_get_version, 10e71b7053SJung-uk KimSSL_CIPHER_description, 11e71b7053SJung-uk KimSSL_CIPHER_get_cipher_nid, 12e71b7053SJung-uk KimSSL_CIPHER_get_digest_nid, 13e71b7053SJung-uk KimSSL_CIPHER_get_handshake_digest, 14e71b7053SJung-uk KimSSL_CIPHER_get_kx_nid, 15e71b7053SJung-uk KimSSL_CIPHER_get_auth_nid, 16e71b7053SJung-uk KimSSL_CIPHER_is_aead, 17e71b7053SJung-uk KimSSL_CIPHER_find, 18e71b7053SJung-uk KimSSL_CIPHER_get_id, 19e71b7053SJung-uk KimSSL_CIPHER_get_protocol_id 20e71b7053SJung-uk Kim- get SSL_CIPHER properties 21e71b7053SJung-uk Kim 22e71b7053SJung-uk Kim=head1 SYNOPSIS 23e71b7053SJung-uk Kim 24e71b7053SJung-uk Kim #include <openssl/ssl.h> 25e71b7053SJung-uk Kim 26e71b7053SJung-uk Kim const char *SSL_CIPHER_get_name(const SSL_CIPHER *cipher); 27e71b7053SJung-uk Kim const char *SSL_CIPHER_standard_name(const SSL_CIPHER *cipher); 28e71b7053SJung-uk Kim const char *OPENSSL_cipher_name(const char *stdname); 29e71b7053SJung-uk Kim int SSL_CIPHER_get_bits(const SSL_CIPHER *cipher, int *alg_bits); 30b077aed3SPierre Pronchery const char *SSL_CIPHER_get_version(const SSL_CIPHER *cipher); 31e71b7053SJung-uk Kim char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int size); 32e71b7053SJung-uk Kim int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c); 33e71b7053SJung-uk Kim int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c); 34e71b7053SJung-uk Kim const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c); 35e71b7053SJung-uk Kim int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c); 36e71b7053SJung-uk Kim int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c); 37e71b7053SJung-uk Kim int SSL_CIPHER_is_aead(const SSL_CIPHER *c); 38e71b7053SJung-uk Kim const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr); 39e71b7053SJung-uk Kim uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *c); 40e71b7053SJung-uk Kim uint32_t SSL_CIPHER_get_protocol_id(const SSL_CIPHER *c); 41e71b7053SJung-uk Kim 42e71b7053SJung-uk Kim=head1 DESCRIPTION 43e71b7053SJung-uk Kim 44e71b7053SJung-uk KimSSL_CIPHER_get_name() returns a pointer to the name of B<cipher>. If the 45e71b7053SJung-uk KimB<cipher> is NULL, it returns "(NONE)". 46e71b7053SJung-uk Kim 47e71b7053SJung-uk KimSSL_CIPHER_standard_name() returns a pointer to the standard RFC name of 48e71b7053SJung-uk KimB<cipher>. If the B<cipher> is NULL, it returns "(NONE)". If the B<cipher> 49e71b7053SJung-uk Kimhas no standard name, it returns B<NULL>. If B<cipher> was defined in both 50e71b7053SJung-uk KimSSLv3 and TLS, it returns the TLS name. 51e71b7053SJung-uk Kim 52e71b7053SJung-uk KimOPENSSL_cipher_name() returns a pointer to the OpenSSL name of B<stdname>. 53e71b7053SJung-uk KimIf the B<stdname> is NULL, or B<stdname> has no corresponding OpenSSL name, 54e71b7053SJung-uk Kimit returns "(NONE)". Where both exist, B<stdname> should be the TLS name rather 55e71b7053SJung-uk Kimthan the SSLv3 name. 56e71b7053SJung-uk Kim 57e71b7053SJung-uk KimSSL_CIPHER_get_bits() returns the number of secret bits used for B<cipher>. 58e71b7053SJung-uk KimIf B<cipher> is NULL, 0 is returned. 59e71b7053SJung-uk Kim 60e71b7053SJung-uk KimSSL_CIPHER_get_version() returns string which indicates the SSL/TLS protocol 61e71b7053SJung-uk Kimversion that first defined the cipher. It returns "(NONE)" if B<cipher> is NULL. 62e71b7053SJung-uk Kim 63e71b7053SJung-uk KimSSL_CIPHER_get_cipher_nid() returns the cipher NID corresponding to B<c>. 64e71b7053SJung-uk KimIf there is no cipher (e.g. for cipher suites with no encryption) then 65e71b7053SJung-uk KimB<NID_undef> is returned. 66e71b7053SJung-uk Kim 67e71b7053SJung-uk KimSSL_CIPHER_get_digest_nid() returns the digest NID corresponding to the MAC 68e71b7053SJung-uk Kimused by B<c> during record encryption/decryption. If there is no digest (e.g. 69e71b7053SJung-uk Kimfor AEAD cipher suites) then B<NID_undef> is returned. 70e71b7053SJung-uk Kim 71e71b7053SJung-uk KimSSL_CIPHER_get_handshake_digest() returns an EVP_MD for the digest used during 72e71b7053SJung-uk Kimthe SSL/TLS handshake when using the SSL_CIPHER B<c>. Note that this may be 73e71b7053SJung-uk Kimdifferent to the digest used to calculate the MAC for encrypted records. 74e71b7053SJung-uk Kim 75e71b7053SJung-uk KimSSL_CIPHER_get_kx_nid() returns the key exchange NID corresponding to the method 76e71b7053SJung-uk Kimused by B<c>. If there is no key exchange, then B<NID_undef> is returned. 77e71b7053SJung-uk KimIf any appropriate key exchange algorithm can be used (as in the case of TLS 1.3 78e71b7053SJung-uk Kimcipher suites) B<NID_kx_any> is returned. Examples (not comprehensive): 79e71b7053SJung-uk Kim 80e71b7053SJung-uk Kim NID_kx_rsa 81e71b7053SJung-uk Kim NID_kx_ecdhe 82e71b7053SJung-uk Kim NID_kx_dhe 83e71b7053SJung-uk Kim NID_kx_psk 84e71b7053SJung-uk Kim 85e71b7053SJung-uk KimSSL_CIPHER_get_auth_nid() returns the authentication NID corresponding to the method 86e71b7053SJung-uk Kimused by B<c>. If there is no authentication, then B<NID_undef> is returned. 87e71b7053SJung-uk KimIf any appropriate authentication algorithm can be used (as in the case of 88e71b7053SJung-uk KimTLS 1.3 cipher suites) B<NID_auth_any> is returned. Examples (not comprehensive): 89e71b7053SJung-uk Kim 90e71b7053SJung-uk Kim NID_auth_rsa 91e71b7053SJung-uk Kim NID_auth_ecdsa 92e71b7053SJung-uk Kim NID_auth_psk 93e71b7053SJung-uk Kim 94e71b7053SJung-uk KimSSL_CIPHER_is_aead() returns 1 if the cipher B<c> is AEAD (e.g. GCM or 95e71b7053SJung-uk KimChaCha20/Poly1305), and 0 if it is not AEAD. 96e71b7053SJung-uk Kim 97e71b7053SJung-uk KimSSL_CIPHER_find() returns a B<SSL_CIPHER> structure which has the cipher ID stored 98e71b7053SJung-uk Kimin B<ptr>. The B<ptr> parameter is a two element array of B<char>, which stores the 99e71b7053SJung-uk Kimtwo-byte TLS cipher ID (as allocated by IANA) in network byte order. This parameter 100e71b7053SJung-uk Kimis usually retrieved from a TLS packet by using functions like 101e71b7053SJung-uk KimL<SSL_client_hello_get0_ciphers(3)>. SSL_CIPHER_find() returns NULL if an 102e71b7053SJung-uk Kimerror occurs or the indicated cipher is not found. 103e71b7053SJung-uk Kim 104e71b7053SJung-uk KimSSL_CIPHER_get_id() returns the OpenSSL-specific ID of the given cipher B<c>. That ID is 105e71b7053SJung-uk Kimnot the same as the IANA-specific ID. 106e71b7053SJung-uk Kim 107e71b7053SJung-uk KimSSL_CIPHER_get_protocol_id() returns the two-byte ID used in the TLS protocol of the given 108e71b7053SJung-uk Kimcipher B<c>. 109e71b7053SJung-uk Kim 110e71b7053SJung-uk KimSSL_CIPHER_description() returns a textual description of the cipher used 111e71b7053SJung-uk Kiminto the buffer B<buf> of length B<len> provided. If B<buf> is provided, it 112*44096ebdSEnji Coopermust be at least 128 bytes. If B<buf> is NULL it will be allocated using 113e71b7053SJung-uk KimOPENSSL_malloc(). If the provided buffer is too small, or the allocation fails, 114e71b7053SJung-uk KimB<NULL> is returned. 115e71b7053SJung-uk Kim 116e71b7053SJung-uk KimThe string returned by SSL_CIPHER_description() consists of several fields 117e71b7053SJung-uk Kimseparated by whitespace: 118e71b7053SJung-uk Kim 119e71b7053SJung-uk Kim=over 4 120e71b7053SJung-uk Kim 121e71b7053SJung-uk Kim=item <ciphername> 122e71b7053SJung-uk Kim 123e71b7053SJung-uk KimTextual representation of the cipher name. 124e71b7053SJung-uk Kim 125e71b7053SJung-uk Kim=item <protocol version> 126e71b7053SJung-uk Kim 127610a21fdSJung-uk KimThe minimum protocol version that the ciphersuite supports, such as B<TLSv1.2>. 128610a21fdSJung-uk KimNote that this is not always the same as the protocol version in which the 129610a21fdSJung-uk Kimciphersuite was first defined because some ciphersuites are backwards compatible 130610a21fdSJung-uk Kimwith earlier protocol versions. 131e71b7053SJung-uk Kim 132e71b7053SJung-uk Kim=item Kx=<key exchange> 133e71b7053SJung-uk Kim 134e71b7053SJung-uk KimKey exchange method such as B<RSA>, B<ECDHE>, etc. 135e71b7053SJung-uk Kim 136e71b7053SJung-uk Kim=item Au=<authentication> 137e71b7053SJung-uk Kim 138e71b7053SJung-uk KimAuthentication method such as B<RSA>, B<None>, etc.. None is the 139e71b7053SJung-uk Kimrepresentation of anonymous ciphers. 140e71b7053SJung-uk Kim 141e71b7053SJung-uk Kim=item Enc=<symmetric encryption method> 142e71b7053SJung-uk Kim 143e71b7053SJung-uk KimEncryption method, with number of secret bits, such as B<AESGCM(128)>. 144e71b7053SJung-uk Kim 145e71b7053SJung-uk Kim=item Mac=<message authentication code> 146e71b7053SJung-uk Kim 147e71b7053SJung-uk KimMessage digest, such as B<SHA256>. 148e71b7053SJung-uk Kim 149e71b7053SJung-uk Kim=back 150e71b7053SJung-uk Kim 151e71b7053SJung-uk KimSome examples for the output of SSL_CIPHER_description(): 152e71b7053SJung-uk Kim 153e71b7053SJung-uk Kim ECDHE-RSA-AES256-GCM-SHA256 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(256) Mac=AEAD 154e71b7053SJung-uk Kim RSA-PSK-AES256-CBC-SHA384 TLSv1.0 Kx=RSAPSK Au=RSA Enc=AES(256) Mac=SHA384 155e71b7053SJung-uk Kim 156e71b7053SJung-uk Kim=head1 RETURN VALUES 157e71b7053SJung-uk Kim 158e71b7053SJung-uk KimSSL_CIPHER_get_name(), SSL_CIPHER_standard_name(), OPENSSL_cipher_name(), 159e71b7053SJung-uk KimSSL_CIPHER_get_version() and SSL_CIPHER_description() return the corresponding 160b077aed3SPierre Proncheryvalue in a NUL-terminated string for a specific cipher or "(NONE)" 161e71b7053SJung-uk Kimif the cipher is not found. 162e71b7053SJung-uk Kim 163e71b7053SJung-uk KimSSL_CIPHER_get_bits() returns a positive integer representing the number of 164e71b7053SJung-uk Kimsecret bits or 0 if an error occurred. 165e71b7053SJung-uk Kim 166e71b7053SJung-uk KimSSL_CIPHER_get_cipher_nid(), SSL_CIPHER_get_digest_nid(), 167e71b7053SJung-uk KimSSL_CIPHER_get_kx_nid() and SSL_CIPHER_get_auth_nid() return the NID value or 168e71b7053SJung-uk KimB<NID_undef> if an error occurred. 169e71b7053SJung-uk Kim 170e71b7053SJung-uk KimSSL_CIPHER_get_handshake_digest() returns a valid B<EVP_MD> structure or NULL 171e71b7053SJung-uk Kimif an error occurred. 172e71b7053SJung-uk Kim 173e71b7053SJung-uk KimSSL_CIPHER_is_aead() returns 1 if the cipher is AEAD or 0 otherwise. 174e71b7053SJung-uk Kim 175e71b7053SJung-uk KimSSL_CIPHER_find() returns a valid B<SSL_CIPHER> structure or NULL if an error 176e71b7053SJung-uk Kimoccurred. 177e71b7053SJung-uk Kim 178e71b7053SJung-uk KimSSL_CIPHER_get_id() returns a 4-byte integer representing the OpenSSL-specific ID. 179e71b7053SJung-uk Kim 180e71b7053SJung-uk KimSSL_CIPHER_get_protocol_id() returns a 2-byte integer representing the TLS 181e71b7053SJung-uk Kimprotocol-specific ID. 182e71b7053SJung-uk Kim 183610a21fdSJung-uk Kim=head1 SEE ALSO 184610a21fdSJung-uk Kim 185610a21fdSJung-uk KimL<ssl(7)>, L<SSL_get_current_cipher(3)>, 186b077aed3SPierre ProncheryL<SSL_get_ciphers(3)>, L<openssl-ciphers(1)> 187610a21fdSJung-uk Kim 188e71b7053SJung-uk Kim=head1 HISTORY 189e71b7053SJung-uk Kim 1906935a639SJung-uk KimThe SSL_CIPHER_get_version() function was updated to always return the 1916935a639SJung-uk Kimcorrect protocol string in OpenSSL 1.1.0. 192e71b7053SJung-uk Kim 1936935a639SJung-uk KimThe SSL_CIPHER_description() function was changed to return B<NULL> on error, 194e71b7053SJung-uk Kimrather than a fixed string, in OpenSSL 1.1.0. 195e71b7053SJung-uk Kim 1966935a639SJung-uk KimThe SSL_CIPHER_get_handshake_digest() function was added in OpenSSL 1.1.1. 197e71b7053SJung-uk Kim 1986935a639SJung-uk KimThe SSL_CIPHER_standard_name() function was globally available in OpenSSL 1.1.1. 1996935a639SJung-uk Kim Before OpenSSL 1.1.1, tracing (B<enable-ssl-trace> argument to Configure) was 200e71b7053SJung-uk Kimrequired to enable this function. 201e71b7053SJung-uk Kim 2026935a639SJung-uk KimThe OPENSSL_cipher_name() function was added in OpenSSL 1.1.1. 203e71b7053SJung-uk Kim 204e71b7053SJung-uk Kim=head1 COPYRIGHT 205e71b7053SJung-uk Kim 206*44096ebdSEnji CooperCopyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved. 207e71b7053SJung-uk Kim 208b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 209e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 210e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 211e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 212e71b7053SJung-uk Kim 213e71b7053SJung-uk Kim=cut 214