From 30c143c1d037b1a01ce69edd1b533878a959e8ff Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 9 Oct 2016 10:34:25 +0200 Subject: Bugfixes and debugging --- envelope/.gitignore | 1 + envelope/Makefile | 7 +++++-- envelope/envelope | Bin 116616 -> 116616 bytes envelope/main.cpp | 1 + envelope/testsuite.sh | 30 ++++++++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 envelope/.gitignore create mode 100755 envelope/testsuite.sh (limited to 'envelope') diff --git a/envelope/.gitignore b/envelope/.gitignore new file mode 100644 index 0000000..68a39b8 --- /dev/null +++ b/envelope/.gitignore @@ -0,0 +1 @@ +.input.testsuite diff --git a/envelope/Makefile b/envelope/Makefile index 06b0419..19e92ed 100644 --- a/envelope/Makefile +++ b/envelope/Makefile @@ -13,9 +13,12 @@ endif BIN = envelope -.PHONY: all clean remake +.PHONY: all clean remake makelib -all: $(BIN) +makelib: + make -C .. + +all: makelib $(BIN) clean: rm -rf $(BIN) *.o *.dSYM diff --git a/envelope/envelope b/envelope/envelope index 50b479f..5582c01 100755 Binary files a/envelope/envelope and b/envelope/envelope differ diff --git a/envelope/main.cpp b/envelope/main.cpp index 49b41ff..f0e544e 100644 --- a/envelope/main.cpp +++ b/envelope/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "../base64.h" #include "../envelope.h" diff --git a/envelope/testsuite.sh b/envelope/testsuite.sh new file mode 100755 index 0000000..f713cda --- /dev/null +++ b/envelope/testsuite.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +make -C .. +make + +set -o pipefail + +function dotest() { + len="$1" + keylen="$2" + printf "\x1B[31;1mlen=$len keylen=$keylen\x1B[0m\n" + fname=".input.testsuite" + head -c "$len" "$fname" + keys="$(./envelope -k "$keylen")" + pubkey="$(echo "$keys" | head -1 | tr -d $'\n')" + privkey="$(echo "$keys" | tail -1 | tr -d $'\n')" + if ! diff "$fname" <(./envelope -e "$pubkey" <"$fname" | ./envelope -d "$privkey"); then + printf "\x1B[31;1m -- ERROR --\x1B[0m\n" + echo "pubkey = $pubkey" + echo "privkey = $privkey" + echo "data = $(base64 <"$fname")" + exit 1 + fi +} + +for keylen in 512 1024 2048; do + for len in 1 10 15 16 17 12345; do + dotest "$len" "$keylen" + done +done -- cgit v1.2.3-70-g09d2