summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2007-02-05 12:12:21 +0000
committerSimon Josefsson <simon@josefsson.org>2007-02-05 12:12:21 +0000
commit2f331ae08ee815589b7a977213b1a8fa18d87055 (patch)
treedb20e021c7e7ddd08626f615f578103e3a74a99b /tests
parent6edab51d0f41f77145042729b41c364886950a97 (diff)
downloadgnutls-2f331ae08ee815589b7a977213b1a8fa18d87055.tar.gz
Add.
Diffstat (limited to 'tests')
-rw-r--r--tests/sha2/Makefile.am26
-rw-r--r--tests/sha2/key-ca.pem15
-rw-r--r--tests/sha2/key-subca.pem15
-rw-r--r--tests/sha2/key-subsubca.pem9
-rw-r--r--tests/sha2/key-user.pem15
-rwxr-xr-xtests/sha2/sha278
6 files changed, 158 insertions, 0 deletions
diff --git a/tests/sha2/Makefile.am b/tests/sha2/Makefile.am
new file mode 100644
index 0000000000..2d4ca9c3ec
--- /dev/null
+++ b/tests/sha2/Makefile.am
@@ -0,0 +1,26 @@
+## Process this file with automake to produce Makefile.in
+# Copyright (C) 2007 Free Software Foundation
+#
+# Author: Simon Josefsson
+#
+# This file is part of GNUTLS.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this file; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+EXTRA_DIST = key-ca.pem key-subca.pem key-subsubca.pem key-user.pem
+
+dist_check_SCRIPTS = sha2
+
+TESTS = sha2
diff --git a/tests/sha2/key-ca.pem b/tests/sha2/key-ca.pem
new file mode 100644
index 0000000000..885c32c9ec
--- /dev/null
+++ b/tests/sha2/key-ca.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICWwIBAAKBgQDAD806NPtYz+Yqr61SH8+zh+TU3vcrnxMlXME+W/dFjdD/tbmV
+c3rwZdqd3I0X0MRWZF1THNFtKW5jvHnOkHb4M85RPu/L/a1/ktuuk2xPk38DgEn5
+NEwST/kDaLtp56HuZTryUvR7dDfXBLp5biy+y/iZ1/srxrs59UfGVeWEewIDAQAB
+AoGAASQ25okpE0KNDiTkJVBOFjWRDRjUJDy6SucNuPan9hBdNR/Z3gMFMIeScIy+
+g+04NYE8MsHBluH/p3UXzjv6kQVuUzSx2Tqu8KjUjbWoAlhusxr9vqJGPPMoC8A8
+8Ubbl4TJFoZXEWmlGZPe00zSJhtYmwY4fYvZkohLyu1LYA0CQQDTozWT5yZ1jRd9
+cDJQ29bdaEPA8UFnLwqkuWL1iRNfeFFICW3wPQPukX6ImIszWsn7aXvtmT2qsu3e
+XQlUiZFnAkEA6FIf7WFs/K19mGbbwJz1TJH1hErVXXbtHplnFRUUm/dqQe3x3Y/d
+lb6EilPFDikW/sF7XBPexN5PdlVlNG0jzQJALaBlH6LY3sTxSIDUyCvtEcS1vrYE
+hKtWnxa8p/TKcW2uEFrAEegFnfxODELe18599y7RofLEobV7pNHn/gq+hwJAZdrj
+rpKBUwLJRtEJ1Ze7IDf5+WdJxnGGolzFSgP1BjBiQMeOvAIAN0/REkiJ45x2PXkc
+mZEIoS2Kjyn/dg3HnQJARXgQ+9fs/UemybHUzl/ywIyYgODebSaV+gOKs41QJtM4
+eP8ajeKtIn3jLsODnlEqkD9Dl2pOHtpz6T/PJM7kMA==
+-----END RSA PRIVATE KEY-----
diff --git a/tests/sha2/key-subca.pem b/tests/sha2/key-subca.pem
new file mode 100644
index 0000000000..bf782b5e53
--- /dev/null
+++ b/tests/sha2/key-subca.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXAIBAAKBgQCs10rMBAozD8bi/KN5HG1HfD5SDePcffzzQAqnw/RdCOOtTDk5
+CfuJOu0xvtxSBj1LnF4F5lQYFKdIn59+efk2V1iCmpmtONzNMUdOxStIYbMH1zfo
+8G5Q+jdEqA3GpqnZHTfKYQRtqce2NfUSL5EjOdcQeW9TF4i3+hhyf7+OFwIDAQAB
+AoGAAyaBAi7BHNa1VeYPaoViA6aNiupz5gX4FrBOek13SgNG6Va8cvIKoq8oK2y7
+gjkDjwEl3SQcLkraFNgE4hssmx9nnzjS0PL+SSVxaUssQEOLfqwRL7DjSVuqN3lG
++DwA88o2jZcUeYk0KMfPh4BXndRoxSl+NLIXqUM0mDKAD/kCQQDPdoC/Na3hb3dR
+783T6Dv/Wip3FJOTgQW00JPo7z/VRWD26O4Gcu7QyWp7cE1jTJBmmFGk99UwhaQj
+dqorPuYbAkEA1UcxH4IAVbW9p4zsFtC62VCOOVTXnwJi2ukyV98sSpoQ8BxHd1fD
+TcimvlVjUP44elisS69KNvFnkLQmfDZntQJAZYhvliTlRnFRCi68ozsDMgOkyMav
+Ov9oFYgG+3cr3Gqp++0foNRbAJ+yl1rs5O4xtaRSQNRx599f52NKAQQ1hQJAOtTe
+ihB0QzBU1oka/tgpEpUUBmCO8f/YgQZeqrqXHyUMkw9Z72O4LhaxWEN5l/foYGdh
+b6c0058XsGThUNY5GQJBAIqgWAWIayeIOdIRY4jVGjbCeF3TK+KkBE9i+wPXPg/r
+togrwce4wYHadBHNeyYnKiIikqc7Lp9dMcvITWyCk2s=
+-----END RSA PRIVATE KEY-----
diff --git a/tests/sha2/key-subsubca.pem b/tests/sha2/key-subsubca.pem
new file mode 100644
index 0000000000..fca7c9d1d2
--- /dev/null
+++ b/tests/sha2/key-subsubca.pem
@@ -0,0 +1,9 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIBOQIBAAJBALsQ5pEpMchi/O8d7+qvAwH19OcTzvszd29dbva83gcydAMAh243
+a6d+6NsakKliKqsNpPvhg3o7/J9vnGWJq7UCAwEAAQJAGKXpL3LNWbE7URlxeYt+
+WrWJA6KPSPeW0uBthMrNeYaRXU8W17aYQ99yYe5K4fRrBA0B92XAlTn8alrxrPXk
+UQIhANH6YN5FXdj2tqdayyoF1ExXuedwLxOUF8cwEfZxH44RAiEA5BD0nxuoyKtZ
+y4OYfbfjyIHL4UljLeZ+wgzkxB1pr2UCIDm6nps9cvnNipYkTir1g1Kh48iPfUHi
+u07WFnosy8IhAiAtdIus4pBjXnOJMnNEK1CE+AmwnzXbQiNlfbhithIIWQIgJNOP
+k0WdX6yK471z5Sfl3T+9fsA5p0qgyNVF0qf18TY=
+-----END RSA PRIVATE KEY-----
diff --git a/tests/sha2/key-user.pem b/tests/sha2/key-user.pem
new file mode 100644
index 0000000000..6b3b30d837
--- /dev/null
+++ b/tests/sha2/key-user.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICWwIBAAKBgQC88r7u5NXiSE352QYT9V9FjaLHtr22D9o+Yp+U7QFs453YBCS8
+zJOTnTONQGr74YWDbYvTPc/biFtTeGaV0tRdIdqYCi7v21koCE7Wx2ZLQRckFt7z
+ks5e+AaKuPVfiE5Hxpg8TQdGruaIZ56+p/fboFv4M52r+iWjhvhn7zOQ5QIDAQAB
+AoGAAtx1W7S6ls41fN6pouYiTTFTd7OJGxd39iqtwL/3nfVMaWSWq20406sCIgkJ
+r0q/Wzm7b+inTx6F4E7m1S0q6tkK19SktgIuza4ZyMoKvGwG8I2Y/PkHBqV0kSg5
+WQZDqoIrPdWvAgZxpfJaCcLsJ1xTG+A7JsCyerDpWw+lm/kCQQDO6vRLy/4cTjvR
+7E8dCwf4mzOzGyx8pTPRXEFdjtqrUODmr/C5XfQXKmAxMMYU8WQT9UBP5PmgKv7x
+EOGS9CLTAkEA6cSXzblzbLLWuSd8Qb87WPOwe7f4gf0XAldFiqG79eKvJWo0BL2E
+x0iyRek/NszrnEYPdPI53xQUspPZeXt6ZwJAUkp+/eYTGY7Dm6kvjY1ljimrVf/o
+oWnSQeE+3caCkL+JsjUmt5H2EYB44RdUr9+QvZ88BIo7/MccvSLJk3gkoQJAdTes
+3u1k4VZzsPgJqHYZbisTjZXcOGIODZBxQGiE9XCrXll4p//X+o2LRt8EYZgzdHL1
+ATEMr71D+5+DZxTxdQJAHN+23/N2giXF1Ls3w4uetxRwLmkNGnpgD0/o+9Kh56xO
+hd6hDqJLqGixQFVpF13l1vEg8R/r5JjhYt8E3JMtlA==
+-----END RSA PRIVATE KEY-----
diff --git a/tests/sha2/sha2 b/tests/sha2/sha2
new file mode 100755
index 0000000000..39ed1744f9
--- /dev/null
+++ b/tests/sha2/sha2
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# Copyright (C) 2006, 2007 Free Software Foundation
+#
+# Author: Simon Josefsson
+#
+# This file is part of GNUTLS.
+#
+# GNUTLS is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at
+# your option) any later version.
+#
+# GNUTLS is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNUTLS; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+set -e
+
+srcdir=${srcdir:-.}
+CERTTOOL=${CERTTOOL:-../../src/certtool}
+
+echo ca > template
+echo cn = "SHA 512 CA" >> template
+
+$CERTTOOL --generate-self-signed --template template \
+ --load-privkey $srcdir/key-ca.pem \
+ --outfile new-ca.pem \
+ --hash sha512
+
+echo ca > template
+echo cn = "SHA 384 sub-CA" >> template
+
+$CERTTOOL --generate-certificate --template template \
+ --load-ca-privkey $srcdir/key-ca.pem \
+ --load-ca-certificate new-ca.pem \
+ --load-privkey $srcdir/key-subca.pem \
+ --outfile new-subca.pem \
+ --hash sha384
+
+echo ca > template
+echo cn = "SHA 256 sub-sub-CA" >> template
+
+$CERTTOOL --generate-certificate --template template \
+ --load-ca-privkey $srcdir/key-subca.pem \
+ --load-ca-certificate new-subca.pem \
+ --load-privkey $srcdir/key-subsubca.pem \
+ --outfile new-subsubca.pem \
+ --hash sha256
+
+echo ca > template
+echo cn = "End-user" >> template
+
+$CERTTOOL --generate-certificate --template template \
+ --load-ca-privkey $srcdir/key-subsubca.pem \
+ --load-ca-certificate new-subsubca.pem \
+ --load-privkey $srcdir/key-user.pem \
+ --outfile new-user.pem
+
+
+num=`cat new-user.pem new-subsubca.pem new-subca.pem new-ca.pem | $CERTTOOL --verify-chain | tee verify | grep -c Verified`
+cat verify
+
+if test "$num" != "4"; then
+ echo Verification failure
+ exit 1
+else
+ echo Test OK
+fi
+
+rm -f verify new-user.pem new-subsubca.pem new-subca.pem new-ca.pem template
+
+exit 0