SSL_CIPHER_get_name.pod 7.7 KB

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