diff options
| -rw-r--r-- | src/regress/lib/libcrypto/sha2/Makefile | 4 | ||||
| -rw-r--r-- | src/regress/usr.bin/openssl/Makefile | 58 | ||||
| -rw-r--r-- | src/regress/usr.bin/openssl/README | 6 | ||||
| -rw-r--r-- | src/regress/usr.bin/openssl/openssl.cnf | 29 | ||||
| -rw-r--r-- | src/regress/usr.bin/openssl/test_client.sh | 12 | ||||
| -rw-r--r-- | src/regress/usr.bin/openssl/test_server.sh | 10 | ||||
| -rw-r--r-- | src/regress/usr.bin/openssl/testdsa.sh | 29 | ||||
| -rw-r--r-- | src/regress/usr.bin/openssl/testenc.sh | 69 | ||||
| -rw-r--r-- | src/regress/usr.bin/openssl/testrsa.sh | 29 |
9 files changed, 244 insertions, 2 deletions
diff --git a/src/regress/lib/libcrypto/sha2/Makefile b/src/regress/lib/libcrypto/sha2/Makefile index 2edf10b0f4..e2bbb02d15 100644 --- a/src/regress/lib/libcrypto/sha2/Makefile +++ b/src/regress/lib/libcrypto/sha2/Makefile | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2014/05/02 19:27:06 miod Exp $ | 1 | # $OpenBSD: Makefile,v 1.2 2014/08/26 17:50:07 jsing Exp $ |
| 2 | 2 | ||
| 3 | REGRESS_TARGETS=regress-sha2 | 3 | REGRESS_TARGETS=regress-sha2 |
| 4 | OPENSSL=/usr/sbin/openssl | 4 | OPENSSL=/usr/bin/openssl |
| 5 | 5 | ||
| 6 | HASHES= \ | 6 | HASHES= \ |
| 7 | sha224 \ | 7 | sha224 \ |
diff --git a/src/regress/usr.bin/openssl/Makefile b/src/regress/usr.bin/openssl/Makefile new file mode 100644 index 0000000000..800e2fd061 --- /dev/null +++ b/src/regress/usr.bin/openssl/Makefile | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2014/08/26 17:50:07 jsing Exp $ | ||
| 2 | |||
| 3 | CLEANFILES+= testdsa.key testdsa.pem rsakey.pem rsacert.pem dsa512.pem | ||
| 4 | |||
| 5 | REGRESS_TARGETS=ssl-enc ssl-dsa ssl-rsa | ||
| 6 | |||
| 7 | OPENSSL=/usr/bin/openssl | ||
| 8 | CLEAR1=p | ||
| 9 | CIPHER=cipher | ||
| 10 | CLEAR2=clear | ||
| 11 | LIBCRYPTO=-lcrypto | ||
| 12 | |||
| 13 | ${CLEAR1}: openssl.cnf | ||
| 14 | cat ${.CURDIR}/openssl.cnf > ${CLEAR1} | ||
| 15 | |||
| 16 | CLEANFILES+=${CLEAR1} | ||
| 17 | |||
| 18 | ENCTARGETS=aes-128-cbc aes-128-cfb aes-128-cfb1 aes-128-cfb8 | ||
| 19 | ENCTARGETS+=aes-128-ecb aes-128-ofb aes-192-cbc aes-192-cfb | ||
| 20 | ENCTARGETS+=aes-192-cfb1 aes-192-cfb8 aes-192-ecb aes-192-ofb | ||
| 21 | ENCTARGETS+=aes-256-cbc aes-256-cfb aes-256-cfb1 aes-256-cfb8 | ||
| 22 | ENCTARGETS+=aes-256-ecb aes-256-ofb | ||
| 23 | ENCTARGETS+=bf-cbc bf-cfb bf-ecb bf-ofb | ||
| 24 | ENCTARGETS+=cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb | ||
| 25 | ENCTARGETS+=des-cbc des-cfb des-cfb8 des-ecb des-ede | ||
| 26 | ENCTARGETS+=des-ede-cbc des-ede-cfb des-ede-ofb des-ede3 | ||
| 27 | ENCTARGETS+=des-ede3-cbc des-ede3-cfb des-ede3-ofb des-ofb desx-cbc | ||
| 28 | ENCTARGETS+=rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb | ||
| 29 | ENCTARGETS+=rc4 rc4-40 | ||
| 30 | |||
| 31 | .for ENC in ${ENCTARGETS} | ||
| 32 | ${CIPHER}.${ENC}: ${CLEAR1} | ||
| 33 | ${OPENSSL} enc -${ENC} -bufsize 113 -e -k test < ${CLEAR1} > ${CIPHER}.${ENC} | ||
| 34 | ${CIPHER}.${ENC}.b64: ${CLEAR1} | ||
| 35 | ${OPENSSL} enc -${ENC} -bufsize 113 -a -e -k test < ${CLEAR1} > ${CIPHER}.${ENC}.b64 | ||
| 36 | |||
| 37 | ${CLEAR2}.${ENC}: ${CIPHER}.${ENC} | ||
| 38 | ${OPENSSL} enc -${ENC} -bufsize 157 -d -k test < ${CIPHER}.${ENC} > ${CLEAR2}.${ENC} | ||
| 39 | ${CLEAR2}.${ENC}.b64: ${CIPHER}.${ENC}.b64 | ||
| 40 | ${OPENSSL} enc -${ENC} -bufsize 157 -a -d -k test < ${CIPHER}.${ENC}.b64 > ${CLEAR2}.${ENC}.b64 | ||
| 41 | |||
| 42 | ssl-enc-${ENC}: ${CLEAR1} ${CLEAR2}.${ENC} | ||
| 43 | cmp ${CLEAR1} ${CLEAR2}.${ENC} | ||
| 44 | ssl-enc-${ENC}.b64: ${CLEAR1} ${CLEAR2}.${ENC}.b64 | ||
| 45 | cmp ${CLEAR1} ${CLEAR2}.${ENC}.b64 | ||
| 46 | |||
| 47 | REGRESS_TARGETS+=ssl-enc-${ENC} ssl-enc-${ENC}.b64 | ||
| 48 | CLEANFILES+=${CIPHER}.${ENC} ${CIPHER}.${ENC}.b64 ${CLEAR2}.${ENC} ${CLEAR2}.${ENC}.b64 .rnd | ||
| 49 | .endfor | ||
| 50 | |||
| 51 | ssl-enc: | ||
| 52 | sh ${.CURDIR}/testenc.sh ${.OBJDIR} ${.CURDIR} | ||
| 53 | ssl-dsa: | ||
| 54 | sh ${.CURDIR}/testdsa.sh ${.OBJDIR} ${.CURDIR} | ||
| 55 | ssl-rsa: | ||
| 56 | sh ${.CURDIR}/testrsa.sh ${.OBJDIR} ${.CURDIR} | ||
| 57 | |||
| 58 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/usr.bin/openssl/README b/src/regress/usr.bin/openssl/README new file mode 100644 index 0000000000..878feca400 --- /dev/null +++ b/src/regress/usr.bin/openssl/README | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | testenc.sh tests encryption routines | ||
| 2 | testdsa.sh tests DSA certificate generation | ||
| 3 | test_server.sh starts a tls1 server using the above generated certificate | ||
| 4 | test_client.sh starts a client to talk to the server. | ||
| 5 | testrsa.sh tests RSA certificate generation | ||
| 6 | |||
diff --git a/src/regress/usr.bin/openssl/openssl.cnf b/src/regress/usr.bin/openssl/openssl.cnf new file mode 100644 index 0000000000..8e1eeb7f16 --- /dev/null +++ b/src/regress/usr.bin/openssl/openssl.cnf | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | # $OpenBSD: openssl.cnf,v 1.1 2014/08/26 17:50:07 jsing Exp $ | ||
| 2 | |||
| 3 | # | ||
| 4 | # SSLeay example configuration file. | ||
| 5 | # This is mostly being used for generation of certificate requests. | ||
| 6 | # | ||
| 7 | # hacked by iang to do DSA certs - Server | ||
| 8 | |||
| 9 | RANDFILE = ./.rnd | ||
| 10 | |||
| 11 | #################################################################### | ||
| 12 | [ req ] | ||
| 13 | distinguished_name = req_distinguished_name | ||
| 14 | encrypt_rsa_key = no | ||
| 15 | |||
| 16 | [ req_distinguished_name ] | ||
| 17 | countryName = Country Name (2 letter code) | ||
| 18 | countryName_default = CA | ||
| 19 | countryName_value = CA | ||
| 20 | |||
| 21 | organizationName = Organization Name (eg, company) | ||
| 22 | organizationName_value = Shake it Vera | ||
| 23 | |||
| 24 | 0.commonName = Common Name (eg, YOUR name) | ||
| 25 | 0.commonName_value = Wastelandus | ||
| 26 | |||
| 27 | 1.commonName = Common Name (eg, YOUR name) | ||
| 28 | 1.commonName_value = Maximus | ||
| 29 | |||
diff --git a/src/regress/usr.bin/openssl/test_client.sh b/src/regress/usr.bin/openssl/test_client.sh new file mode 100644 index 0000000000..36c6ac4add --- /dev/null +++ b/src/regress/usr.bin/openssl/test_client.sh | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # $OpenBSD: test_client.sh,v 1.1 2014/08/26 17:50:07 jsing Exp $ | ||
| 3 | |||
| 4 | echo | ||
| 5 | echo This starts a tls1 mode client to talk to the server run by | ||
| 6 | echo ./testserver.sh. You should start the server first. | ||
| 7 | echo | ||
| 8 | echo type in this window after ssl negotiation and your output should | ||
| 9 | echo be echoed by the server. | ||
| 10 | echo | ||
| 11 | echo | ||
| 12 | /usr/bin/openssl s_client -tls1 | ||
diff --git a/src/regress/usr.bin/openssl/test_server.sh b/src/regress/usr.bin/openssl/test_server.sh new file mode 100644 index 0000000000..b4fd2560df --- /dev/null +++ b/src/regress/usr.bin/openssl/test_server.sh | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # $OpenBSD: test_server.sh,v 1.1 2014/08/26 17:50:07 jsing Exp $ | ||
| 3 | |||
| 4 | echo This starts a tls1 mode server using the DSA certificate in ./server.pem | ||
| 5 | echo Run ./testclient.sh in another window and type at it, you should | ||
| 6 | echo see the results of the ssl negotiation, and stuff you type in the client | ||
| 7 | echo should echo in this window | ||
| 8 | echo | ||
| 9 | echo | ||
| 10 | /usr/bin/openssl s_server -tls1 -key testdsa.key -cert testdsa.pem | ||
diff --git a/src/regress/usr.bin/openssl/testdsa.sh b/src/regress/usr.bin/openssl/testdsa.sh new file mode 100644 index 0000000000..32293d8ff3 --- /dev/null +++ b/src/regress/usr.bin/openssl/testdsa.sh | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # $OpenBSD: testdsa.sh,v 1.1 2014/08/26 17:50:07 jsing Exp $ | ||
| 3 | |||
| 4 | |||
| 5 | #Test DSA certificate generation of openssl | ||
| 6 | |||
| 7 | cd $1 | ||
| 8 | |||
| 9 | # Generate DSA paramter set | ||
| 10 | openssl dsaparam 512 -out dsa512.pem | ||
| 11 | if [ $? != 0 ]; then | ||
| 12 | exit 1; | ||
| 13 | fi | ||
| 14 | |||
| 15 | |||
| 16 | # Denerate a DSA certificate | ||
| 17 | openssl req -config $2/openssl.cnf -x509 -newkey dsa:dsa512.pem -out testdsa.pem -keyout testdsa.key | ||
| 18 | if [ $? != 0 ]; then | ||
| 19 | exit 1; | ||
| 20 | fi | ||
| 21 | |||
| 22 | |||
| 23 | # Now check the certificate | ||
| 24 | openssl x509 -text -in testdsa.pem | ||
| 25 | if [ $? != 0 ]; then | ||
| 26 | exit 1; | ||
| 27 | fi | ||
| 28 | |||
| 29 | exit 0 | ||
diff --git a/src/regress/usr.bin/openssl/testenc.sh b/src/regress/usr.bin/openssl/testenc.sh new file mode 100644 index 0000000000..72c87a87a9 --- /dev/null +++ b/src/regress/usr.bin/openssl/testenc.sh | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # $OpenBSD: testenc.sh,v 1.1 2014/08/26 17:50:07 jsing Exp $ | ||
| 3 | |||
| 4 | testsrc=$2/openssl.cnf | ||
| 5 | test=$1/p | ||
| 6 | cmd=/usr/bin/openssl | ||
| 7 | |||
| 8 | cd $1 | ||
| 9 | |||
| 10 | cat $testsrc >$test; | ||
| 11 | |||
| 12 | echo cat | ||
| 13 | $cmd enc < $test > $test.cipher | ||
| 14 | $cmd enc < $test.cipher >$test.clear | ||
| 15 | cmp $test $test.clear | ||
| 16 | if [ $? != 0 ] | ||
| 17 | then | ||
| 18 | exit 1 | ||
| 19 | else | ||
| 20 | /bin/rm $test.cipher $test.clear | ||
| 21 | fi | ||
| 22 | echo base64 | ||
| 23 | $cmd enc -a -e < $test > $test.cipher | ||
| 24 | $cmd enc -a -d < $test.cipher >$test.clear | ||
| 25 | cmp $test $test.clear | ||
| 26 | if [ $? != 0 ] | ||
| 27 | then | ||
| 28 | exit 1 | ||
| 29 | else | ||
| 30 | /bin/rm $test.cipher $test.clear | ||
| 31 | fi | ||
| 32 | |||
| 33 | /bin/rm -f $test | ||
| 34 | exit 0 | ||
| 35 | |||
| 36 | # These tests are now done by the makefile. | ||
| 37 | |||
| 38 | for 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 | ||
| 46 | do | ||
| 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 | ||
| 68 | done | ||
| 69 | rm -f $test | ||
diff --git a/src/regress/usr.bin/openssl/testrsa.sh b/src/regress/usr.bin/openssl/testrsa.sh new file mode 100644 index 0000000000..a9a00f295e --- /dev/null +++ b/src/regress/usr.bin/openssl/testrsa.sh | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # $OpenBSD: testrsa.sh,v 1.1 2014/08/26 17:50:07 jsing Exp $ | ||
| 3 | |||
| 4 | |||
| 5 | #Test RSA certificate generation of openssl | ||
| 6 | |||
| 7 | cd $1 | ||
| 8 | |||
| 9 | # Generate RSA private key | ||
| 10 | openssl genrsa -out rsakey.pem | ||
| 11 | if [ $? != 0 ]; then | ||
| 12 | exit 1; | ||
| 13 | fi | ||
| 14 | |||
| 15 | |||
| 16 | # Generate an RSA certificate | ||
| 17 | openssl req -config $2/openssl.cnf -key rsakey.pem -new -x509 -days 365 -out rsacert.pem | ||
| 18 | if [ $? != 0 ]; then | ||
| 19 | exit 1; | ||
| 20 | fi | ||
| 21 | |||
| 22 | |||
| 23 | # Now check the certificate | ||
| 24 | openssl x509 -text -in rsacert.pem | ||
| 25 | if [ $? != 0 ]; then | ||
| 26 | exit 1; | ||
| 27 | fi | ||
| 28 | |||
| 29 | exit 0 | ||
