b5b7f0623fb7070d93e1f1bc5225dbeae3541ffd
[openssl.git] / doc / ssl / 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 libary 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 it's 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 set to 80 bits of security. Any parameters offering
71 below 80 bits of security are excluded. As a result all export ciphersuites
72 are prohibited. SSL version 2 is prohibited. Any ciphersuite using MD5 for
73 the MAC is also prohibited.
74
75 =item B<Level 2>
76
77 Security level set to 112 bits of security. In addition to the level 1
78 exclusions any ciphersuite using RC4 is also prohibited. SSL version
79 3 is also not allowed. Compression is disabled.
80
81 =item B<Level 3>
82
83 Ssecurity level set to 128 bits of security. In addition to the level 2
84 exclusions any ciphersuite not offering forward secrecy are prohibited.
85 TLS versions below 1.1 are not permitted. Session tickets are disabled.
86
87 =item B<Level 4>
88
89 Security level set to 192 bits of security. TLS versions below 1.2 are not
90 permitted.
91
92 =item B<Level 5>
93
94 Security level set to 256 bits of security.
95
96 =back
97
98 =head1 APPLICATION DEFINED SECURITY CALLBACKS
99
100 TBA
101
102 =head1 NOTES
103
104 The default security level can be configured when OpenSSL is compiled by
105 setting B<-DOPENSSL_TLS_SECURITY_LEVEL=level>. If not set then 1 is used.
106
107 The security framework disables or reject parameters inconsistent with the
108 set security level. In the past this was difficult as applications had to set
109 a number of distinct parameters (supported ciphers, supported curves supported
110 signature algorithms) to achieve this end and some cases (DH parameter size
111 for example) could not be checked at all.
112
113 By setting an appropriate security level much of this complexity can be
114 avoided.
115
116 The bits of security limits affect all relevant parameters including
117 ciphersuite encryption algorithms, supported ECC curves, supported
118 signature algorithms, DH parameter sizes, certificate key sizes and
119 signature algorithms. This limit applies no matter what other custom
120 settings an application has set: so if the ciphersuite is set to B<ALL>
121 then only ciphersuites consistent with the security level are permissible.
122
123 See SP800-57 for how the security limits are related to individual
124 algorithms.
125
126 SHA1 is in widespread use in certificates but it only offers 80 bits
127 of security. This is problematic as anything above level 1 will reject
128 them.
129
130 Some security levels require large key sizes for none-ECC public key
131 algorithms. For example 256 bits of security requires the use of RSA
132 keys of at least 15360 bits in size.
133
134 Some restrictions can be gracefully handled: for example ciphersuites
135 offering insufficient security are not sent by the client and will not
136 be selected by the server. Other restrictions such as the peer certificate
137 key size or the DH pameter size will abort the handshake with a fatal
138 alert.
139
140 Attempts to set certificates or parameters with insufficient security are
141 also blocked. For example trying to set a certificate using a 512 bit RSA
142 key using SSL_CTX_use_certificate() at level 1. Applications which do not
143 check the return values for errors will misbehave.
144
145 =head1 SEE ALSO
146
147 TBA
148
149 =head1 HISTORY
150
151 These functions were first added to OpenSSL 1.1.0
152
153 =cut