SSL_CTX_set_security_level.pod 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. =pod
  2. =head1 NAME
  3. SSL_CTX_set_security_level, SSL_set_security_level, SSL_CTX_get_security_level, SSL_get_security_level, SSL_CTX_set_security_callback, SSL_set_security_callback, SSL_CTX_get_security_callback, SSL_get_security_callback, SSL_CTX_set0_security_ex_data, SSL_set0_security_ex_data, SSL_CTX_get0_security_ex_data, SSL_get0_security_ex_data - SSL/TLS security framework
  4. =head1 SYNOPSIS
  5. #include <openssl/ssl.h>
  6. void SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
  7. void SSL_set_security_level(SSL *s, int level);
  8. int SSL_CTX_get_security_level(const SSL_CTX *ctx);
  9. int SSL_get_security_level(const SSL *s);
  10. void SSL_CTX_set_security_callback(SSL_CTX *ctx,
  11. int (*cb)(SSL *s, SSL_CTX *ctx, int op,
  12. int bits, int nid,
  13. void *other, void *ex));
  14. void SSL_set_security_callback(SSL *s, int (*cb)(SSL *s, SSL_CTX *ctx, int op,
  15. int bits, int nid,
  16. void *other, void *ex));
  17. int (*SSL_CTX_get_security_callback(const SSL_CTX *ctx))(SSL *s, SSL_CTX *ctx, int op,
  18. int bits, int nid, void *other,
  19. void *ex);
  20. int (*SSL_get_security_callback(const SSL *s))(SSL *s, SSL_CTX *ctx, int op,
  21. int bits, int nid, void *other,
  22. void *ex);
  23. void SSL_CTX_set0_security_ex_data(SSL_CTX *ctx, void *ex);
  24. void SSL_set0_security_ex_data(SSL *s, void *ex);
  25. void *SSL_CTX_get0_security_ex_data(const SSL_CTX *ctx);
  26. void *SSL_get0_security_ex_data(const SSL *s);
  27. =head1 DESCRIPTION
  28. The functions SSL_CTX_set_security_level() and SSL_set_security_level() set
  29. the security level to B<level>. If not set the library default security level
  30. is used.
  31. The functions SSL_CTX_get_security_level() and SSL_get_security_level()
  32. retrieve the current security level.
  33. SSL_CTX_set_security_callback(), SSL_set_security_callback(),
  34. SSL_CTX_get_security_callback() and SSL_get_security_callback() get or set
  35. the security callback associated with B<ctx> or B<s>. If not set a default
  36. security callback is used. The meaning of the parameters and the behaviour
  37. of the default callbacks is described below.
  38. SSL_CTX_set0_security_ex_data(), SSL_set0_security_ex_data(),
  39. SSL_CTX_get0_security_ex_data() and SSL_get0_security_ex_data() set the
  40. extra data pointer passed to the B<ex> parameter of the callback. This
  41. value is passed to the callback verbatim and can be set to any convenient
  42. application specific value.
  43. =head1 DEFAULT CALLBACK BEHAVIOUR
  44. If an application doesn't set its own security callback the default
  45. callback is used. It is intended to provide sane defaults. The meaning
  46. of each level is described below.
  47. =over 4
  48. =item B<Level 0>
  49. Everything is permitted. This retains compatibility with previous versions of
  50. OpenSSL.
  51. =item B<Level 1>
  52. The security level corresponds to a minimum of 80 bits of security. Any
  53. parameters offering below 80 bits of security are excluded. As a result RSA,
  54. DSA and DH keys shorter than 1024 bits and ECC keys shorter than 160 bits
  55. are prohibited. All export cipher suites are prohibited since they all offer
  56. less than 80 bits of security. SSL version 2 is prohibited. Any cipher suite
  57. using MD5 for the MAC is also prohibited.
  58. =item B<Level 2>
  59. Security level set to 112 bits of security. As a result RSA, DSA and DH keys
  60. shorter than 2048 bits and ECC keys shorter than 224 bits are prohibited.
  61. In addition to the level 1 exclusions any cipher suite using RC4 is also
  62. prohibited. SSL version 3 is also not allowed. Compression is disabled.
  63. =item B<Level 3>
  64. Security level set to 128 bits of security. As a result RSA, DSA and DH keys
  65. shorter than 3072 bits and ECC keys shorter than 256 bits are prohibited.
  66. In addition to the level 2 exclusions cipher suites not offering forward
  67. secrecy are prohibited. TLS versions below 1.1 are not permitted. Session
  68. tickets are disabled.
  69. =item B<Level 4>
  70. Security level set to 192 bits of security. As a result RSA, DSA and
  71. DH keys shorter than 7680 bits and ECC keys shorter than 384 bits are
  72. prohibited. Cipher suites using SHA1 for the MAC are prohibited. TLS
  73. versions below 1.2 are not permitted.
  74. =item B<Level 5>
  75. Security level set to 256 bits of security. As a result RSA, DSA and DH keys
  76. shorter than 15360 bits and ECC keys shorter than 512 bits are prohibited.
  77. =back
  78. =head1 APPLICATION DEFINED SECURITY CALLBACKS
  79. I<Documentation to be provided.>
  80. =head1 NOTES
  81. B<WARNING> at this time setting the security level higher than 1 for
  82. general internet use is likely to cause B<considerable> interoperability
  83. issues and is not recommended. This is because the B<SHA1> algorithm
  84. is very widely used in certificates and will be rejected at levels
  85. higher than 1 because it only offers 80 bits of security.
  86. The default security level can be configured when OpenSSL is compiled by
  87. setting B<-DOPENSSL_TLS_SECURITY_LEVEL=level>. If not set then 1 is used.
  88. The security framework disables or reject parameters inconsistent with the
  89. set security level. In the past this was difficult as applications had to set
  90. a number of distinct parameters (supported ciphers, supported curves supported
  91. signature algorithms) to achieve this end and some cases (DH parameter size
  92. for example) could not be checked at all.
  93. By setting an appropriate security level much of this complexity can be
  94. avoided.
  95. The bits of security limits affect all relevant parameters including
  96. cipher suite encryption algorithms, supported ECC curves, supported
  97. signature algorithms, DH parameter sizes, certificate key sizes and
  98. signature algorithms. This limit applies no matter what other custom
  99. settings an application has set: so if the cipher suite is set to B<ALL>
  100. then only cipher suites consistent with the security level are permissible.
  101. See SP800-57 for how the security limits are related to individual
  102. algorithms.
  103. Some security levels require large key sizes for non-ECC public key
  104. algorithms which can severely degrade performance. For example 256 bits
  105. of security requires the use of RSA keys of at least 15360 bits in size.
  106. Some restrictions can be gracefully handled: for example cipher suites
  107. offering insufficient security are not sent by the client and will not
  108. be selected by the server. Other restrictions such as the peer certificate
  109. key size or the DH parameter size will abort the handshake with a fatal
  110. alert.
  111. Attempts to set certificates or parameters with insufficient security are
  112. also blocked. For example trying to set a certificate using a 512 bit RSA
  113. key using SSL_CTX_use_certificate() at level 1. Applications which do not
  114. check the return values for errors will misbehave: for example it might
  115. appear that a certificate is not set at all because it had been rejected.
  116. =head1 RETURN VALUES
  117. SSL_CTX_set_security_level() and SSL_set_security_level() do not return values.
  118. SSL_CTX_get_security_level() and SSL_get_security_level() return a integer that
  119. represents the security level with B<SSL_CTX> or B<SSL>, respectively.
  120. SSL_CTX_set_security_callback() and SSL_set_security_callback() do not return
  121. values.
  122. SSL_CTX_get_security_callback() and SSL_get_security_callback() return the pointer
  123. to the security callback or NULL if the callback is not set.
  124. SSL_CTX_get0_security_ex_data() and SSL_get0_security_ex_data() return the extra
  125. data pointer or NULL if the ex data is not set.
  126. =head1 SEE ALSO
  127. L<ssl(7)>
  128. =head1 HISTORY
  129. These functions were added in OpenSSL 1.1.0.
  130. =head1 COPYRIGHT
  131. Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.
  132. Licensed under the Apache License 2.0 (the "License"). You may not use
  133. this file except in compliance with the License. You can obtain a copy
  134. in the file LICENSE in the source distribution or at
  135. L<https://www.openssl.org/source/license.html>.
  136. =cut