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