1SSL_CTX_SET_SECURITY_LEVEL(3ossl) OpenSSL SSL_CTX_SET_SECURITY_LEVEL(3ossl)
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. Note that signatures using SHA1 and MD5 are also
82 forbidden at this level as they have less than 80 security bits.
83 Additionally, SSLv3, TLS 1.0, TLS 1.1 and DTLS 1.0 are all disabled
84 at this level.
85
86 Level 2
87 Security level set to 112 bits of security. As a result RSA, DSA
88 and DH keys shorter than 2048 bits and ECC keys shorter than 224
89 bits are prohibited. In addition to the level 1 exclusions any
90 cipher suite using RC4 is also prohibited. Compression is disabled.
91
92 Level 3
93 Security level set to 128 bits of security. As a result RSA, DSA
94 and DH keys shorter than 3072 bits and ECC keys shorter than 256
95 bits are prohibited. In addition to the level 2 exclusions cipher
96 suites not offering forward secrecy are prohibited. Session tickets
97 are disabled.
98
99 Level 4
100 Security level set to 192 bits of security. As a result RSA, DSA
101 and DH keys shorter than 7680 bits and ECC keys shorter than 384
102 bits are prohibited. Cipher suites using SHA1 for the MAC are
103 prohibited.
104
105 Level 5
106 Security level set to 256 bits of security. As a result RSA, DSA
107 and DH keys shorter than 15360 bits and ECC keys shorter than 512
108 bits are prohibited.
109
111 Documentation to be provided.
112
114 The default security level can be configured when OpenSSL is compiled
115 by setting -DOPENSSL_TLS_SECURITY_LEVEL=level. If not set then 1 is
116 used.
117
118 The security framework disables or reject parameters inconsistent with
119 the set security level. In the past this was difficult as applications
120 had to set a number of distinct parameters (supported ciphers,
121 supported curves supported signature algorithms) to achieve this end
122 and some cases (DH parameter size for example) could not be checked at
123 all.
124
125 By setting an appropriate security level much of this complexity can be
126 avoided.
127
128 The bits of security limits affect all relevant parameters including
129 cipher suite encryption algorithms, supported ECC curves, supported
130 signature algorithms, DH parameter sizes, certificate key sizes and
131 signature algorithms. This limit applies no matter what other custom
132 settings an application has set: so if the cipher suite is set to ALL
133 then only cipher suites consistent with the security level are
134 permissible.
135
136 See SP800-57 for how the security limits are related to individual
137 algorithms.
138
139 Some security levels require large key sizes for non-ECC public key
140 algorithms which can severely degrade performance. For example 256 bits
141 of security requires the use of RSA keys of at least 15360 bits in
142 size.
143
144 Some restrictions can be gracefully handled: for example cipher suites
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
147 certificate key size or the DH parameter size will abort the handshake
148 with a fatal alert.
149
150 Attempts to set certificates or parameters with insufficient security
151 are also blocked. For example trying to set a certificate using a 512
152 bit RSA key or a certificate with a signature with SHA1 digest at level
153 1 using SSL_CTX_use_certificate(). Applications which do not check the
154 return values for errors will misbehave: for example it might appear
155 that a certificate is not set at all because it had been rejected.
156
158 SSL_CTX_set_security_level() and SSL_set_security_level() do not return
159 values.
160
161 SSL_CTX_get_security_level() and SSL_get_security_level() return a
162 integer that represents the security level with SSL_CTX or SSL,
163 respectively.
164
165 SSL_CTX_set_security_callback() and SSL_set_security_callback() do not
166 return values.
167
168 SSL_CTX_get_security_callback() and SSL_get_security_callback() return
169 the pointer to the security callback or NULL if the callback is not
170 set.
171
172 SSL_CTX_get0_security_ex_data() and SSL_get0_security_ex_data() return
173 the extra data pointer or NULL if the ex data is not set.
174
176 ssl(7)
177
179 These functions were added in OpenSSL 1.1.0.
180
182 Copyright 2014-2022 The OpenSSL Project Authors. All Rights Reserved.
183
184 Licensed under the Apache License 2.0 (the "License"). You may not use
185 this file except in compliance with the License. You can obtain a copy
186 in the file LICENSE in the source distribution or at
187 <https://www.openssl.org/source/license.html>.
188
189
190
1913.1.1 2023-08-31 SSL_CTX_SET_SECURITY_LEVEL(3ossl)