summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLars Schmertmann <Lars.Schmertmann@governikus.de>2016-07-13 08:42:33 +0200
committerAndré Klitzing <aklitzing@gmail.com>2018-11-23 22:58:05 +0000
commitde83447830b0941216f922a37b6cd36e703197d4 (patch)
treeb2c58b8fb086cc7a6b45252b56f2014732a9f9ba /tests
parent14144079709201929c97b9a5f0db406c27275baf (diff)
Add support for Diffie-Hellman keys to QSslKey
This is necessary to provide details for the key too, when the server is using DHE-RSA-AESxxx-SHAxxx. Amends 7f77dc84fb434f33ffe96f6633792706b80fb0a3. Change-Id: I8ab15b6987c17c857f54bc368df3c6c1818f428c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.derbin0 -> 293 bytes
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.pem9
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.derbin0 -> 554 bytes
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.pem14
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pri-512.derbin0 -> 159 bytes
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pri-512.pem6
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.derbin0 -> 291 bytes
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.pem9
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.derbin0 -> 552 bytes
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.pem14
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pub-512.derbin0 -> 157 bytes
-rw-r--r--tests/auto/network/ssl/qsslkey/keys/dh-pub-512.pem6
-rwxr-xr-xtests/auto/network/ssl/qsslkey/keys/genkeys.sh21
-rw-r--r--tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp5
14 files changed, 82 insertions, 2 deletions
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.der b/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.der
new file mode 100644
index 0000000000..687009e087
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.der
Binary files differ
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.pem
new file mode 100644
index 0000000000..233e0dfb37
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.pem
@@ -0,0 +1,9 @@
+-----BEGIN PRIVATE KEY-----
+MIIBIQIBADCBlQYJKoZIhvcNAQMBMIGHAoGBAIlk2YX0TJzfQ18ZzZroQoE5Nyjt
+bWxWRxBriG/c+JWhBwttVDb6lzLN+GVJxXVPfc6JJmDORVRxdxAlMqu++2Vqpsnl
+/H8xIXsxjuTcTjq8sXagGRa0LfeggkUD64tEhO4iZ8Q2TIdb3OHkAF0Sn+06b/0e
+iIz323Kywq0CsspTAgECBIGDAoGAQCo39UHP4s2ZVH4nOmWgNlb4JsHPX4EzqDBr
+ig46hvMLAFrILYnsCbqqD/+GNAUl1PV/nfEQoAk/HvtACqLFLG5/3jK2w6dVHGEo
+JnVOGz9vZpWUx+SCslHJRFaeE+6AAbbvrTr0lci29Ta4IesHlamRsj+ZaUrVX6k/
+/9OTGAo=
+-----END PRIVATE KEY-----
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.der b/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.der
new file mode 100644
index 0000000000..e193f25f07
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.der
Binary files differ
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.pem
new file mode 100644
index 0000000000..32299b2b6c
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.pem
@@ -0,0 +1,14 @@
+-----BEGIN PRIVATE KEY-----
+MIICJgIBADCCARcGCSqGSIb3DQEDATCCAQgCggEBAJsiReJxBjkC7Hy99AJATusq
+YsNQHhjoeTLPeHhsBuLtJK18Krk736V09efX6qeAEmvgMQbvbHqtrOaY3q6dut6C
+UTGVW+oVg3d/Y8qakkanvEnIlliaTIyWIz0JMjO2prC6AuU/QEzZcQVUS6bxyn3D
+iYFxCE6+7cJJpEH9HVbcrl+J6Ch6ax5rQGUyxpSMkmItLJx92upRxOnaxJMHR+ZF
+OSdDPfrkINpEzahnhteLszddyLasnE0or6ZnXYLvKsT1Uu6QwDc4EO1FJHScoeep
+zsK/VRcXzMpj/1Rl+F9E/AikCqHRrnvISt25wrK0Mwy854P2T7dJlBNewc6vE6MC
+AQIEggEEAoIBAGIctO30MoZ9DiuKbOBpqM9rl2bNH/I46GGcfEiSsO/zOw2V9WFC
+MxkjF0I1ilDfPY+Ag3bLB2n89DPcfXliYH9MFolehPTc1fWplhX3+ImdC6y95uXO
+FV5xtcEQCbPktnUtkUdcAT5831p9lu1QJo+DzMPrQa7axMLj8heBAi4VqAi+8Q31
+dpGKuhCUlgs+pLENx1o0QY2kui6Z5uR0YhmA547lwBWA4XEv5OV9ExmxytiatvOv
+PZKT1ID76LrL9bnnZvOEGczWLQvJ9VaaZSpoP+2QisRANWW4w57d+PIR1WR/FTSH
+F6xocElUoTzuiSPzRz60aw/KkisImBBKERQ=
+-----END PRIVATE KEY-----
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.der b/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.der
new file mode 100644
index 0000000000..42ddbaaae2
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.der
Binary files differ
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.pem
new file mode 100644
index 0000000000..d2c3170b16
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.pem
@@ -0,0 +1,6 @@
+-----BEGIN PRIVATE KEY-----
+MIGcAgEAMFMGCSqGSIb3DQEDATBGAkEAvXx0QxJvIGA2ig8Je55R2rmeO4Ta2Esj
+ANLuyVIFRbtuLFsdhU+amUc8bs9RUQmkUNzS92jkpAfqtCv+mQ06EwIBAgRCAkBJ
+rDM0BTevOPIHpJzMtSQhw3e7Dr38HUfTn8zF3uYi1RCxjkTUukmzRLPTf0aqPgpd
+8dSldjG/11aZORl8/mXO
+-----END PRIVATE KEY-----
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.der b/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.der
new file mode 100644
index 0000000000..2805a67633
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.der
Binary files differ
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.pem
new file mode 100644
index 0000000000..da4e327ac9
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.pem
@@ -0,0 +1,9 @@
+-----BEGIN PUBLIC KEY-----
+MIIBHzCBlQYJKoZIhvcNAQMBMIGHAoGBAIlk2YX0TJzfQ18ZzZroQoE5NyjtbWxW
+RxBriG/c+JWhBwttVDb6lzLN+GVJxXVPfc6JJmDORVRxdxAlMqu++2Vqpsnl/H8x
+IXsxjuTcTjq8sXagGRa0LfeggkUD64tEhO4iZ8Q2TIdb3OHkAF0Sn+06b/0eiIz3
+23Kywq0CsspTAgECA4GEAAKBgA8pxU1sMDvRWKpvJKNs3jNhZPQWFf4Tszu/cMcb
+1qAQ/q0DRb41VvsUoMaCfef/plZleV4MG26owb574AJeC86wX5MbRDTPS4CzAn+I
+an92AZl3vlYRQ2sSo3ktkyhw6LV1iewi08Ky7J4rqvG0Oo335QGEZlK1OgwBsyh0
+FKLe
+-----END PUBLIC KEY-----
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.der b/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.der
new file mode 100644
index 0000000000..9e749d8a41
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.der
Binary files differ
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.pem
new file mode 100644
index 0000000000..f751157c87
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.pem
@@ -0,0 +1,14 @@
+-----BEGIN PUBLIC KEY-----
+MIICJDCCARcGCSqGSIb3DQEDATCCAQgCggEBAJsiReJxBjkC7Hy99AJATusqYsNQ
+HhjoeTLPeHhsBuLtJK18Krk736V09efX6qeAEmvgMQbvbHqtrOaY3q6dut6CUTGV
+W+oVg3d/Y8qakkanvEnIlliaTIyWIz0JMjO2prC6AuU/QEzZcQVUS6bxyn3DiYFx
+CE6+7cJJpEH9HVbcrl+J6Ch6ax5rQGUyxpSMkmItLJx92upRxOnaxJMHR+ZFOSdD
+PfrkINpEzahnhteLszddyLasnE0or6ZnXYLvKsT1Uu6QwDc4EO1FJHScoeepzsK/
+VRcXzMpj/1Rl+F9E/AikCqHRrnvISt25wrK0Mwy854P2T7dJlBNewc6vE6MCAQID
+ggEFAAKCAQAUeWRuqjl7F84USogxJOM1M4y8yKtBYY2KLs5iIVhzV4UZ+9+cMNZA
+otLXJ/e8BH0diR0yk7tjxD6hjjqd+nyafIkJGPElDMnTbRPHg5zZYMmI5L/efdSm
+OPbM7QsodrYH5aoF4c7hjMb/cttYVG2Yupsy4tfORuDbwL70upqOo6rkVq55eOGS
+6pseEume/SD+7e3xIPJTkrMMzBFHG6H7bVHikT4O7yWV1iVzElj919yi+4Zy6TK8
+0hG6l31D5bsJpOduhHYZtN1yQpw+sGT6Yiepkjgt+1YkGFiiRs5vDl4DHeYHyAhL
+oH9uKcm3q4lhaOeT5ml765g87qQD6+vr
+-----END PUBLIC KEY-----
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.der b/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.der
new file mode 100644
index 0000000000..8a75babb6d
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.der
Binary files differ
diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.pem
new file mode 100644
index 0000000000..1f4e5c9a47
--- /dev/null
+++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.pem
@@ -0,0 +1,6 @@
+-----BEGIN PUBLIC KEY-----
+MIGaMFMGCSqGSIb3DQEDATBGAkEAvXx0QxJvIGA2ig8Je55R2rmeO4Ta2EsjANLu
+yVIFRbtuLFsdhU+amUc8bs9RUQmkUNzS92jkpAfqtCv+mQ06EwIBAgNDAAJARGBh
+9FmRRZZAxBtXZmS8wIgDwWvjB63GQ+E1pDLtZPztvPQ2eqUjTgSuGKV5cDankAV1
+Pkj/IA0Xl+SuFhLLew==
+-----END PUBLIC KEY-----
diff --git a/tests/auto/network/ssl/qsslkey/keys/genkeys.sh b/tests/auto/network/ssl/qsslkey/keys/genkeys.sh
index 6210b42ab4..0106953bff 100755
--- a/tests/auto/network/ssl/qsslkey/keys/genkeys.sh
+++ b/tests/auto/network/ssl/qsslkey/keys/genkeys.sh
@@ -88,6 +88,27 @@ do
openssl ec -in ec-pri-$size-$curve.pem -pubout -out ec-pub-$size-$curve.der -outform DER
done
+#--- DH ----------------------------------------------------------------------------
+for size in 512 1024 2048
+do
+ echo -e "\ngenerating DH parameters to PEM file ..."
+ openssl dhparam -out dhpar-$size.pem $size
+
+ echo -e "\ngenerating DH private key to PEM file ..."
+ openssl genpkey -paramfile dhpar-$size.pem -out dh-pri-$size.pem
+
+ /bin/rm dhpar-$size.pem
+
+ echo -e "\ngenerating DH private key to DER file ..."
+ openssl pkey -in dh-pri-$size.pem -out dh-pri-$size.der -outform DER
+
+ echo -e "\ngenerating DH public key to PEM file ..."
+ openssl pkey -in dh-pri-$size.pem -pubout -out dh-pub-$size.pem
+
+ echo -e "\ngenerating DH public key to DER file ..."
+ openssl pkey -in dh-pri-$size.pem -pubout -out dh-pub-$size.der -outform DER
+done
+
#--- PKCS#8 ------------------------------------------------------------------------
# Note: We'll just grab some of the keys generated earlier and convert those
# https://www.openssl.org/docs/manmaster/man1/pkcs8.html#PKCS-5-v1.5-and-PKCS-12-algorithms
diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
index ddfe52c5e4..a257becfd2 100644
--- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
+++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp
@@ -111,13 +111,14 @@ void tst_QSslKey::initTestCase()
QDir dir(testDataDir + "keys");
const QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Readable);
- QRegExp rx(QLatin1String("^(rsa|dsa|ec)-(pub|pri)-(\\d+)-?[\\w-]*\\.(pem|der)$"));
+ QRegExp rx(QLatin1String("^(rsa|dsa|dh|ec)-(pub|pri)-(\\d+)-?[\\w-]*\\.(pem|der)$"));
for (const QFileInfo &fileInfo : fileInfoList) {
if (rx.indexIn(fileInfo.fileName()) >= 0) {
keyInfoList << KeyInfo(
fileInfo,
rx.cap(1) == QLatin1String("rsa") ? QSsl::Rsa :
- (rx.cap(1) == QLatin1String("dsa") ? QSsl::Dsa : QSsl::Ec),
+ rx.cap(1) == QLatin1String("dsa") ? QSsl::Dsa :
+ rx.cap(1) == QLatin1String("dh") ? QSsl::Dh : QSsl::Ec,
rx.cap(2) == QLatin1String("pub") ? QSsl::PublicKey : QSsl::PrivateKey,
rx.cap(3).toInt(),
rx.cap(4) == QLatin1String("pem") ? QSsl::Pem : QSsl::Der);