aboutsummaryrefslogtreecommitdiff
path: root/envelope/testsuite.sh
blob: f713cda7fc60c8c84f750f7c6b6e7f1f8a9dfa08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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" </dev/urandom >"$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