| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtNetwork module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | |
| 41 | #include "qsslkey.h" |
| 42 | #include "qssl_p.h" |
| 43 | |
| 44 | QT_BEGIN_NAMESPACE |
| 45 | |
| 46 | Q_LOGGING_CATEGORY(lcSsl, "qt.network.ssl" ); |
| 47 | |
| 48 | /*! \namespace QSsl |
| 49 | |
| 50 | \brief The QSsl namespace declares enums common to all SSL classes in Qt Network. |
| 51 | \since 4.3 |
| 52 | |
| 53 | \ingroup network |
| 54 | \ingroup ssl |
| 55 | \inmodule QtNetwork |
| 56 | */ |
| 57 | |
| 58 | /*! |
| 59 | \enum QSsl::KeyType |
| 60 | |
| 61 | Describes the two types of keys QSslKey supports. |
| 62 | |
| 63 | \value PrivateKey A private key. |
| 64 | \value PublicKey A public key. |
| 65 | */ |
| 66 | |
| 67 | /*! |
| 68 | \enum QSsl::KeyAlgorithm |
| 69 | |
| 70 | Describes the different key algorithms supported by QSslKey. |
| 71 | |
| 72 | \value Rsa The RSA algorithm. |
| 73 | \value Dsa The DSA algorithm. |
| 74 | \value Ec The Elliptic Curve algorithm. |
| 75 | \value Dh The Diffie-Hellman algorithm. |
| 76 | \value Opaque A key that should be treated as a 'black box' by QSslKey. |
| 77 | |
| 78 | The opaque key facility allows applications to add support for facilities |
| 79 | such as PKCS#11 that Qt does not currently offer natively. |
| 80 | */ |
| 81 | |
| 82 | /*! |
| 83 | \enum QSsl::EncodingFormat |
| 84 | |
| 85 | Describes supported encoding formats for certificates and keys. |
| 86 | |
| 87 | \value Pem The PEM format. |
| 88 | \value Der The DER format. |
| 89 | */ |
| 90 | |
| 91 | /*! |
| 92 | \enum QSsl::AlternativeNameEntryType |
| 93 | |
| 94 | Describes the key types for alternative name entries in QSslCertificate. |
| 95 | |
| 96 | \value EmailEntry An email entry; the entry contains an email address that |
| 97 | the certificate is valid for. |
| 98 | |
| 99 | \value DnsEntry A DNS host name entry; the entry contains a host name |
| 100 | entry that the certificate is valid for. The entry may contain wildcards. |
| 101 | |
| 102 | \value IpAddressEntry An IP address entry; the entry contains an IP address |
| 103 | entry that the certificate is valid for, introduced in Qt 5.13. |
| 104 | |
| 105 | \sa QSslCertificate::subjectAlternativeNames() |
| 106 | */ |
| 107 | |
| 108 | /*! |
| 109 | \enum QSsl::SslProtocol |
| 110 | |
| 111 | Describes the protocol of the cipher. |
| 112 | |
| 113 | \value TlsV1_0 TLSv1.0 |
| 114 | \value TlsV1_0OrLater TLSv1.0 and later versions. |
| 115 | \value TlsV1_1 TLSv1.1. |
| 116 | \value TlsV1_1OrLater TLSv1.1 and later versions. |
| 117 | \value TlsV1_2 TLSv1.2. |
| 118 | \value TlsV1_2OrLater TLSv1.2 and later versions. |
| 119 | \value DtlsV1_0 DTLSv1.0 |
| 120 | \value DtlsV1_0OrLater DTLSv1.0 and later versions. |
| 121 | \value DtlsV1_2 DTLSv1.2 |
| 122 | \value DtlsV1_2OrLater DTLSv1.2 and later versions. |
| 123 | \value TlsV1_3 TLSv1.3. (Since Qt 5.12) |
| 124 | \value TlsV1_3OrLater TLSv1.3 and later versions. (Since Qt 5.12) |
| 125 | \value UnknownProtocol The cipher's protocol cannot be determined. |
| 126 | \value AnyProtocol Any supported protocol. This value is used by QSslSocket only. |
| 127 | \value SecureProtocols The default option, using protocols known to be secure. |
| 128 | */ |
| 129 | |
| 130 | /*! |
| 131 | \enum QSsl::SslOption |
| 132 | |
| 133 | Describes the options that can be used to control the details of |
| 134 | SSL behaviour. These options are generally used to turn features off |
| 135 | to work around buggy servers. |
| 136 | |
| 137 | \value SslOptionDisableEmptyFragments Disables the insertion of empty |
| 138 | fragments into the data when using block ciphers. When enabled, this |
| 139 | prevents some attacks (such as the BEAST attack), however it is |
| 140 | incompatible with some servers. |
| 141 | \value SslOptionDisableSessionTickets Disables the SSL session ticket |
| 142 | extension. This can cause slower connection setup, however some servers |
| 143 | are not compatible with the extension. |
| 144 | \value SslOptionDisableCompression Disables the SSL compression |
| 145 | extension. When enabled, this allows the data being passed over SSL to |
| 146 | be compressed, however some servers are not compatible with this |
| 147 | extension. |
| 148 | \value SslOptionDisableServerNameIndication Disables the SSL server |
| 149 | name indication extension. When enabled, this tells the server the virtual |
| 150 | host being accessed allowing it to respond with the correct certificate. |
| 151 | \value SslOptionDisableLegacyRenegotiation Disables the older insecure |
| 152 | mechanism for renegotiating the connection parameters. When enabled, this |
| 153 | option can allow connections for legacy servers, but it introduces the |
| 154 | possibility that an attacker could inject plaintext into the SSL session. |
| 155 | \value SslOptionDisableSessionSharing Disables SSL session sharing via |
| 156 | the session ID handshake attribute. |
| 157 | \value SslOptionDisableSessionPersistence Disables storing the SSL session |
| 158 | in ASN.1 format as returned by QSslConfiguration::sessionTicket(). Enabling |
| 159 | this feature adds memory overhead of approximately 1K per used session |
| 160 | ticket. |
| 161 | \value SslOptionDisableServerCipherPreference Disables selecting the cipher |
| 162 | chosen based on the servers preferences rather than the order ciphers were |
| 163 | sent by the client. This option is only relevant to server sockets, and is |
| 164 | only honored by the OpenSSL backend. |
| 165 | |
| 166 | By default, SslOptionDisableEmptyFragments is turned on since this causes |
| 167 | problems with a large number of servers. SslOptionDisableLegacyRenegotiation |
| 168 | is also turned on, since it introduces a security risk. |
| 169 | SslOptionDisableCompression is turned on to prevent the attack publicised by |
| 170 | CRIME. |
| 171 | SslOptionDisableSessionPersistence is turned on to optimize memory usage. |
| 172 | The other options are turned off. |
| 173 | |
| 174 | \note Availability of above options depends on the version of the SSL |
| 175 | backend in use. |
| 176 | */ |
| 177 | |
| 178 | /*! |
| 179 | \enum QSsl::AlertLevel |
| 180 | \brief Describes the level of an alert message |
| 181 | \relates QSslSocket |
| 182 | \since 6.0 |
| 183 | |
| 184 | \ingroup network |
| 185 | \ingroup ssl |
| 186 | \inmodule QtNetwork |
| 187 | |
| 188 | This enum describes the level of an alert message that was sent |
| 189 | or received. |
| 190 | |
| 191 | \value Warning Non-fatal alert message |
| 192 | \value Fatal Fatal alert message, the underlying backend will |
| 193 | handle such an alert properly and close the connection. |
| 194 | \value Unknown An alert of unknown level of severity. |
| 195 | */ |
| 196 | |
| 197 | /*! |
| 198 | \enum QSsl::AlertType |
| 199 | \brief Enumerates possible codes that an alert message can have |
| 200 | \relates QSslSocket |
| 201 | \since 6.0 |
| 202 | |
| 203 | \ingroup network |
| 204 | \ingroup ssl |
| 205 | \inmodule QtNetwork |
| 206 | |
| 207 | See \l{https://tools.ietf.org/html/rfc8446#page-85}{RFC 8446, section 6} |
| 208 | for the possible values and their meaning. |
| 209 | |
| 210 | \value CloseNotify, |
| 211 | \value UnexpectedMessage |
| 212 | \value BadRecordMac |
| 213 | \value RecordOverflow |
| 214 | \value DecompressionFailure |
| 215 | \value HandshakeFailure |
| 216 | \value NoCertificate |
| 217 | \value BadCertificate |
| 218 | \value UnsupportedCertificate |
| 219 | \value CertificateRevoked |
| 220 | \value CertificateExpired |
| 221 | \value CertificateUnknown |
| 222 | \value IllegalParameter |
| 223 | \value UnknownCa |
| 224 | \value AccessDenied |
| 225 | \value DecodeError |
| 226 | \value DecryptError |
| 227 | \value ExportRestriction |
| 228 | \value ProtocolVersion |
| 229 | \value InsufficientSecurity |
| 230 | \value InternalError |
| 231 | \value InappropriateFallback |
| 232 | \value UserCancelled |
| 233 | \value NoRenegotiation |
| 234 | \value MissingExtension |
| 235 | \value UnsupportedExtension |
| 236 | \value CertificateUnobtainable |
| 237 | \value UnrecognizedName |
| 238 | \value BadCertificateStatusResponse |
| 239 | \value BadCertificateHashValue |
| 240 | \value UnknownPskIdentity |
| 241 | \value CertificateRequired |
| 242 | \value NoApplicationProtocol |
| 243 | \value UnknownAlertMessage |
| 244 | */ |
| 245 | |
| 246 | QT_END_NAMESPACE |
| 247 | |