| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/ssl/qsslkey_p.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | QSslKey::QSslKey() | - | ||||||||||||||||||
| 9 | : d(new QSslKeyPrivate) | - | ||||||||||||||||||
| 10 | { | - | ||||||||||||||||||
| 11 | } executed 13280 times by 17 tests: end of blockExecuted by:
| 13280 | ||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | QByteArray QSslKeyPrivate::pemHeader() const | - | ||||||||||||||||||
| 17 | { | - | ||||||||||||||||||
| 18 | if (type == QSsl::PublicKey
| 576-590 | ||||||||||||||||||
| 19 | return executed 590 times by 2 tests: ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN PUBLIC KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN PUBLIC KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN PUBLIC KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN PUBLIC KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
executed 590 times by 2 tests: ba;return ba;Executed by:
executed 590 times by 2 tests: }());return ba;Executed by:
executed 590 times by 2 tests: return ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN PUBLIC KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN PUBLIC KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
| 590 | ||||||||||||||||||
| 20 | else if (algorithm == QSsl::Rsa
| 287-289 | ||||||||||||||||||
| 21 | return executed 289 times by 2 tests: ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN RSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN RSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN RSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN RSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
executed 289 times by 2 tests: ba;return ba;Executed by:
executed 289 times by 2 tests: }());return ba;Executed by:
executed 289 times by 2 tests: return ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN RSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN RSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
| 289 | ||||||||||||||||||
| 22 | else if (algorithm == QSsl::Dsa
| 123-164 | ||||||||||||||||||
| 23 | return executed 164 times by 1 test: ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN DSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN DSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN DSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN DSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
executed 164 times by 1 test: ba;return ba;Executed by:
executed 164 times by 1 test: }());return ba;Executed by:
executed 164 times by 1 test: return ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN DSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN DSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
| 164 | ||||||||||||||||||
| 24 | else if (algorithm == QSsl::Ec
| 0-123 | ||||||||||||||||||
| 25 | return executed 123 times by 1 test: ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN EC PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN EC PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN EC PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN EC PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
executed 123 times by 1 test: ba;return ba;Executed by:
executed 123 times by 1 test: }());return ba;Executed by:
executed 123 times by 1 test: return ([]() -> QByteArray { enum { Size = sizeof("-----BEGIN EC PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----BEGIN EC PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
| 123 | ||||||||||||||||||
| 26 | - | |||||||||||||||||||
| 27 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,116) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||||||||
| 28 | return never executed: QByteArray();return QByteArray();never executed: return QByteArray(); | 0 | ||||||||||||||||||
| 29 | } | - | ||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | QByteArray QSslKeyPrivate::pemFooter() const | - | ||||||||||||||||||
| 35 | { | - | ||||||||||||||||||
| 36 | if (type == QSsl::PublicKey
| 576-590 | ||||||||||||||||||
| 37 | return executed 590 times by 2 tests: ([]() -> QByteArray { enum { Size = sizeof("-----END PUBLIC KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END PUBLIC KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("-----END PUBLIC KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END PUBLIC KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
executed 590 times by 2 tests: ba;return ba;Executed by:
executed 590 times by 2 tests: }());return ba;Executed by:
executed 590 times by 2 tests: return ([]() -> QByteArray { enum { Size = sizeof("-----END PUBLIC KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END PUBLIC KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
| 590 | ||||||||||||||||||
| 38 | else if (algorithm == QSsl::Rsa
| 287-289 | ||||||||||||||||||
| 39 | return executed 289 times by 2 tests: ([]() -> QByteArray { enum { Size = sizeof("-----END RSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END RSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("-----END RSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END RSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
executed 289 times by 2 tests: ba;return ba;Executed by:
executed 289 times by 2 tests: }());return ba;Executed by:
executed 289 times by 2 tests: return ([]() -> QByteArray { enum { Size = sizeof("-----END RSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END RSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
| 289 | ||||||||||||||||||
| 40 | else if (algorithm == QSsl::Dsa
| 123-164 | ||||||||||||||||||
| 41 | return executed 164 times by 1 test: ([]() -> QByteArray { enum { Size = sizeof("-----END DSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END DSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("-----END DSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END DSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
executed 164 times by 1 test: ba;return ba;Executed by:
executed 164 times by 1 test: }());return ba;Executed by:
executed 164 times by 1 test: return ([]() -> QByteArray { enum { Size = sizeof("-----END DSA PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END DSA PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
| 164 | ||||||||||||||||||
| 42 | else if (algorithm == QSsl::Ec
| 0-123 | ||||||||||||||||||
| 43 | return executed 123 times by 1 test: ([]() -> QByteArray { enum { Size = sizeof("-----END EC PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END EC PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); returnreturn ([]() -> QByteArray { enum { Size = sizeof("-----END EC PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END EC PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
executed 123 times by 1 test: ba;return ba;Executed by:
executed 123 times by 1 test: }());return ba;Executed by:
executed 123 times by 1 test: return ([]() -> QByteArray { enum { Size = sizeof("-----END EC PRIVATE KEY-----") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "-----END EC PRIVATE KEY-----" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }());Executed by:
| 123 | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,134) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||||||||
| 46 | return never executed: QByteArray();return QByteArray();never executed: return QByteArray(); | 0 | ||||||||||||||||||
| 47 | } | - | ||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | QByteArray QSslKeyPrivate::pemFromDer(const QByteArray &der, const QMap<QByteArray, QByteArray> &headers) const | - | ||||||||||||||||||
| 55 | { | - | ||||||||||||||||||
| 56 | QByteArray pem(der.toBase64()); | - | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | const int lineWidth = 64; | - | ||||||||||||||||||
| 59 | const int newLines = pem.size() / lineWidth; | - | ||||||||||||||||||
| 60 | const bool rem = pem.size() % lineWidth; | - | ||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | for (int i = 0; i < newLines
| 226-1254 | ||||||||||||||||||
| 64 | pem.insert((i + 1) * lineWidth + i, '\n'); executed 1254 times by 2 tests: pem.insert((i + 1) * lineWidth + i, '\n');Executed by:
| 1254 | ||||||||||||||||||
| 65 | if (rem
| 8-218 | ||||||||||||||||||
| 66 | pem.append('\n'); executed 218 times by 2 tests: pem.append('\n');Executed by:
| 218 | ||||||||||||||||||
| 67 | - | |||||||||||||||||||
| 68 | QByteArray extra; | - | ||||||||||||||||||
| 69 | if (!headers.isEmpty()
| 0-226 | ||||||||||||||||||
| 70 | QMap<QByteArray, QByteArray>::const_iterator it = headers.constEnd(); | - | ||||||||||||||||||
| 71 | do { | - | ||||||||||||||||||
| 72 | --it; | - | ||||||||||||||||||
| 73 | extra += it.key() + ": " + it.value() + '\n'; | - | ||||||||||||||||||
| 74 | } never executed: while (it != headers.constBegin()end of block
| 0 | ||||||||||||||||||
| 75 | extra += '\n'; | - | ||||||||||||||||||
| 76 | } never executed: end of block | 0 | ||||||||||||||||||
| 77 | pem.prepend(pemHeader() + '\n' + extra); | - | ||||||||||||||||||
| 78 | pem.append(pemFooter() + '\n'); | - | ||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | return executed 226 times by 2 tests: pem;return pem;Executed by:
executed 226 times by 2 tests: return pem;Executed by:
| 226 | ||||||||||||||||||
| 81 | } | - | ||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | - | |||||||||||||||||||
| 88 | QByteArray QSslKeyPrivate::derFromPem(const QByteArray &pem, QMap<QByteArray, QByteArray> *headers) const | - | ||||||||||||||||||
| 89 | { | - | ||||||||||||||||||
| 90 | const QByteArray header = pemHeader(); | - | ||||||||||||||||||
| 91 | const QByteArray footer = pemFooter(); | - | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | QByteArray der(pem); | - | ||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | const int headerIndex = der.indexOf(header); | - | ||||||||||||||||||
| 96 | const int footerIndex = der.indexOf(footer); | - | ||||||||||||||||||
| 97 | if (headerIndex == -1
| 0-940 | ||||||||||||||||||
| 98 | return never executed: QByteArray();return QByteArray();never executed: return QByteArray(); | 0 | ||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | der = der.mid(headerIndex + header.size(), footerIndex - (headerIndex + header.size())); | - | ||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | if (der.contains("Proc-Type:")
| 0-940 | ||||||||||||||||||
| 103 | - | |||||||||||||||||||
| 104 | int i = 0; | - | ||||||||||||||||||
| 105 | while (i < der.count()
| 0 | ||||||||||||||||||
| 106 | int j = der.indexOf(':', i); | - | ||||||||||||||||||
| 107 | if (j == -1
| 0 | ||||||||||||||||||
| 108 | break; never executed: break; | 0 | ||||||||||||||||||
| 109 | const QByteArray field = der.mid(i, j - i).trimmed(); | - | ||||||||||||||||||
| 110 | j++; | - | ||||||||||||||||||
| 111 | - | |||||||||||||||||||
| 112 | QByteArray value; | - | ||||||||||||||||||
| 113 | do { | - | ||||||||||||||||||
| 114 | i = der.indexOf('\n', j); | - | ||||||||||||||||||
| 115 | if (i == -1
| 0 | ||||||||||||||||||
| 116 | break; never executed: break; | 0 | ||||||||||||||||||
| 117 | if (!value.isEmpty()
| 0 | ||||||||||||||||||
| 118 | value += ' '; never executed: value += ' '; | 0 | ||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | bool hasCR = (i
| 0 | ||||||||||||||||||
| 121 | int length = i -(hasCR
| 0 | ||||||||||||||||||
| 122 | value += der.mid(j, length).trimmed(); | - | ||||||||||||||||||
| 123 | j = ++i; | - | ||||||||||||||||||
| 124 | } never executed: while (i < der.count()end of block
| 0 | ||||||||||||||||||
| 125 | if (i == -1
| 0 | ||||||||||||||||||
| 126 | break; never executed: break; | 0 | ||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | headers->insert(field, value); | - | ||||||||||||||||||
| 129 | } never executed: end of block | 0 | ||||||||||||||||||
| 130 | der = der.mid(i); | - | ||||||||||||||||||
| 131 | } never executed: end of block | 0 | ||||||||||||||||||
| 132 | - | |||||||||||||||||||
| 133 | return executed 940 times by 2 tests: QByteArray::fromBase64(der);return QByteArray::fromBase64(der);Executed by:
executed 940 times by 2 tests: return QByteArray::fromBase64(der);Executed by:
| 940 | ||||||||||||||||||
| 134 | } | - | ||||||||||||||||||
| 135 | QSslKey::QSslKey(const QByteArray &encoded, QSsl::KeyAlgorithm algorithm, | - | ||||||||||||||||||
| 136 | QSsl::EncodingFormat encoding, QSsl::KeyType type, const QByteArray &passPhrase) | - | ||||||||||||||||||
| 137 | : d(new QSslKeyPrivate) | - | ||||||||||||||||||
| 138 | { | - | ||||||||||||||||||
| 139 | d->type = type; | - | ||||||||||||||||||
| 140 | d->algorithm = algorithm; | - | ||||||||||||||||||
| 141 | if (encoding == QSsl::Der
| 226-417 | ||||||||||||||||||
| 142 | d->decodeDer(encoded); executed 226 times by 2 tests: d->decodeDer(encoded);Executed by:
| 226 | ||||||||||||||||||
| 143 | else | - | ||||||||||||||||||
| 144 | d->decodePem(encoded, passPhrase); executed 417 times by 4 tests: d->decodePem(encoded, passPhrase);Executed by:
| 417 | ||||||||||||||||||
| 145 | } | - | ||||||||||||||||||
| 146 | QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::EncodingFormat encoding, | - | ||||||||||||||||||
| 147 | QSsl::KeyType type, const QByteArray &passPhrase) | - | ||||||||||||||||||
| 148 | : d(new QSslKeyPrivate) | - | ||||||||||||||||||
| 149 | { | - | ||||||||||||||||||
| 150 | QByteArray encoded; | - | ||||||||||||||||||
| 151 | if (device
| 0-16 | ||||||||||||||||||
| 152 | encoded = device->readAll(); executed 16 times by 2 tests: encoded = device->readAll();Executed by:
| 16 | ||||||||||||||||||
| 153 | d->type = type; | - | ||||||||||||||||||
| 154 | d->algorithm = algorithm; | - | ||||||||||||||||||
| 155 | if (encoding == QSsl::Der
| 0-16 | ||||||||||||||||||
| 156 | d->decodeDer(encoded); never executed: d->decodeDer(encoded); | 0 | ||||||||||||||||||
| 157 | else | - | ||||||||||||||||||
| 158 | d->decodePem(encoded, passPhrase); executed 16 times by 2 tests: d->decodePem(encoded, passPhrase);Executed by:
| 16 | ||||||||||||||||||
| 159 | } | - | ||||||||||||||||||
| 160 | QSslKey::QSslKey(Qt::HANDLE handle, QSsl::KeyType type) | - | ||||||||||||||||||
| 161 | : d(new QSslKeyPrivate) | - | ||||||||||||||||||
| 162 | { | - | ||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | d->opaque = reinterpret_cast<EVP_PKEY *>(handle); | - | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | d->algorithm = QSsl::Opaque; | - | ||||||||||||||||||
| 169 | d->type = type; | - | ||||||||||||||||||
| 170 | d->isNull = !d->opaque; | - | ||||||||||||||||||
| 171 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | QSslKey::QSslKey(const QSslKey &other) : d(other.d) | - | ||||||||||||||||||
| 177 | { | - | ||||||||||||||||||
| 178 | } executed 2828 times by 9 tests: end of blockExecuted by:
| 2828 | ||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | - | |||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | - | |||||||||||||||||||
| 183 | QSslKey::~QSslKey() | - | ||||||||||||||||||
| 184 | { | - | ||||||||||||||||||
| 185 | } | - | ||||||||||||||||||
| 186 | - | |||||||||||||||||||
| 187 | - | |||||||||||||||||||
| 188 | - | |||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | - | |||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | QSslKey &QSslKey::operator=(const QSslKey &other) | - | ||||||||||||||||||
| 194 | { | - | ||||||||||||||||||
| 195 | d = other.d; | - | ||||||||||||||||||
| 196 | return executed 805 times by 8 tests: *this;return *this;Executed by:
executed 805 times by 8 tests: return *this;Executed by:
| 805 | ||||||||||||||||||
| 197 | } | - | ||||||||||||||||||
| 198 | bool QSslKey::isNull() const | - | ||||||||||||||||||
| 199 | { | - | ||||||||||||||||||
| 200 | return executed 1418 times by 6 tests: d->isNull;return d->isNull;Executed by:
executed 1418 times by 6 tests: return d->isNull;Executed by:
| 1418 | ||||||||||||||||||
| 201 | } | - | ||||||||||||||||||
| 202 | - | |||||||||||||||||||
| 203 | - | |||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | void QSslKey::clear() | - | ||||||||||||||||||
| 209 | { | - | ||||||||||||||||||
| 210 | d = new QSslKeyPrivate; | - | ||||||||||||||||||
| 211 | } never executed: end of block | 0 | ||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | - | |||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | int QSslKey::length() const | - | ||||||||||||||||||
| 217 | { | - | ||||||||||||||||||
| 218 | return executed 745 times by 2 tests: d->length();return d->length();Executed by:
executed 745 times by 2 tests: return d->length();Executed by:
| 745 | ||||||||||||||||||
| 219 | } | - | ||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | - | |||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | - | |||||||||||||||||||
| 224 | QSsl::KeyType QSslKey::type() const | - | ||||||||||||||||||
| 225 | { | - | ||||||||||||||||||
| 226 | return executed 688 times by 2 tests: d->type;return d->type;Executed by:
executed 688 times by 2 tests: return d->type;Executed by:
| 688 | ||||||||||||||||||
| 227 | } | - | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | QSsl::KeyAlgorithm QSslKey::algorithm() const | - | ||||||||||||||||||
| 233 | { | - | ||||||||||||||||||
| 234 | return executed 1180 times by 4 tests: d->algorithm;return d->algorithm;Executed by:
executed 1180 times by 4 tests: return d->algorithm;Executed by:
| 1180 | ||||||||||||||||||
| 235 | } | - | ||||||||||||||||||
| 236 | - | |||||||||||||||||||
| 237 | - | |||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | - | |||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | QByteArray QSslKey::toDer(const QByteArray &passPhrase) const | - | ||||||||||||||||||
| 244 | { | - | ||||||||||||||||||
| 245 | if (d->isNull
| 0-1052 | ||||||||||||||||||
| 246 | return never executed: QByteArray();return QByteArray();never executed: return QByteArray(); | 0 | ||||||||||||||||||
| 247 | - | |||||||||||||||||||
| 248 | - | |||||||||||||||||||
| 249 | if (d->type == QSsl::PrivateKey
| 112-576 | ||||||||||||||||||
| 250 | return executed 112 times by 1 test: QByteArray();return QByteArray();Executed by:
executed 112 times by 1 test: return QByteArray();Executed by:
| 112 | ||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | QMap<QByteArray, QByteArray> headers; | - | ||||||||||||||||||
| 254 | return executed 940 times by 2 tests: d->derFromPem(toPem(passPhrase), &headers);return d->derFromPem(toPem(passPhrase), &headers);Executed by:
executed 940 times by 2 tests: return d->derFromPem(toPem(passPhrase), &headers);Executed by:
| 940 | ||||||||||||||||||
| 255 | - | |||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | } | - | ||||||||||||||||||
| 259 | - | |||||||||||||||||||
| 260 | - | |||||||||||||||||||
| 261 | - | |||||||||||||||||||
| 262 | - | |||||||||||||||||||
| 263 | - | |||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | QByteArray QSslKey::toPem(const QByteArray &passPhrase) const | - | ||||||||||||||||||
| 266 | { | - | ||||||||||||||||||
| 267 | return executed 1752 times by 2 tests: d->toPem(passPhrase);return d->toPem(passPhrase);Executed by:
executed 1752 times by 2 tests: return d->toPem(passPhrase);Executed by:
| 1752 | ||||||||||||||||||
| 268 | } | - | ||||||||||||||||||
| 269 | Qt::HANDLE QSslKey::handle() const | - | ||||||||||||||||||
| 270 | { | - | ||||||||||||||||||
| 271 | return executed 93 times by 2 tests: d->handle();return d->handle();Executed by:
executed 93 times by 2 tests: return d->handle();Executed by:
| 93 | ||||||||||||||||||
| 272 | } | - | ||||||||||||||||||
| 273 | - | |||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | - | |||||||||||||||||||
| 276 | - | |||||||||||||||||||
| 277 | bool QSslKey::operator==(const QSslKey &other) const | - | ||||||||||||||||||
| 278 | { | - | ||||||||||||||||||
| 279 | if (isNull()
| 84-232 | ||||||||||||||||||
| 280 | return executed 84 times by 4 tests: other.isNull();return other.isNull();Executed by:
executed 84 times by 4 tests: return other.isNull();Executed by:
| 84 | ||||||||||||||||||
| 281 | if (other.isNull()
| 0-232 | ||||||||||||||||||
| 282 | return never executed: isNull();return isNull();never executed: return isNull(); | 0 | ||||||||||||||||||
| 283 | if (algorithm() != other.algorithm()
| 0-232 | ||||||||||||||||||
| 284 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 285 | if (type() != other.type()
| 0-232 | ||||||||||||||||||
| 286 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 287 | if (length() != other.length()
| 0-232 | ||||||||||||||||||
| 288 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 289 | if (algorithm() == QSsl::Opaque
| 0-232 | ||||||||||||||||||
| 290 | return never executed: handle() == other.handle();return handle() == other.handle();never executed: return handle() == other.handle(); | 0 | ||||||||||||||||||
| 291 | return executed 232 times by 2 tests: toDer() == other.toDer();return toDer() == other.toDer();Executed by:
executed 232 times by 2 tests: return toDer() == other.toDer();Executed by:
| 232 | ||||||||||||||||||
| 292 | } | - | ||||||||||||||||||
| 293 | QDebug operator<<(QDebug debug, const QSslKey &key) | - | ||||||||||||||||||
| 294 | { | - | ||||||||||||||||||
| 295 | QDebugStateSaver saver(debug); | - | ||||||||||||||||||
| 296 | debug.resetFormat().nospace(); | - | ||||||||||||||||||
| 297 | debug << "QSslKey(" | - | ||||||||||||||||||
| 298 | << (key.type() == QSsl::PublicKey ? "PublicKey" : "PrivateKey") | - | ||||||||||||||||||
| 299 | << ", " << (key.algorithm() == QSsl::Opaque ? "OPAQUE" : | - | ||||||||||||||||||
| 300 | (key.algorithm() == QSsl::Rsa ? "RSA" : ((key.algorithm() == QSsl::Dsa) ? "DSA" : "EC"))) | - | ||||||||||||||||||
| 301 | << ", " << key.length() | - | ||||||||||||||||||
| 302 | << ')'; | - | ||||||||||||||||||
| 303 | return never executed: debug;return debug;never executed: return debug; | 0 | ||||||||||||||||||
| 304 | } | - | ||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | - | |||||||||||||||||||
| 307 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |