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