QtBase  v6.3.1
qtlskey_openssl_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2021 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 #ifndef QTLSKEY_OPENSSL_H
41 #define QTLSKEY_OPENSSL_H
42 
43 //
44 // W A R N I N G
45 // -------------
46 //
47 // This file is not part of the Qt API. It exists purely as an
48 // implementation detail. This header file may change from version to
49 // version without notice, or even be removed.
50 //
51 // We mean it.
52 //
53 
54 #include <QtNetwork/private/qtnetworkglobal_p.h>
55 
56 #include "../shared/qtlskey_base_p.h"
57 
58 #include <QtNetwork/private/qtlsbackend_p.h>
59 #include <QtNetwork/private/qsslkey_p.h>
60 
61 #include <QtNetwork/qssl.h>
62 
63 #include <QtCore/qbytearray.h>
64 #include <QtCore/qglobal.h>
65 
66 #include <openssl/rsa.h>
67 #include <openssl/dsa.h>
68 #include <openssl/dh.h>
69 
70 #ifdef OPENSSL_NO_DEPRECATED_3_0
71 typedef struct evp_pkey_st EVP_PKEY;
72 typedef struct dsa_st DSA;
73 typedef struct rsa_st RSA;
74 typedef struct dh_st DH;
75 typedef struct ec_key_st EC_KEY;
76 #endif // OPENSSL_NO_DEPRECATED_3_0
77 
79 
81 
82 namespace QTlsPrivate {
83 
85 {
86 public:
88  : opaque(nullptr)
89  {
90  clear(false);
91  }
93  {
94  clear(true);
95  }
96 
98  const QByteArray &passPhrase, bool deepClear) override;
100  const QByteArray &passPhrase, bool deepClear) override;
101 
102  QByteArray toPem(const QByteArray &passPhrase) const override;
103  QByteArray derFromPem(const QByteArray &pem, QMap<QByteArray, QByteArray> *headers) const override;
104 
105  void fromHandle(Qt::HANDLE opaque, KeyType expectedType) override;
106 
107  void clear(bool deep) override;
108  Qt::HANDLE handle() const override;
109  int length() const override;
110 
111  QByteArray decrypt(Cipher cipher, const QByteArray &data,
112  const QByteArray &key, const QByteArray &iv) const override;
113  QByteArray encrypt(Cipher cipher, const QByteArray &data,
114  const QByteArray &key, const QByteArray &iv) const override;
115 
116  static TlsKeyOpenSSL *publicKeyFromX509(X509 *x);
117 
118  union {
119  EVP_PKEY *opaque;
120  RSA *rsa;
121  DSA *dsa;
122  DH *dh;
123 #ifndef OPENSSL_NO_EC
124  EC_KEY *ec;
125 #endif
126  EVP_PKEY *genericKey;
127  };
128 
129  bool fromEVP_PKEY(EVP_PKEY *pkey);
130 };
131 
132 } // namespace QTlsPrivate
133 
135 
136 #endif // QTLSKEY_OPENSSL_H
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:85
KeyAlgorithm algorithm() const override
QSsl::KeyAlgorithm KeyAlgorithm
void decodePem(KeyType type, KeyAlgorithm algorithm, const QByteArray &pem, const QByteArray &passPhrase, bool deepClear) override
void fromHandle(Qt::HANDLE opaque, KeyType expectedType) override
void clear(bool deep) override
bool fromEVP_PKEY(EVP_PKEY *pkey)
QByteArray derFromPem(const QByteArray &pem, QMap< QByteArray, QByteArray > *headers) const override
void decodeDer(KeyType type, KeyAlgorithm algorithm, const QByteArray &der, const QByteArray &passPhrase, bool deepClear) override
QByteArray decrypt(Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv) const override
QByteArray toPem(const QByteArray &passPhrase) const override
int length() const override
Qt::HANDLE handle() const override
QByteArray encrypt(Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv) const override
static TlsKeyOpenSSL * publicKeyFromX509(X509 *x)
void * HANDLE
Definition: qnamespace.h:1561
GLenum type
Definition: qopengl.h:270
GLint GLint GLint GLint GLint x
[0]
GLuint64 key
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
QT_BEGIN_NAMESPACE QT_REQUIRE_CONFIG(ssl)
QObject::connect nullptr