aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-07-25 19:35:56 +0200
committerSven Gothel <[email protected]>2022-07-25 19:35:56 +0200
commitf6bc0d947f53b9125fa0866dca1f2fda08dd695b (patch)
treeeb7ca041de5acd9d4b413220ff6faf3386998b4d /scripts
parentccda67800bb963dfb8659cb78cd01144c3705970 (diff)
commandline cipherpack (native): Support pack, unpack and hash on fd pipe for streaming, add manual full test script.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/cipherpack15
-rwxr-xr-xscripts/test_cipherpack_cmdline.sh75
2 files changed, 86 insertions, 4 deletions
diff --git a/scripts/cipherpack b/scripts/cipherpack
index 70290df..09d4a07 100755
--- a/scripts/cipherpack
+++ b/scripts/cipherpack
@@ -1,14 +1,21 @@
#!/bin/bash
-export jau_debug=true
-export cipherpack_debug=true
+# export jau_debug=true
+# export cipherpack_debug=true
# export cipherpack_verbose=true
#
# ../scripts/cipherpack some_plaintext_file.bin
#
# Examples
-# scripts/cipherpack pack -epk test_keys/terminal_rsa1.pub.pem -ssk test_keys/host_rsa1 -out a.enc test_data_local/data-10kiB.bin
+# scripts/cipherpack pack -epk test_keys/terminal_rsa1.pub.pem -ssk test_keys/host_rsa1 -out a.enc plaintext.bin
# scripts/cipherpack unpack -spk test_keys/host_rsa1.pub.pem -dsk test_keys/terminal_rsa1 -out a.dec a.enc
+# scripts/cipherpack hash -out a.hash jaulib/test_data
+#
+# cat plaintext.bin | scripts/cipherpack pack -epk test_keys/terminal_rsa1.pub.pem -ssk test_keys/host_rsa1 > a.enc
+# cat a.enc | scripts/cipherpack unpack -spk test_keys/host_rsa1.pub.pem -dsk test_keys/terminal_rsa1 > a.dec
+# cat a.dec | scripts/run_cipherpack.sh hash jaulib/test_data
+#
+# cat plaintext.bin | scripts/cipherpack pack -epk test_keys/terminal_rsa1.pub.pem -ssk test_keys/host_rsa1 | scripts/cipherpack unpack -spk test_keys/host_rsa1.pub.pem -dsk test_keys/terminal_rsa1 > a.dec
#
sdir=`dirname $(readlink -f $0)`
@@ -31,5 +38,5 @@ export LC_MEASUREMENT=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
-#LD_LIBRARY_PATH=${dist_dir}/lib strace ${dist_dir}/bin/cipherpack $*
+#LD_LIBRARY_PATH=${dist_dir}/lib strace ${dist_dir}/bin/cipherpack "$@"
LD_LIBRARY_PATH=${dist_dir}/lib ${dist_dir}/bin/cipherpack $*
diff --git a/scripts/test_cipherpack_cmdline.sh b/scripts/test_cipherpack_cmdline.sh
new file mode 100755
index 0000000..e43aa8d
--- /dev/null
+++ b/scripts/test_cipherpack_cmdline.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+data_dir_in=../cipherpack_test_data_local
+
+sdir=`dirname $(readlink -f $0)`
+rootdir=`dirname $sdir`
+bname=`basename $0 .sh`
+
+. $rootdir/jaulib/scripts/setup-machine-arch.sh "-quiet"
+
+mkdir -p $rootdir/doc/test
+logfile=$rootdir/doc/test/$bname-$os_name-$archabi.log
+rm -f $logfile
+
+build_dir=$rootdir/"build-$os_name-$archabi"
+data_dir_out=${build_dir}/test_cipherpack_out
+rm -rf ${data_dir_out}
+mkdir -p ${data_dir_out}
+
+cmp_hash_value() {
+ hash1=`awk ' { print $1 } ' $1`
+ hash2=`awk ' { print $1 } ' $2`
+ if [ "$hash1" != "$hash2" ] ; then
+ echo "Hash mismatch $1 $2"
+ return 1
+ fi
+ return 0
+}
+
+run_test_file01() {
+ #scripts/cipherpack hash -out ${data_dir_out}/test_data_local.phash ${data_dir_in}
+ #if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+
+ scripts/cipherpack pack -epk test_keys/terminal_rsa1.pub.pem -ssk test_keys/host_rsa1 -hashout ${data_dir_out}/t1.orig.phash -out ${data_dir_out}/t1.enc ${data_dir_in}/data-10kiB.bin
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+ scripts/cipherpack unpack -spk test_keys/host_rsa1.pub.pem -dsk test_keys/terminal_rsa1 -hashout ${data_dir_out}/t1.dec.phash -out ${data_dir_out}/t1.dec ${data_dir_out}/t1.enc
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+ cmp ${data_dir_out}/t1.dec ${data_dir_in}/data-10kiB.bin
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+ cmp_hash_value ${data_dir_out}/t1.orig.phash ${data_dir_out}/t1.dec.phash
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+
+ scripts/cipherpack hash -out ${data_dir_out}/t1.dec2.phash ${data_dir_out}/t1.dec
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+ cmp_hash_value ${data_dir_out}/t1.dec.phash ${data_dir_out}/t1.dec2.phash
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+}
+
+run_test_pipe01() {
+ cat ${data_dir_in}/data-10kiB.bin | scripts/cipherpack pack -epk test_keys/terminal_rsa1.pub.pem -ssk test_keys/host_rsa1 -hashout ${data_dir_out}/t2.orig.phash > ${data_dir_out}/t2.enc
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+ cat ${data_dir_out}/t2.enc | scripts/cipherpack unpack -spk test_keys/host_rsa1.pub.pem -dsk test_keys/terminal_rsa1 -hashout ${data_dir_out}/t2.dec.phash > ${data_dir_out}/t2.dec
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+ cmp ${data_dir_out}/t2.dec ${data_dir_in}/data-10kiB.bin
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+ cmp_hash_value ${data_dir_out}/t2.orig.phash ${data_dir_out}/t2.dec.phash
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+
+ scripts/cipherpack hash -out ${data_dir_out}/t2.dec2.phash ${data_dir_out}/t2.dec
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+ cmp_hash_value ${data_dir_out}/t2.dec.phash ${data_dir_out}/t2.dec2.phash
+}
+
+run_test_pipe02() {
+ cat ${data_dir_in}/data-10kiB.bin | scripts/cipherpack pack -epk test_keys/terminal_rsa1.pub.pem -ssk test_keys/host_rsa1 -hashout ${data_dir_out}/t3.orig.phash | scripts/cipherpack unpack -spk test_keys/host_rsa1.pub.pem -dsk test_keys/terminal_rsa1 -hashout ${data_dir_out}/t3.dec.phash > ${data_dir_out}/t3.dec
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+ cmp ${data_dir_out}/t3.dec ${data_dir_in}/data-10kiB.bin
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+ cmp_hash_value ${data_dir_out}/t3.orig.phash ${data_dir_out}/t3.dec.phash
+ if [ $? -ne 0 ] ; then echo "ERROR test $LINENO"; return 1; fi
+}
+
+run_test_file01 2>&1 | tee $logfile
+run_test_pipe01 2>&1 | tee $logfile
+run_test_pipe02 2>&1 | tee $logfile