summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@kodafritt.se>2014-04-11 22:39:56 +0200
committerSamuel Lidén Borell <samuel@kodafritt.se>2014-04-11 22:39:56 +0200
commit313fd3a3653795e983e583dcbf0aa1c9867f61c4 (patch)
treea7feddf8899e45a36e499c5ffed70b752fbb61f9
parent7bd491c7a8f70e76e22c499b675d33eced1a4b7a (diff)
downloadfribid-313fd3a3653795e983e583dcbf0aa1c9867f61c4.tar.gz
fribid-313fd3a3653795e983e583dcbf0aa1c9867f61c4.tar.bz2
fribid-313fd3a3653795e983e583dcbf0aa1c9867f61c4.zip
Improve the test scripts and install them under <docdir>/fribid/examples
-rwxr-xr-xclient/sendreq.sh59
-rwxr-xr-xclient/testsign.sh44
-rwxr-xr-xconfigure11
-rw-r--r--doc/Makefile20
-rw-r--r--doc/examples/README16
-rw-r--r--doc/examples/README.sv15
-rw-r--r--doc/examples/common.sh159
-rwxr-xr-xdoc/examples/reqcert.sh73
-rwxr-xr-xdoc/examples/sign.sh62
-rw-r--r--doc/fribid.72
-rw-r--r--doc/fribid.sv.72
11 files changed, 359 insertions, 104 deletions
diff --git a/client/sendreq.sh b/client/sendreq.sh
deleted file mode 100755
index 768bd89..0000000
--- a/client/sendreq.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/sh
-
-sendint() { echo "$*;"; }
-sendstring() { echo "${#1};$1"; }
-
-CreateRequest() { sendint 4; }
-
-MoreData() { sendint 1; }
-EndOfData() { sendint 0; }
-
-
-{
-
-# Send command header
-CreateRequest
-sendstring 'https://example.com/' # URL
-sendstring 'example.com' # Hostname
-sendstring '198.51.100.200' # IP of example.com
-
-# Password policy
-sendint 12 # Minimum length
-sendint 4 # Minimum number of non-digits
-sendint 1 # Minimum number of digits
-
-# PKCS10
-MoreData
- sendint 1 # KeyUsage
- sendint 2048 # KeySize
- sendstring 'CN=TEST PERSON,OID.2.5.4.41=(090102 12.30) TEST PERSON - BankID på fil,SN=197711223334,G=TEST,S=PERSON' # SubjectDN
- sendint 0 # Include full DN
-MoreData
- sendint 2 # KeyUsage
- sendint 2048 # KeySize
- sendstring 'CN=TEST PERSON,OID.2.5.4.41=(090102 12.30) TEST PERSON - BankID på fil,SN=197711223334,G=TEST,S=PERSON' # SubjectDN
- sendint 1 # Include full DN
-EndOfData
-
-# CMC
-sendstring 'Not Applicable'
-sendstring true
-
-# Prevent EOF
-echo 'hack'
-
-
-} | valgrind --leak-check=no -q ./sign --internal--ipc=10 | tr ';' '\n' | {
-#} | ./sign --internal--ipc=10 | tr ';' '\n' | {
-
-#### Parse response ####
-read error
-read requestLength
-read request
-sha="`echo $request | sha1sum | head -c 5`"
-
-echo "error=$error, length=$requestLength, sha1=$sha"
-echo "$request" | base64 -d > test/output.p7
-
-}
-
diff --git a/client/testsign.sh b/client/testsign.sh
deleted file mode 100755
index d466824..0000000
--- a/client/testsign.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-
-sendint() { echo "$*;"; }
-sendstring() { echo "${#1};$1"; }
-
-SignCommand() { sendint 3; }
-
-
-{
-
-# Send command header
-SignCommand
-sendstring 'https://example.com/' # URL
-sendstring 'example.com' # Hostname
-sendstring '198.51.100.200' # IP of example.com
-
-# Send common data
-sendstring 'MTIzNDU2Nzg5' # nonce
-sendint 0 # server time (optional)
-sendstring '' # policies (optional)
-sendstring '' # subject filter (optional)
-
-# Send data to be signed
-sendstring 'UTF-8' # message encoding
-sendstring 'aGkK' # visible message
-sendstring '' # hidden data (optional)
-
-# Prevent EOF
-echo 'hack'
-
-} | valgrind --leak-check=no -q ./sign --internal--ipc=10 | tr ';' '\n' | {
-#} | ./sign --internal--ipc=10 | tr ';' '\n' | {
-
-#### Parse response ####
-read error
-read sigLength
-read signature
-sha="`echo $signature | sha1sum | head -c 5`"
-
-echo "error=$error, length=$requestLength, sha1=$sha"
-echo "$signature" | base64 -d > test/signature.xml
-
-}
-
diff --git a/configure b/configure
index 2e70f8b..53a3412 100755
--- a/configure
+++ b/configure
@@ -43,6 +43,7 @@ fi
libdir=""
libexecdir=""
datadir=""
+docdir=""
localedir=""
mandir=""
@@ -106,6 +107,8 @@ Options:
--libexecdir=PATH Sets the directory for internal executables. [LIBDIR]
--datadir=PATH Sets the directory for architecture-independent
data. [PREFIX/share]
+ --docdir=PATH Sets the directory for documentation and test
+ scripts. [DATADIR/doc]
--localedir=PATH Sets the directory for translations [DATADIR/locale]
--mandir=PATH Sets the directory for man pages. [DATADIR/man]
--plugin-path=PATH Sets the NPAPI plugin path [$pluginPaths]
@@ -138,6 +141,9 @@ Options:
--datadir=*)
datadir=${flag#--datadir=}
;;
+ --docdir=*)
+ docdir=${flag#--docdir=}
+ ;;
--localedir=*)
localedir=${flag#--localedir=}
;;
@@ -277,6 +283,10 @@ if [ -z "$datadir" ]; then
datadir="$prefixPath/share"
fi
+if [ -z "$docdir" ]; then
+ docdir="$datadir/doc"
+fi
+
if [ -z "$localedir" ]; then
localedir="$datadir/locale"
fi
@@ -438,6 +448,7 @@ cat <<EOT >"$CONFFILE"
#define LIBDIR "$libdir"
#define LIBEXECDIR "$libexecdir"
#define DATADIR "$datadir"
+#define DOCDIR "$docdir"
#define LOCALEDIR "$localedir"
#define MANDIR "$mandir"
diff --git a/doc/Makefile b/doc/Makefile
index 3e40878..84e7220 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2010 Samuel Lidén Borell <samuel@kodafritt.se>
+# Copyright (c) 2010-2014 Samuel Lidén Borell <samuel@kodafritt.se>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -22,6 +22,7 @@
MANDIR=`../configure --internal--get-define=MANDIR`
+DOCDIR=`../configure --internal--get-define=DOCDIR`
LANGUAGES=sv
@@ -29,18 +30,35 @@ all:
clean:
install: all
+ # Man page
install -d $(DESTDIR)$(MANDIR)/man7
gzip -n -c9 fribid.7 > $(DESTDIR)$(MANDIR)/man7/fribid.7.gz
+ # Localization
for lang in $(LANGUAGES); do \
install -d $(DESTDIR)$(MANDIR)/$$lang/man7 && \
gzip -n -c9 fribid.$$lang.7 > $(DESTDIR)$(MANDIR)/$$lang/man7/fribid.7.gz || exit 1; \
done
+ # Test scripts
+ install -d $(DOCDIR)/fribid
+ install -d $(DOCDIR)/fribid/examples
+ install -m 644 examples/README $(DESTDIR)$(DOCDIR)/fribid/examples/
+ install -m 644 examples/README.sv $(DESTDIR)$(DOCDIR)/fribid/examples/
+ install -m 644 examples/common.sh $(DESTDIR)$(DOCDIR)/fribid/examples/
+ install -m 755 examples/sign.sh $(DESTDIR)$(DOCDIR)/fribid/examples/
+ install -m 755 examples/reqcert.sh $(DESTDIR)$(DOCDIR)/fribid/examples/
uninstall:
rm -f $(DESTDIR)$(MANDIR)/man7/fribid.7.gz
for lang in $(LANGUAGES); do \
rm -f $(DESTDIR)$(MANDIR)/$$lang/man7/fribid.7.gz || exit 1; \
done
+ rm -f $(DESTDIR)$(DOCDIR)/fribid/examples/README
+ rm -f $(DESTDIR)$(DOCDIR)/fribid/examples/README.sv
+ rm -f $(DESTDIR)$(DOCDIR)/fribid/examples/common.sh
+ rm -f $(DESTDIR)$(DOCDIR)/fribid/examples/sign.sh
+ rm -f $(DESTDIR)$(DOCDIR)/fribid/examples/reqcert.sh
+ [ ! -d $(DESTDIR)$(DOCDIR)/fribid/examples ] || rmdir $(DESTDIR)$(DOCDIR)/fribid/examples
+ [ ! -d $(DESTDIR)$(DOCDIR)/fribid ] || rmdir $(DESTDIR)$(DOCDIR)/fribid
.PHONY: all clean install uninstall
diff --git a/doc/examples/README b/doc/examples/README
new file mode 100644
index 0000000..6c1ab10
--- /dev/null
+++ b/doc/examples/README
@@ -0,0 +1,16 @@
+This directory contains scripts that can be used for testing that FriBID
+works properly. The scripts do not check the validity of certificates
+and can't generate valid certificates, only test certificates. The
+following scripts are available:
+
+
+sign.sh - This script tests signature generation. You need to to have a
+certificate to successfully run this test, but even if you don't have
+any certificate you should still get a certificate selection and
+password entry dialog.
+
+reqcert.sh - This script tests a "certificate request", which is the
+first step of getting a certificate. You should get window where you can
+choose a password, and after running the script you should have a test
+file in "~/cbt". The second step can currently not be tested with these
+scripts.
diff --git a/doc/examples/README.sv b/doc/examples/README.sv
new file mode 100644
index 0000000..9842113
--- /dev/null
+++ b/doc/examples/README.sv
@@ -0,0 +1,15 @@
+Denna katalog innehåller testskript som kan användas för att testa att
+FriBID fungerar korrekt. Skripten kontrollerar dock inte giltigheten hos
+certifikaten, och kan inte heller skapa giltiga certifikat, utan enbart
+testcertifikat. Följande skript finns tillgängliga:
+
+sign.sh - Detta skript testar skapande av signaturer. Du behöver ha ett
+certifikat (en e-legitimation) för att köra testet, men oavsett så ska
+det dyka upp ett fönster där man får välja certifikat och ange lösenord
+när man kör skriptet.
+
+reqcert.sh - Detta skript testar en "certifikatförfrågan", vilket är det
+första steget vid hämtning av en e-legitimation. Du bör få upp ett
+fönster där du får välja ett lösenord, och efter att ha kört testet ska
+det dyka upp en testfil i "~/cbt". Det andra steget vid hämtning av en
+e-legitimation kan för närvarande inte testas med dessa skript.
diff --git a/doc/examples/common.sh b/doc/examples/common.sh
new file mode 100644
index 0000000..89c86a5
--- /dev/null
+++ b/doc/examples/common.sh
@@ -0,0 +1,159 @@
+#!/bin/sh
+#
+# Copyright (c) 2014 Samuel Lidén Borell <samuel@kodafritt.se>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+# Defaults
+multiarch="`gcc -print-multiarch 2>/dev/null`"
+if ( [ ! -h /usr/lib64 ] && [ -f /usr/lib64/libc.so ] && [ ! -d /usr/lib32 ] ) ||
+ ( [ ! -h /lib64 ] && [ -f /lib64/libc.so.6 ] && [ ! -d /usr/lib32 ] ); then
+ # RedHat etc.
+ multilib="lib64"
+elif [ -n "$multiarch" ]; then
+ # New Debian with multiarch
+ multilib="lib/$multiarch"
+else
+ # Old Debian and 32-bit RedHat
+ multilib="lib"
+fi
+
+if [ -x "/usr/local/$multilib/fribid/sign" ]; then
+ path="/usr/local/$multilib/fribid"
+elif [ -x "/usr/$multilib/fribid/sign" ]; then
+ path="/usr/$multilib/fribid"
+else
+ path=""
+fi
+
+mode=normal
+output=""
+fuzz_seed=""
+
+# Parse command line
+
+while [ "$#" -gt 0 ]; do
+ opt="$1"
+ case "$opt" in
+ --valgrind|-V)
+ mode=valgrind;;
+ --valgrind-zzuf-p12|--valgrind-zzuf-pkcs12|-P)
+ mode=valgrind-zzuf-pkcs12;;
+ --valgrind-zzuf-x509|-X)
+ mode=valgrind-zzuf-x509;;
+ -o)
+ output="$2"
+ shift;;
+ -s)
+ fuzz_seed="$2"
+ shift;;
+ --help|-h)
+ cat <<EOF
+Usage: $0 [options] [fribid-lib-path]
+
+Options:
+ --valgrind, -V
+ Run FriBID under Valgrind, but without leak checking.
+ --valgrind-zzuf-pkcs12, -P
+ Run FriBID under zzuf (a fuzzer) and fuzz PKCS#12 input.
+ --valgrind-zzuf-x509, -P
+ Run FriBID under zzuf (a fuzzer) and fuzz X509 input.
+ Applicable to the "storecerts" command only.
+ -o FILE
+ Write signature or request output to the given file.
+ -s NUMBER
+ Seed number to pass to fuzzer's psuedo-random generator.
+ --help, -h
+ Show this help text.
+
+The path is autodetected by default to /usr/lib/fribid or similar. If you
+want to run FriBID from the source tree, you can specify the path to the
+"client" directory.
+
+EOF
+ exit 0;;
+ --)
+ break;;
+ -*)
+ echo "$0: invalid option: $1" >&2
+ exit 1;;
+ *)
+ path="$1";;
+ esac
+ shift
+done
+
+while [ "$#" -gt 0 ]; do
+ path="$1"
+done
+
+# Check options
+if [ -z "$path" ]; then
+ echo "Couldn't find the fribid \"sign\" executable. Please specify the path manually!" >&2
+ exit 1
+fi
+
+if [ -z "$fuzz_seed" ]; then
+ fuzz_seed=0
+elif [ "x$mode" != "xvalgrind-zzuf-pkcs12" -a "x$mode" != "xvalgrind-zzuf-x509" ]; then
+ echo "The fuzz seed option can only be used with the zzuf options." >&2
+ exit 1
+fi
+
+
+# IPC commands
+sendint() { echo "$*;"; }
+sendstring() { echo "${#1};$1"; }
+
+SignCommand() { sendint 3; }
+CreateRequest() { sendint 4; }
+StoreCertsCommand() { sendint 5; }
+
+MoreData() { sendint 1; }
+EndOfData() { sendint 0; }
+
+# Runs the FriBID executable
+run() {
+ exe="$1"
+ shift
+ case "$mode" in
+ valgrind|valgrind-zzuf-x509)
+ valgrind --leak-check=no -q "$path/$exe" $*;;
+ valgrind-zzuf-pkcs12)
+ valgrind --leak-check=no -q --trace-children=yes zzuf -s "$zzuf_seed" -I '.*\.[pP]12' "$path/$exe" $*;;
+ normal)
+ "$path/$exe" $*;;
+ esac
+}
+
+shorthash() {
+ if [ -z "$1" ]; then
+ # Empty string
+ echo "<empty>"
+ elif which sha1sum > /dev/null 2>&1; then
+ # Linux
+ echo "$1" | sha1sum | head -c 5
+ elif which sha1 > /dev/null 2>&1; then
+ # BSD
+ echo "$1" | sha1
+ else
+ echo "<command not available>"
+ fi
+}
diff --git a/doc/examples/reqcert.sh b/doc/examples/reqcert.sh
new file mode 100755
index 0000000..a255c75
--- /dev/null
+++ b/doc/examples/reqcert.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+#
+# Copyright (c) 2014 Samuel Lidén Borell <samuel@kodafritt.se>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+. "`dirname "$0"`/common.sh"
+
+{
+
+# Send command header
+CreateRequest
+sendstring 'https://example.com/' # URL
+sendstring 'example.com' # Hostname
+sendstring '198.51.100.200' # IP of example.com
+
+# Password policy
+sendint 12 # Minimum length
+sendint 4 # Minimum number of non-digits
+sendint 1 # Minimum number of digits
+
+# PKCS10
+MoreData
+ sendint 1 # KeyUsage
+ sendint 2048 # KeySize
+ sendstring 'CN=TEST PERSON,OID.2.5.4.41=(090102 12.30) TEST PERSON - BankID på fil,SN=197711223334,G=TEST,S=PERSON' # SubjectDN
+ sendint 0 # Include full DN
+MoreData
+ sendint 2 # KeyUsage
+ sendint 2048 # KeySize
+ sendstring 'CN=TEST PERSON,OID.2.5.4.41=(090102 12.30) TEST PERSON - BankID på fil,SN=197711223334,G=TEST,S=PERSON' # SubjectDN
+ sendint 1 # Include full DN
+EndOfData
+
+# CMC
+sendstring 'Not Applicable'
+sendstring true
+
+# Prevent EOF
+echo 'hack'
+
+} | run sign --internal--ipc=10 | tr ';' '\n' | {
+
+#### Parse response ####
+read error
+read requestLength
+read request
+sha="`shorthash $request`"
+
+echo "error=$error, length=$requestLength, sha1=$sha"
+if [ -n "$output" ]; then
+ echo "$request" | base64 -d > "$output"
+fi
+
+}
+
diff --git a/doc/examples/sign.sh b/doc/examples/sign.sh
new file mode 100755
index 0000000..d0a0790
--- /dev/null
+++ b/doc/examples/sign.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# Copyright (c) 2014 Samuel Lidén Borell <samuel@kodafritt.se>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+. "`dirname "$0"`/common.sh"
+
+{
+
+# Send command header
+SignCommand
+sendstring 'https://example.com/' # URL
+sendstring 'example.com' # Hostname
+sendstring '198.51.100.200' # IP of example.com
+
+# Send common data
+sendstring 'MTIzNDU2Nzg5' # nonce
+sendint 0 # server time (optional)
+sendstring '' # policies (optional)
+sendstring '' # subject filter (optional)
+
+# Send data to be signed
+sendstring 'UTF-8' # message encoding
+sendstring 'VGVzdAo=' # visible message
+sendstring '' # hidden data (optional)
+
+# Prevent EOF
+echo 'hack'
+
+} | run sign --internal--ipc=10 | tr ';' '\n' | {
+
+#### Parse response ####
+read error
+read sigLength
+read signature
+sha="`shorthash $signature`"
+
+echo "error=$error, length=$sigLength, sha1=$sha"
+if [ -n "$output" ]; then
+ echo "$signature" | base64 -d > "$output"
+fi
+
+}
+
diff --git a/doc/fribid.7 b/doc/fribid.7
index 0825637..1a0913e 100644
--- a/doc/fribid.7
+++ b/doc/fribid.7
@@ -70,6 +70,8 @@ version-to-emulate=4.19.0.11351
FriBID will start automatically when you visit a web page that uses BankID for the log in system or to sign information. You can check that FriBID works on this page:
.LP
https://fribid.se/test/
+.LP
+If the web site above would not work for some reason (e.g. in case the browser plugin is not working), there are also test scripts that can be run from the terminal in /usr/share/doc/fribid/examples/, /usr/local/share/doc/fribid/examples/ or an equivalent directory. If the scripts work but the web site does not, then there's very likely a problem with either the plugin or the browser.
.SH NOTES
FriBID is
diff --git a/doc/fribid.sv.7 b/doc/fribid.sv.7
index aa2c960..08dfb8c 100644
--- a/doc/fribid.sv.7
+++ b/doc/fribid.sv.7
@@ -71,6 +71,8 @@ version-to-emulate=4.19.0.11351
FriBID startas automatiskt när du besöker en webbsida som använder BankID för inloggning eller signering. Du kan testa att FriBID fungerar på denna sida:
.LP
https://fribid.se/test/
+.LP
+Om webbsidan ovan mot förmodan inte skulle fungera (t.ex. ifall webbläsarpluginen inte fungerar), så finns det även testskript man kan köra från terminalen i /usr/share/doc/fribid/examples/, /usr/local/share/doc/fribid/examples/ eller motsvarande katalog. Om enbart skripten fungerar men inte webbsidan gör det, så är det antagligen ett problem med pluginen eller webbläsaren.
.SH VIKTIGT
FriBID är