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,
|
---|
19 | int bits, int nid,
|
---|
20 | void *other, void *ex));
|
---|
21 |
|
---|
22 | void SSL_set_security_callback(SSL *s, int (*cb)(SSL *s, SSL_CTX *ctx, int op,
|
---|
23 | int bits, int nid,
|
---|
24 | void *other, void *ex));
|
---|
25 |
|
---|
26 | int (*SSL_CTX_get_security_callback(const SSL_CTX *ctx))(SSL *s, SSL_CTX *ctx, int op,
|
---|
27 | int bits, int nid, void *other,
|
---|
28 | void *ex);
|
---|
29 | int (*SSL_get_security_callback(const SSL *s))(SSL *s, SSL_CTX *ctx, int op,
|
---|
30 | int bits, int nid, void *other,
|
---|
31 | void *ex);
|
---|
32 |
|
---|
33 | void SSL_CTX_set0_security_ex_data(SSL_CTX *ctx, void *ex);
|
---|
34 | void SSL_set0_security_ex_data(SSL *s, void *ex);
|
---|
35 |
|
---|
36 | void *SSL_CTX_get0_security_ex_data(const SSL_CTX *ctx);
|
---|
37 | void *SSL_get0_security_ex_data(const SSL *s);
|
---|
38 |
|
---|
39 | =head1 DESCRIPTION
|
---|
40 |
|
---|
41 | The functions SSL_CTX_set_security_level() and SSL_set_security_level() set
|
---|
42 | the security level to B<level>. If not set the library default security level
|
---|
43 | is used.
|
---|
44 |
|
---|
45 | The functions SSL_CTX_get_security_level() and SSL_get_security_level()
|
---|
46 | retrieve the current security level.
|
---|
47 |
|
---|
48 | SSL_CTX_set_security_callback(), SSL_set_security_callback(),
|
---|
49 | SSL_CTX_get_security_callback() and SSL_get_security_callback() get or set
|
---|
50 | the security callback associated with B<ctx> or B<s>. If not set a default
|
---|
51 | security callback is used. The meaning of the parameters and the behaviour
|
---|
52 | of the default callbacks is described below.
|
---|
53 |
|
---|
54 | SSL_CTX_set0_security_ex_data(), SSL_set0_security_ex_data(),
|
---|
55 | SSL_CTX_get0_security_ex_data() and SSL_get0_security_ex_data() set the
|
---|
56 | extra data pointer passed to the B<ex> parameter of the callback. This
|
---|
57 | value is passed to the callback verbatim and can be set to any convenient
|
---|
58 | application specific value.
|
---|
59 |
|
---|
60 | =head1 DEFAULT CALLBACK BEHAVIOUR
|
---|
61 |
|
---|
62 | If an application doesn't set its own security callback the default
|
---|
63 | callback is used. It is intended to provide sane defaults. The meaning
|
---|
64 | of each level is described below.
|
---|
65 |
|
---|
66 | =over 4
|
---|
67 |
|
---|
68 | =item B<Level 0>
|
---|
69 |
|
---|
70 | Everything is permitted. This retains compatibility with previous versions of
|
---|
71 | OpenSSL.
|
---|
72 |
|
---|
73 | =item B<Level 1>
|
---|
74 |
|
---|
75 | The security level corresponds to a minimum of 80 bits of security. Any
|
---|
76 | parameters offering below 80 bits of security are excluded. As a result RSA,
|
---|
77 | DSA and DH keys shorter than 1024 bits and ECC keys shorter than 160 bits
|
---|
78 | are prohibited. Any cipher suite using MD5 for the MAC is also prohibited. Any
|
---|
79 | cipher suites using CCM with a 64 bit authentication tag are prohibited. Note
|
---|
80 | that signatures using SHA1 and MD5 are also forbidden at this level as they
|
---|
81 | have less than 80 security bits. Additionally, SSLv3, TLS 1.0, TLS 1.1 and
|
---|
82 | DTLS 1.0 are all disabled at this level.
|
---|
83 |
|
---|
84 | =item B<Level 2>
|
---|
85 |
|
---|
86 | Security level set to 112 bits of security. As a result RSA, DSA and DH keys
|
---|
87 | shorter than 2048 bits and ECC keys shorter than 224 bits are prohibited.
|
---|
88 | In addition to the level 1 exclusions any cipher suite using RC4 is also
|
---|
89 | prohibited. Compression is disabled.
|
---|
90 |
|
---|
91 | =item B<Level 3>
|
---|
92 |
|
---|
93 | Security level set to 128 bits of security. As a result RSA, DSA and DH keys
|
---|
94 | shorter than 3072 bits and ECC keys shorter than 256 bits are prohibited.
|
---|
95 | In addition to the level 2 exclusions cipher suites not offering forward
|
---|
96 | secrecy are prohibited. Session tickets are disabled.
|
---|
97 |
|
---|
98 | =item B<Level 4>
|
---|
99 |
|
---|
100 | Security level set to 192 bits of security. As a result RSA, DSA and
|
---|
101 | DH keys shorter than 7680 bits and ECC keys shorter than 384 bits are
|
---|
102 | prohibited. Cipher suites using SHA1 for the MAC are prohibited.
|
---|
103 |
|
---|
104 | =item B<Level 5>
|
---|
105 |
|
---|
106 | Security level set to 256 bits of security. As a result RSA, DSA and DH keys
|
---|
107 | shorter than 15360 bits and ECC keys shorter than 512 bits are prohibited.
|
---|
108 |
|
---|
109 | =back
|
---|
110 |
|
---|
111 | =head1 APPLICATION DEFINED SECURITY CALLBACKS
|
---|
112 |
|
---|
113 | I<Documentation to be provided.>
|
---|
114 |
|
---|
115 | =head1 NOTES
|
---|
116 |
|
---|
117 | The default security level can be configured when OpenSSL is compiled by
|
---|
118 | setting B<-DOPENSSL_TLS_SECURITY_LEVEL=level>. If not set then 2 is used.
|
---|
119 |
|
---|
120 | The security framework disables or reject parameters inconsistent with the
|
---|
121 | set security level. In the past this was difficult as applications had to set
|
---|
122 | a number of distinct parameters (supported ciphers, supported curves supported
|
---|
123 | signature algorithms) to achieve this end and some cases (DH parameter size
|
---|
124 | for example) could not be checked at all.
|
---|
125 |
|
---|
126 | By setting an appropriate security level much of this complexity can be
|
---|
127 | avoided.
|
---|
128 |
|
---|
129 | The bits of security limits affect all relevant parameters including
|
---|
130 | cipher suite encryption algorithms, supported ECC curves, supported
|
---|
131 | signature algorithms, DH parameter sizes, certificate key sizes and
|
---|
132 | signature algorithms. This limit applies no matter what other custom
|
---|
133 | settings an application has set: so if the cipher suite is set to B<ALL>
|
---|
134 | then only cipher suites consistent with the security level are 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 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 certificate
|
---|
146 | key size or the DH parameter size will abort the handshake with a fatal
|
---|
147 | alert.
|
---|
148 |
|
---|
149 | Attempts to set certificates or parameters with insufficient security are
|
---|
150 | also blocked. For example trying to set a certificate using a 512 bit RSA key
|
---|
151 | or a certificate with a signature with SHA1 digest at level 1 using
|
---|
152 | SSL_CTX_use_certificate(). Applications which do not check the return values
|
---|
153 | for errors will misbehave: for example it might appear that a certificate is
|
---|
154 | not set at all because it had been rejected.
|
---|
155 |
|
---|
156 | =head1 RETURN VALUES
|
---|
157 |
|
---|
158 | SSL_CTX_set_security_level() and SSL_set_security_level() do not return values.
|
---|
159 |
|
---|
160 | SSL_CTX_get_security_level() and SSL_get_security_level() return a integer that
|
---|
161 | represents the security level with B<SSL_CTX> or B<SSL>, respectively.
|
---|
162 |
|
---|
163 | SSL_CTX_set_security_callback() and SSL_set_security_callback() do not return
|
---|
164 | values.
|
---|
165 |
|
---|
166 | SSL_CTX_get_security_callback() and SSL_get_security_callback() return the pointer
|
---|
167 | to the security callback or NULL if the callback is not set.
|
---|
168 |
|
---|
169 | SSL_CTX_get0_security_ex_data() and SSL_get0_security_ex_data() return the extra
|
---|
170 | data pointer or NULL if the ex data is not set.
|
---|
171 |
|
---|
172 | =head1 SEE ALSO
|
---|
173 |
|
---|
174 | L<ssl(7)>
|
---|
175 |
|
---|
176 | =head1 HISTORY
|
---|
177 |
|
---|
178 | These functions were added in OpenSSL 1.1.0.
|
---|
179 |
|
---|
180 | =head1 COPYRIGHT
|
---|
181 |
|
---|
182 | Copyright 2014-2020 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 | L<https://www.openssl.org/source/license.html>.
|
---|
188 |
|
---|
189 | =cut
|
---|