diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/CA/Makefile | 106 | ||||
| -rwxr-xr-x | src/regress/lib/libcrypto/CA/doit.sh | 116 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/CA/intermediate.cnf | 9 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/CA/root.cnf | 7 | ||||
| -rw-r--r-- | src/regress/lib/libcrypto/Makefile | 3 |
5 files changed, 100 insertions, 141 deletions
diff --git a/src/regress/lib/libcrypto/CA/Makefile b/src/regress/lib/libcrypto/CA/Makefile index c31c99c946..3e445d2de0 100644 --- a/src/regress/lib/libcrypto/CA/Makefile +++ b/src/regress/lib/libcrypto/CA/Makefile | |||
| @@ -1,21 +1,97 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2017/01/25 10:29:34 beck Exp $ | 1 | # $OpenBSD: Makefile,v 1.2 2020/12/26 00:48:56 bluhm Exp $ |
| 2 | 2 | ||
| 3 | TESTS = \ | 3 | CLEANFILES += *.pem *.serial *.txt *.attr *.old |
| 4 | doit.sh | ||
| 5 | 4 | ||
| 6 | REGRESS_TARGETS= all_tests | 5 | REGRESS_SETUP_ONCE += root.serial intermediate.serial |
| 6 | root.serial intermediate.serial: | ||
| 7 | echo 1000 >$@ | ||
| 7 | 8 | ||
| 8 | CLEANFILES += \ | 9 | REGRESS_SETUP_ONCE += root.txt intermediate.txt |
| 9 | 1000.pem client.cert.pem intermediate.cert.pem root.cert.pem server.csr.pem \ | 10 | root.txt intermediate.txt: |
| 10 | 1001.pem client.csr.pem intermediate.csr.pem root.key.pem server.key.pem \ | 11 | true >$@ |
| 11 | chain.pem client.key.pem intermediate.key.pem server.cert.pem \ | ||
| 12 | int.txt int.txt.attr int.txt.old int.txt.attr.old \ | ||
| 13 | root.txt root.txt.attr root.txt.old root.txt.attr.old \ | ||
| 14 | intserial rootserial intserial.old rootserial.old | ||
| 15 | 12 | ||
| 16 | all_tests: ${TESTS} | 13 | # Vanna Vanna make me a root cert |
| 17 | @for test in $>; do \ | 14 | root.key.pem: |
| 18 | ./$$test; \ | 15 | # generate root rsa 4096 key |
| 19 | done | 16 | openssl genrsa -out root.key.pem 4096 |
| 17 | |||
| 18 | root.cert.pem: root.cnf root.key.pem | ||
| 19 | # generate root req | ||
| 20 | openssl req -batch -config ${.CURDIR}/root.cnf -key root.key.pem \ | ||
| 21 | -new -x509 -days 365 -sha256 -extensions v3_ca -out root.cert.pem | ||
| 22 | |||
| 23 | # Make intermediate | ||
| 24 | intermediate.key.pem: | ||
| 25 | # generate intermediate rsa 2048 key | ||
| 26 | openssl genrsa -out intermediate.key.pem 2048 | ||
| 27 | |||
| 28 | intermediate.csr.pem: intermediate.cnf intermediate.key.pem | ||
| 29 | # generate intermediate req | ||
| 30 | openssl req -batch -config ${.CURDIR}/intermediate.cnf -new -sha256 \ | ||
| 31 | -key intermediate.key.pem -out intermediate.csr.pem | ||
| 32 | |||
| 33 | # Sign intermediate | ||
| 34 | intermediate.cert.pem: root.cnf root.cert.pem intermediate.csr.pem | ||
| 35 | # sign intermediate | ||
| 36 | openssl ca -batch -config ${.CURDIR}/root.cnf \ | ||
| 37 | -extensions v3_intermediate_ca -days 10 -notext -md sha256 \ | ||
| 38 | -in intermediate.csr.pem -out intermediate.cert.pem | ||
| 39 | |||
| 40 | REGRESS_TARGETS += run-verify-intermediate | ||
| 41 | # Verify Intermediate | ||
| 42 | run-verify-intermediate: root.cert.pem intermediate.cert.pem | ||
| 43 | # validate intermediate CA | ||
| 44 | openssl verify -CAfile root.cert.pem intermediate.cert.pem | ||
| 45 | |||
| 46 | chain.pem: intermediate.cert.pem root.cert.pem | ||
| 47 | cat intermediate.cert.pem root.cert.pem > chain.pem | ||
| 48 | |||
| 49 | # Make a server certificate | ||
| 50 | server.key.pem: | ||
| 51 | # genrsa server | ||
| 52 | openssl genrsa -out server.key.pem 2048 | ||
| 53 | |||
| 54 | server.csr.pem: intermediate.cnf server.key.pem | ||
| 55 | # server req | ||
| 56 | openssl req -batch -config ${.CURDIR}/intermediate.cnf -new -sha256 \ | ||
| 57 | -subj '/CN=server/O=OpenBSD/OU=So and Sos/C=CA' \ | ||
| 58 | -key server.key.pem -out server.csr.pem | ||
| 59 | |||
| 60 | # Sign server key | ||
| 61 | server.cert.pem: intermediate.cnf intermediate.cert.pem server.csr.pem | ||
| 62 | # server sign | ||
| 63 | openssl ca -batch -config ${.CURDIR}/intermediate.cnf \ | ||
| 64 | -extensions server_cert -days 5 -notext -md sha256 \ | ||
| 65 | -in server.csr.pem -out server.cert.pem | ||
| 66 | |||
| 67 | # Make a client certificate | ||
| 68 | client.key.pem: | ||
| 69 | # genrsa client | ||
| 70 | openssl genrsa -out client.key.pem 2048 | ||
| 71 | |||
| 72 | client.csr.pem: intermediate.cnf intermediate.cert.pem client.key.pem | ||
| 73 | # client req | ||
| 74 | openssl req -batch -config ${.CURDIR}/intermediate.cnf -new -sha256 \ | ||
| 75 | -subj '/CN=client/O=OpenBSD/OU=So and Sos/C=CA' \ | ||
| 76 | -key client.key.pem -out client.csr.pem | ||
| 77 | |||
| 78 | # Sign client key | ||
| 79 | client.cert.pem: intermediate.cnf intermediate.txt client.csr.pem | ||
| 80 | # client sign | ||
| 81 | openssl ca -batch -config ${.CURDIR}/intermediate.cnf \ | ||
| 82 | -extensions usr_cert -days 5 -notext -md sha256 \ | ||
| 83 | -in client.csr.pem -out client.cert.pem | ||
| 84 | |||
| 85 | REGRESS_TARGETS += run-verify-server | ||
| 86 | # Verify Intermediate | ||
| 87 | run-verify-server: chain.pem server.cert.pem | ||
| 88 | # validate server cert | ||
| 89 | openssl verify -purpose sslserver -CAfile chain.pem server.cert.pem | ||
| 90 | |||
| 91 | REGRESS_TARGETS += run-verify-client | ||
| 92 | # Verify Intermediate | ||
| 93 | run-verify-client: chain.pem client.cert.pem | ||
| 94 | # validate client cert | ||
| 95 | openssl verify -purpose sslclient -CAfile chain.pem client.cert.pem | ||
| 20 | 96 | ||
| 21 | .include <bsd.regress.mk> | 97 | .include <bsd.regress.mk> |
diff --git a/src/regress/lib/libcrypto/CA/doit.sh b/src/regress/lib/libcrypto/CA/doit.sh deleted file mode 100755 index 110d89d67f..0000000000 --- a/src/regress/lib/libcrypto/CA/doit.sh +++ /dev/null | |||
| @@ -1,116 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # $OpenBSD: doit.sh,v 1.2 2018/07/17 17:06:49 tb Exp $ | ||
| 3 | |||
| 4 | rm -rf root intermediate certs | ||
| 5 | echo 1000 > rootserial | ||
| 6 | cat /dev/null > root.txt | ||
| 7 | echo 1000 > intserial | ||
| 8 | cat /dev/null > int.txt | ||
| 9 | |||
| 10 | # Vanna Vanna make me a root cert | ||
| 11 | openssl genrsa -out root.key.pem 4096 | ||
| 12 | if [ $? -ne 0 ]; then | ||
| 13 | echo "*** Fail; Can't generate root rsa 4096 key" | ||
| 14 | exit 1 | ||
| 15 | fi | ||
| 16 | |||
| 17 | openssl req -batch -config root.cnf -key root.key.pem -new -x509 -days 365 -sha256 -extensions v3_ca -out root.cert.pem | ||
| 18 | if [ $? -ne 0 ]; then | ||
| 19 | echo "*** Fail; Can't generate root req" | ||
| 20 | exit 1 | ||
| 21 | fi | ||
| 22 | |||
| 23 | # Make intermediate | ||
| 24 | openssl genrsa -out intermediate.key.pem 2048 | ||
| 25 | if [ $? -ne 0 ]; then | ||
| 26 | echo "*** Fail; Can't generate intermediate rsa 2048 key" | ||
| 27 | exit 1 | ||
| 28 | fi | ||
| 29 | |||
| 30 | openssl req -batch -config intermediate.cnf -new -sha256 \ | ||
| 31 | -key intermediate.key.pem \ | ||
| 32 | -out intermediate.csr.pem | ||
| 33 | if [ $? -ne 0 ]; then | ||
| 34 | echo "*** Fail; Can't generate intermediate req" | ||
| 35 | exit 1 | ||
| 36 | fi | ||
| 37 | |||
| 38 | # Sign intermediate | ||
| 39 | openssl ca -batch -config root.cnf -extensions v3_intermediate_ca -days 10 -notext -md sha256 -in intermediate.csr.pem -out intermediate.cert.pem | ||
| 40 | if [ $? -ne 0 ]; then | ||
| 41 | echo "*** Fail; Can't sign intermediate" | ||
| 42 | exit 1 | ||
| 43 | fi | ||
| 44 | |||
| 45 | # Verify Intermediate | ||
| 46 | openssl verify -CAfile ca.cert.pem intermediate.cert.pem | ||
| 47 | if [ $? -ne 0]; then | ||
| 48 | echo "*** Fail; Intermediate CA does not validate" | ||
| 49 | exit 1 | ||
| 50 | fi | ||
| 51 | |||
| 52 | cat intermediate.cert.pem root.cert.pem > chain.pem | ||
| 53 | |||
| 54 | # make a server certificate | ||
| 55 | |||
| 56 | openssl genrsa -out server.key.pem 2048 | ||
| 57 | if [ $? -ne 0]; then | ||
| 58 | echo "*** Fail; genrsa server" | ||
| 59 | exit 1 | ||
| 60 | fi | ||
| 61 | |||
| 62 | |||
| 63 | openssl req -batch -config intermediate.cnf \ | ||
| 64 | -key server.key.pem \ | ||
| 65 | -new -sha256 -out server.csr.pem \ | ||
| 66 | -subj '/CN=server/O=OpenBSD/OU=So and Sos/C=CA' | ||
| 67 | if [ $? -ne 0]; then | ||
| 68 | echo "*** Fail; server req" | ||
| 69 | exit 1 | ||
| 70 | fi | ||
| 71 | |||
| 72 | # sign server key | ||
| 73 | openssl ca -batch -config intermediate.cnf -extensions server_cert -days 5 -notext -md sha256 -in server.csr.pem -out server.cert.pem | ||
| 74 | if [ $? -ne 0 ]; then | ||
| 75 | echo "*** Fail; server sign" | ||
| 76 | exit 1 | ||
| 77 | fi | ||
| 78 | |||
| 79 | # make a client certificate | ||
| 80 | |||
| 81 | openssl genrsa -out client.key.pem 2048 | ||
| 82 | if [ $? -ne 0]; then | ||
| 83 | echo "*** Fail; genrsa client" | ||
| 84 | exit 1 | ||
| 85 | fi | ||
| 86 | |||
| 87 | openssl req -batch -config intermediate.cnf \ | ||
| 88 | -key client.key.pem \ | ||
| 89 | -new -sha256 -out client.csr.pem \ | ||
| 90 | -subj '/CN=client/O=OpenBSD/OU=So and Sos/C=CA' | ||
| 91 | if [ $? -ne 0]; then | ||
| 92 | echo "*** Fail; client req" | ||
| 93 | exit 1 | ||
| 94 | fi | ||
| 95 | |||
| 96 | # sign client key | ||
| 97 | openssl ca -batch -config intermediate.cnf -extensions usr_cert -days 5 -notext -md sha256 -in client.csr.pem -out client.cert.pem | ||
| 98 | if [ $? -ne 0 ]; then | ||
| 99 | echo "*** Fail; client sign" | ||
| 100 | exit 1 | ||
| 101 | fi | ||
| 102 | |||
| 103 | # Verify Intermediate | ||
| 104 | openssl verify -purpose sslserver -CAfile chain.pem server.cert.pem | ||
| 105 | if [ $? -ne 0 ]; then | ||
| 106 | echo "*** Fail; server cert does not validate" | ||
| 107 | exit 1 | ||
| 108 | fi | ||
| 109 | |||
| 110 | # Verify Intermediate | ||
| 111 | openssl verify -purpose sslclient -CAfile chain.pem client.cert.pem | ||
| 112 | if [ $? -ne 0 ]; then | ||
| 113 | echo "*** Fail; client cert does not validate" | ||
| 114 | exit 1 | ||
| 115 | fi | ||
| 116 | |||
diff --git a/src/regress/lib/libcrypto/CA/intermediate.cnf b/src/regress/lib/libcrypto/CA/intermediate.cnf index 9a95487c00..bbf189d268 100644 --- a/src/regress/lib/libcrypto/CA/intermediate.cnf +++ b/src/regress/lib/libcrypto/CA/intermediate.cnf | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: intermediate.cnf,v 1.2 2018/07/17 17:06:49 tb Exp $ | 1 | # $OpenBSD: intermediate.cnf,v 1.3 2020/12/26 00:48:56 bluhm Exp $ |
| 2 | # For regression tests | 2 | # For regression tests |
| 3 | default_ca = CA_regress | 3 | default_ca = CA_regress |
| 4 | 4 | ||
| @@ -7,9 +7,9 @@ default_ca = CA_regress | |||
| 7 | dir = . | 7 | dir = . |
| 8 | certs = $dir | 8 | certs = $dir |
| 9 | crl_dir = $dir | 9 | crl_dir = $dir |
| 10 | database = $dir/int.txt | 10 | database = $dir/intermediate.txt |
| 11 | serial = $dir/intserial | 11 | serial = $dir/intermediate.serial |
| 12 | new_certs_dir = $dir | 12 | new_certs_dir = $dir |
| 13 | 13 | ||
| 14 | # The root key and root certificate. | 14 | # The root key and root certificate. |
| 15 | private_key = $dir/intermediate.key.pem | 15 | private_key = $dir/intermediate.key.pem |
| @@ -127,4 +127,3 @@ subjectKeyIdentifier = hash | |||
| 127 | authorityKeyIdentifier = keyid,issuer | 127 | authorityKeyIdentifier = keyid,issuer |
| 128 | keyUsage = critical, digitalSignature | 128 | keyUsage = critical, digitalSignature |
| 129 | extendedKeyUsage = critical, OCSPSigning | 129 | extendedKeyUsage = critical, OCSPSigning |
| 130 | |||
diff --git a/src/regress/lib/libcrypto/CA/root.cnf b/src/regress/lib/libcrypto/CA/root.cnf index b22e161476..506542e943 100644 --- a/src/regress/lib/libcrypto/CA/root.cnf +++ b/src/regress/lib/libcrypto/CA/root.cnf | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: root.cnf,v 1.2 2018/07/17 17:06:49 tb Exp $ | 1 | # $OpenBSD: root.cnf,v 1.3 2020/12/26 00:48:56 bluhm Exp $ |
| 2 | # For regression tests | 2 | # For regression tests |
| 3 | default_ca = CA_regress | 3 | default_ca = CA_regress |
| 4 | 4 | ||
| @@ -8,8 +8,8 @@ dir = . | |||
| 8 | certs = $dir | 8 | certs = $dir |
| 9 | crl_dir = $dir | 9 | crl_dir = $dir |
| 10 | database = $dir/root.txt | 10 | database = $dir/root.txt |
| 11 | serial = $dir/rootserial | 11 | serial = $dir/root.serial |
| 12 | new_certs_dir = $dir | 12 | new_certs_dir = $dir |
| 13 | 13 | ||
| 14 | # The root key and root certificate. | 14 | # The root key and root certificate. |
| 15 | private_key = $dir/root.key.pem | 15 | private_key = $dir/root.key.pem |
| @@ -127,4 +127,3 @@ subjectKeyIdentifier = hash | |||
| 127 | authorityKeyIdentifier = keyid,issuer | 127 | authorityKeyIdentifier = keyid,issuer |
| 128 | keyUsage = critical, digitalSignature | 128 | keyUsage = critical, digitalSignature |
| 129 | extendedKeyUsage = critical, OCSPSigning | 129 | extendedKeyUsage = critical, OCSPSigning |
| 130 | |||
diff --git a/src/regress/lib/libcrypto/Makefile b/src/regress/lib/libcrypto/Makefile index 7ec659bfc2..6f7b024c47 100644 --- a/src/regress/lib/libcrypto/Makefile +++ b/src/regress/lib/libcrypto/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.40 2020/09/18 10:19:31 tb Exp $ | 1 | # $OpenBSD: Makefile,v 1.41 2020/12/26 00:48:56 bluhm Exp $ |
| 2 | 2 | ||
| 3 | SUBDIR += aead | 3 | SUBDIR += aead |
| 4 | SUBDIR += aeswrap | 4 | SUBDIR += aeswrap |
| @@ -7,6 +7,7 @@ SUBDIR += base64 | |||
| 7 | SUBDIR += bf | 7 | SUBDIR += bf |
| 8 | SUBDIR += bio | 8 | SUBDIR += bio |
| 9 | SUBDIR += bn | 9 | SUBDIR += bn |
| 10 | SUBDIR += CA | ||
| 10 | SUBDIR += cast | 11 | SUBDIR += cast |
| 11 | SUBDIR += certs | 12 | SUBDIR += certs |
| 12 | SUBDIR += chacha | 13 | SUBDIR += chacha |
