diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2018-10-16 12:30:02 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2018-12-04 14:26:52 +0000 |
commit | 37f773a754cd8c6a9ce05a67ae2a59cea4b4cc4a (patch) | |
tree | 0b56c513d046e6c400bc34a1779341cf08a95ef4 /src | |
parent | f5cfc36e3e47d59ebce8f6b8c6d75b2724e985c7 (diff) |
_q_makePkcs12: clean up
Remove braces for single-line bodies, space around binary operators
Change-Id: I958396772966428dcd9694279175fd61d6109b40
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/network/ssl/qsslsocket_qt.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/network/ssl/qsslsocket_qt.cpp b/src/network/ssl/qsslsocket_qt.cpp index 2c78f0f4e7..da865c476c 100644 --- a/src/network/ssl/qsslsocket_qt.cpp +++ b/src/network/ssl/qsslsocket_qt.cpp @@ -92,14 +92,12 @@ static QByteArray _q_PKCS12_keygen(char id, const QByteArray &salt, const QStrin QByteArray S, P; const int sSize = v * ((salt.size() + v - 1) / v); S.resize(sSize); - for (int i = 0; i < sSize; ++i) { + for (int i = 0; i < sSize; ++i) S[i] = salt[i % salt.size()]; - } const int pSize = v * ((passUnicode.size() + v - 1) / v); P.resize(pSize); - for (int i = 0; i < pSize; ++i) { + for (int i = 0; i < pSize; ++i) P[i] = passUnicode[i % passUnicode.size()]; - } QByteArray I = S + P; // apply hashing @@ -117,16 +115,15 @@ static QByteArray _q_PKCS12_keygen(char id, const QByteArray &salt, const QStrin Ai = hash.result(); } - for (int j = 0; j < v; ++j) { + for (int j = 0; j < v; ++j) B[j] = Ai[j % u]; - } // modify I as Ij = (Ij + B + 1) modulo 2^v for (int p = 0; p < I.size(); p += v) { quint8 carry = 1; for (int j = v - 1; j >= 0; --j) { - quint16 v = quint8(I[p+j]) + quint8(B[j]) + carry; - I[p+j] = v & 0xff; + quint16 v = quint8(I[p + j]) + quint8(B[j]) + carry; + I[p + j] = v & 0xff; carry = (v & 0xff00) >> 8; } } @@ -139,9 +136,8 @@ static QByteArray _q_PKCS12_salt() { QByteArray salt; salt.resize(8); - for (int i = 0; i < salt.size(); ++i) { + for (int i = 0; i < salt.size(); ++i) salt[i] = (qrand() & 0xff); - } return salt; } @@ -203,7 +199,7 @@ static QByteArray _q_PKCS12_shroudedKeyBag(const QSslKey &key, const QString &pa QDataStream plainStream(&plain, QIODevice::WriteOnly); _q_PKCS12_key(key).write(plainStream); QByteArray crypted = QSslKeyPrivate::encrypt(QSslKeyPrivate::DesEde3Cbc, - plain, cKey, cIv); + plain, cKey, cIv); QVector<QAsn1Element> items; items << QAsn1Element::fromObjectId("1.2.840.113549.1.12.10.1.2"); |