44 #include <QtNetwork/private/qsslkey_p.h>
46 #include <QtNetwork/qsslsocket.h>
48 #include <QtCore/qscopeguard.h>
86 void *phrase =
const_cast<char *
>(passPhrase.
data());
88 #ifdef OPENSSL_NO_DEPRECATED_3_0
119 #ifndef OPENSSL_NO_EC
142 if (headerIndex == -1 || footerIndex == -1) {
148 if (headerIndex == -1 || footerIndex == -1) {
155 if (headerIndex == -1 || footerIndex == -1)
158 der = der.
mid(headerIndex +
header.size(), footerIndex - (headerIndex +
header.size()));
175 if (!
value.isEmpty())
178 bool hasCR = (
i && der[
i-1] ==
'\r');
182 }
while (
i < der.
count() && (der.
at(
i) ==
' ' || der.
at(
i) ==
'\t'));
198 #ifndef OPENSSL_NO_DEPRECATED_3_0
214 #ifndef OPENSSL_NO_EC
243 #ifndef OPENSSL_NO_DEPRECATED_3_0
251 #ifndef OPENSSL_NO_EC
260 "This version of OpenSSL disabled direct manipulation with RSA/DSA/DH/EC_KEY structures, consider using QSsl::Opaque instead.");
270 #ifndef OPENSSL_NO_DEPRECATED_3_0
278 #ifndef OPENSSL_NO_EC
296 const EVP_CIPHER *cipher =
nullptr;
298 #ifndef OPENSSL_NO_DES
311 #ifndef OPENSSL_NO_DEPRECATED_3_0
313 #define write_pubkey(alg, key) q_PEM_write_bio_##alg##_PUBKEY(bio, key)
314 #define write_privatekey(alg, key) \
315 q_PEM_write_bio_##alg##PrivateKey(bio, key, cipher, (uchar *)passPhrase.data(), \
316 passPhrase.size(), nullptr, nullptr)
320 #define write_pubkey(alg, key) q_PEM_write_bio_PUBKEY(bio, genericKey)
321 #define write_privatekey(alg, key) \
322 q_PEM_write_bio_PrivateKey_traditional(bio, genericKey, cipher, (uchar *)passPhrase.data(), passPhrase.size(), nullptr, nullptr)
342 #ifdef OPENSSL_NO_DEPRECATED_3_0
355 passPhrase.
size(),
nullptr,
nullptr)) {
358 #ifndef OPENSSL_NO_EC
374 char *
data =
nullptr;
387 EVP_PKEY *evpKey =
reinterpret_cast<EVP_PKEY *
>(
handle);
404 #ifndef OPENSSL_NO_DEPRECATED_3_0
405 #define get_key(key, alg) key = q_EVP_PKEY_get1_##alg(pkey)
407 #define get_key(key, alg) q_EVP_PKEY_up_ref(pkey); genericKey = pkey;
429 #ifndef OPENSSL_NO_EC
450 const EVP_CIPHER *
type =
nullptr;
455 #ifndef OPENSSL_NO_DES
460 #ifndef OPENSSL_NO_DES
465 #ifndef OPENSSL_NO_RC2
484 output.
resize(
data.size() + EVP_MAX_BLOCK_LENGTH);
499 reinterpret_cast<const unsigned char *
>(
key.constData()),
500 reinterpret_cast<const unsigned char *
>(iv.
constData()),
503 reinterpret_cast<unsigned char *
>(output.
data()), &
len,
504 reinterpret_cast<const unsigned char *
>(
data.constData()),
data.size());
506 reinterpret_cast<unsigned char *
>(output.
data()) +
len, &
i);
530 std::unique_ptr<TlsKeyOpenSSL> keyRaii(tlsKey);
534 #ifndef OPENSSL_NO_DEPRECATED_3_0
536 #define get_pubkey(keyName, alg) tlsKey->keyName = q_EVP_PKEY_get1_##alg(pkey)
540 #define get_pubkey(a, b) tlsKey->genericKey = pkey
552 }
else if (
keyType == EVP_PKEY_DSA) {
556 #ifndef OPENSSL_NO_EC
557 }
else if (
keyType == EVP_PKEY_EC) {
562 }
else if (
keyType == EVP_PKEY_DH) {
568 #ifndef OPENSSL_NO_DEPRECATED_3_0
572 return keyRaii.release();
small capitals from c petite p scientific i
[1]
The QByteArray class provides an array of bytes.
QByteArray trimmed() const &
qsizetype size() const noexcept
const char * constData() const noexcept
qsizetype indexOf(char c, qsizetype from=0) const
static QByteArray fromBase64(const QByteArray &base64, Base64Options options=Base64Encoding)
char at(qsizetype i) const
bool contains(char c) const
bool isEmpty() const noexcept
QByteArray left(qsizetype len) const
void resize(qsizetype size)
qsizetype count(char c) const
QByteArray mid(qsizetype index, qsizetype len=-1) const
iterator insert(const Key &key, const T &value)
static bool supportsSsl()
static void logAndClearErrorQueue()
KeyType type() const override
QByteArray pemFromDer(const QByteArray &der, const QMap< QByteArray, QByteArray > &headers) const override
KeyAlgorithm algorithm() const override
static QByteArray pkcs8Footer(bool encrypted)
static QByteArray pkcs8Header(bool encrypted)
bool isNull() const override
KeyAlgorithm keyAlgorithm
QByteArray pemHeader() const
QByteArray pemFooter() const
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)
QByteArray doCrypt(QSslKeyPrivate::Cipher cipher, const QByteArray &data, const QByteArray &key, const QByteArray &iv, bool enc)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
QT_BEGIN_INCLUDE_NAMESPACE typedef unsigned char uchar
#define qCWarning(category,...)
GLenum GLuint GLenum GLsizei length
GLuint64 GLenum void * handle
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
int q_EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c)
const EVP_CIPHER * q_EVP_aes_128_cbc()
const EVP_CIPHER * q_EVP_des_cbc()
DH * q_EVP_PKEY_get1_DH(EVP_PKEY *a)
EC_KEY * q_PEM_read_bio_EC_PUBKEY(BIO *a, EC_KEY **b, pem_password_cb *c, void *d)
int q_EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, const unsigned char *key, const unsigned char *iv, int enc)
EVP_PKEY * q_PEM_read_bio_PrivateKey(BIO *a, EVP_PKEY **b, pem_password_cb *c, void *d)
int q_EVP_PKEY_base_id(EVP_PKEY *a)
const EVP_CIPHER * q_EVP_rc2_cbc()
EC_KEY * q_PEM_read_bio_ECPrivateKey(BIO *a, EC_KEY **b, pem_password_cb *c, void *d)
const EVP_CIPHER * q_EVP_des_ede3_cbc()
int q_EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl)
DSA * q_PEM_read_bio_DSA_PUBKEY(BIO *a, DSA **b, pem_password_cb *c, void *d)
#define q_BIO_get_mem_data(b, pp)
void q_EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a)
int q_EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen)
RSA * q_PEM_read_bio_RSA_PUBKEY(BIO *a, RSA **b, pem_password_cb *c, void *d)
EVP_CIPHER_CTX * q_EVP_CIPHER_CTX_new()
void q_EVP_PKEY_free(EVP_PKEY *a)
DSA * q_PEM_read_bio_DSAPrivateKey(BIO *a, DSA **b, pem_password_cb *c, void *d)
void q_EC_KEY_free(EC_KEY *ecdh)
EVP_PKEY * q_X509_get_pubkey(X509 *a)
int q_EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
int q_EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const unsigned char *key, const unsigned char *iv, int enc)
int q_PEM_write_bio_PUBKEY(BIO *a, EVP_PKEY *b)
int q_EVP_PKEY_set1_DH(EVP_PKEY *a, DH *b)
const EC_GROUP * q_EC_KEY_get0_group(const EC_KEY *k)
int q_EC_GROUP_get_degree(const EC_GROUP *g)
RSA * q_PEM_read_bio_RSAPrivateKey(BIO *a, RSA **b, pem_password_cb *c, void *d)
EVP_PKEY * q_EVP_PKEY_new()
int q_PEM_write_bio_PrivateKey(BIO *a, EVP_PKEY *b, const EVP_CIPHER *c, unsigned char *d, int e, pem_password_cb *f, void *g)
const EVP_CIPHER * q_EVP_aes_256_cbc()
EVP_PKEY * q_PEM_read_bio_PUBKEY(BIO *a, EVP_PKEY **b, pem_password_cb *c, void *d)
BIO * q_BIO_new(const BIO_METHOD *a)
int q_EVP_PKEY_type(int a)
const EVP_CIPHER * q_EVP_aes_192_cbc()
const BIO_METHOD * q_BIO_s_mem()
int q_EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
BIO * q_BIO_new_mem_buf(void *a, int b)
#define write_pubkey(alg, key)
#define write_privatekey(alg, key)
#define get_key(key, alg)
#define get_pubkey(keyName, alg)
QHttpRequestHeader header("GET", QUrl::toPercentEncoding("/index.html"))
[1]