xref: /openbsd/regress/usr.bin/openssl/testenc.sh (revision 771fbea0)
1#!/bin/sh
2#	$OpenBSD: testenc.sh,v 1.2 2018/02/06 02:31:13 tb Exp $
3
4testsrc=$2/openssl.cnf
5test=$1/p
6cmd=${OPENSSL:-/usr/bin/openssl}
7
8cd $1
9
10cat $testsrc >$test;
11
12echo cat
13$cmd enc < $test > $test.cipher
14$cmd enc < $test.cipher >$test.clear
15cmp $test $test.clear
16if [ $? != 0 ]
17then
18	exit 1
19else
20	/bin/rm $test.cipher $test.clear
21fi
22echo base64
23$cmd enc -a -e < $test > $test.cipher
24$cmd enc -a -d < $test.cipher >$test.clear
25cmp $test $test.clear
26if [ $? != 0 ]
27then
28	exit 1
29else
30	/bin/rm $test.cipher $test.clear
31fi
32
33/bin/rm -f $test
34exit 0
35
36# These tests are now done by the makefile.
37
38for i in rc4 \
39	des-cfb des-ede-cfb des-ede3-cfb \
40	des-ofb des-ede-ofb des-ede3-ofb \
41	des-ecb des-ede des-ede3 desx \
42	des-cbc des-ede-cbc des-ede3-cbc \
43	rc2-ecb rc2-cfb rc2-ofb rc2-cbc \
44	bf-ecb bf-cfb bf-ofb bf-cbc rc4 \
45	cast5-ecb cast5-cfb cast5-ofb cast5-cbc
46do
47	echo $i
48	$cmd $i -bufsize 113 -e -k test < $test > $test.$i.cipher
49	$cmd $i -bufsize 157 -d -k test < $test.$i.cipher >$test.$i.clear
50	cmp $test $test.$i.clear
51	if [ $? != 0 ]
52	then
53		exit 1
54	else
55		/bin/rm $test.$i.cipher $test.$i.clear
56	fi
57
58	echo $i base64
59	$cmd $i -bufsize 113 -a -e -k test < $test > $test.$i.cipher
60	$cmd $i -bufsize 157 -a -d -k test < $test.$i.cipher >$test.$i.clear
61	cmp $test $test.$i.clear
62	if [ $? != 0 ]
63	then
64		exit 1
65	else
66		/bin/rm $test.$i.cipher $test.$i.clear
67	fi
68done
69rm -f $test
70