summaryrefslogtreecommitdiff
path: root/lib/libssl
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2010-10-01 22:54:19 +0000
committerDamien Miller <djm@cvs.openbsd.org>2010-10-01 22:54:19 +0000
commitae9cbeba0dc25f0e95e6a0e50b6c161bf6384e17 (patch)
tree8df3ed61815c8ca9c7b1d1c57d9dee71b0933444 /lib/libssl
parent8bf056baaec6a3f97edb90b5b7567c7d7f94f8fa (diff)
import OpenSSL-1.0.0a
Diffstat (limited to 'lib/libssl')
-rw-r--r--lib/libssl/t1_reneg.c292
-rw-r--r--lib/libssl/test/CAtsa.cnf163
-rwxr-xr-xlib/libssl/test/asn1test.c22
-rw-r--r--lib/libssl/test/cms-test.pl18
-rw-r--r--lib/libssl/test/pkits-test.pl940
-rwxr-xr-xlib/libssl/test/test_padlock64
-rw-r--r--lib/libssl/test/testtsa238
-rw-r--r--lib/libssl/test/testtsa.com248
8 files changed, 1976 insertions, 9 deletions
diff --git a/lib/libssl/t1_reneg.c b/lib/libssl/t1_reneg.c
new file mode 100644
index 00000000000..9c2cc3c712a
--- /dev/null
+++ b/lib/libssl/t1_reneg.c
@@ -0,0 +1,292 @@
+/* ssl/t1_reneg.c */
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
+ * All rights reserved.
+ *
+ * This package is an SSL implementation written
+ * by Eric Young (eay@cryptsoft.com).
+ * The implementation was written so as to conform with Netscapes SSL.
+ *
+ * This library is free for commercial and non-commercial use as long as
+ * the following conditions are aheared to. The following conditions
+ * apply to all code found in this distribution, be it the RC4, RSA,
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
+ * included with this distribution is covered by the same copyright terms
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
+ *
+ * Copyright remains Eric Young's, and as such any Copyright notices in
+ * the code are not to be removed.
+ * If this package is used in a product, Eric Young should be given attribution
+ * as the author of the parts of the library used.
+ * This can be in the form of a textual message at program startup or
+ * in documentation (online or textual) provided with the package.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * "This product includes cryptographic software written by
+ * Eric Young (eay@cryptsoft.com)"
+ * The word 'cryptographic' can be left out if the rouines from the library
+ * being used are not cryptographic related :-).
+ * 4. If you include any Windows specific code (or a derivative thereof) from
+ * the apps directory (application code) you must include an acknowledgement:
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * The licence and distribution terms for any publically available version or
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
+ * copied and put under another distribution licence
+ * [including the GNU Public Licence.]
+ */
+/* ====================================================================
+ * Copyright (c) 1998-2009 The OpenSSL Project. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ * software must display the following acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
+ *
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+ * endorse or promote products derived from this software without
+ * prior written permission. For written permission, please contact
+ * openssl-core@openssl.org.
+ *
+ * 5. Products derived from this software may not be called "OpenSSL"
+ * nor may "OpenSSL" appear in their names without prior written
+ * permission of the OpenSSL Project.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ * acknowledgment:
+ * "This product includes software developed by the OpenSSL Project
+ * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This product includes cryptographic software written by Eric Young
+ * (eay@cryptsoft.com). This product includes software written by Tim
+ * Hudson (tjh@cryptsoft.com).
+ *
+ */
+#include <stdio.h>
+#include <openssl/objects.h>
+#include "ssl_locl.h"
+
+/* Add the client's renegotiation binding */
+int ssl_add_clienthello_renegotiate_ext(SSL *s, unsigned char *p, int *len,
+ int maxlen)
+ {
+ if(p)
+ {
+ if((s->s3->previous_client_finished_len+1) > maxlen)
+ {
+ SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT,SSL_R_RENEGOTIATE_EXT_TOO_LONG);
+ return 0;
+ }
+
+ /* Length byte */
+ *p = s->s3->previous_client_finished_len;
+ p++;
+
+ memcpy(p, s->s3->previous_client_finished,
+ s->s3->previous_client_finished_len);
+#ifdef OPENSSL_RI_DEBUG
+ fprintf(stderr, "%s RI extension sent by client\n",
+ s->s3->previous_client_finished_len ? "Non-empty" : "Empty");
+#endif
+ }
+
+ *len=s->s3->previous_client_finished_len + 1;
+
+
+ return 1;
+ }
+
+/* Parse the client's renegotiation binding and abort if it's not
+ right */
+int ssl_parse_clienthello_renegotiate_ext(SSL *s, unsigned char *d, int len,
+ int *al)
+ {
+ int ilen;
+
+ /* Parse the length byte */
+ if(len < 1)
+ {
+ SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,SSL_R_RENEGOTIATION_ENCODING_ERR);
+ *al=SSL_AD_ILLEGAL_PARAMETER;
+ return 0;
+ }
+ ilen = *d;
+ d++;
+
+ /* Consistency check */
+ if((ilen+1) != len)
+ {
+ SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,SSL_R_RENEGOTIATION_ENCODING_ERR);
+ *al=SSL_AD_ILLEGAL_PARAMETER;
+ return 0;
+ }
+
+ /* Check that the extension matches */
+ if(ilen != s->s3->previous_client_finished_len)
+ {
+ SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,SSL_R_RENEGOTIATION_MISMATCH);
+ *al=SSL_AD_HANDSHAKE_FAILURE;
+ return 0;
+ }
+
+ if(memcmp(d, s->s3->previous_client_finished,
+ s->s3->previous_client_finished_len))
+ {
+ SSLerr(SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT,SSL_R_RENEGOTIATION_MISMATCH);
+ *al=SSL_AD_HANDSHAKE_FAILURE;
+ return 0;
+ }
+#ifdef OPENSSL_RI_DEBUG
+ fprintf(stderr, "%s RI extension received by server\n",
+ ilen ? "Non-empty" : "Empty");
+#endif
+
+ s->s3->send_connection_binding=1;
+
+ return 1;
+ }
+
+/* Add the server's renegotiation binding */
+int ssl_add_serverhello_renegotiate_ext(SSL *s, unsigned char *p, int *len,
+ int maxlen)
+ {
+ if(p)
+ {
+ if((s->s3->previous_client_finished_len +
+ s->s3->previous_server_finished_len + 1) > maxlen)
+ {
+ SSLerr(SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT,SSL_R_RENEGOTIATE_EXT_TOO_LONG);
+ return 0;
+ }
+
+ /* Length byte */
+ *p = s->s3->previous_client_finished_len + s->s3->previous_server_finished_len;
+ p++;
+
+ memcpy(p, s->s3->previous_client_finished,
+ s->s3->previous_client_finished_len);
+ p += s->s3->previous_client_finished_len;
+
+ memcpy(p, s->s3->previous_server_finished,
+ s->s3->previous_server_finished_len);
+#ifdef OPENSSL_RI_DEBUG
+ fprintf(stderr, "%s RI extension sent by server\n",
+ s->s3->previous_client_finished_len ? "Non-empty" : "Empty");
+#endif
+ }
+
+ *len=s->s3->previous_client_finished_len
+ + s->s3->previous_server_finished_len + 1;
+
+ return 1;
+ }
+
+/* Parse the server's renegotiation binding and abort if it's not
+ right */
+int ssl_parse_serverhello_renegotiate_ext(SSL *s, unsigned char *d, int len,
+ int *al)
+ {
+ int expected_len=s->s3->previous_client_finished_len
+ + s->s3->previous_server_finished_len;
+ int ilen;
+
+ /* Check for logic errors */
+ OPENSSL_assert(!expected_len || s->s3->previous_client_finished_len);
+ OPENSSL_assert(!expected_len || s->s3->previous_server_finished_len);
+
+ /* Parse the length byte */
+ if(len < 1)
+ {
+ SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT,SSL_R_RENEGOTIATION_ENCODING_ERR);
+ *al=SSL_AD_ILLEGAL_PARAMETER;
+ return 0;
+ }
+ ilen = *d;
+ d++;
+
+ /* Consistency check */
+ if(ilen+1 != len)
+ {
+ SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT,SSL_R_RENEGOTIATION_ENCODING_ERR);
+ *al=SSL_AD_ILLEGAL_PARAMETER;
+ return 0;
+ }
+
+ /* Check that the extension matches */
+ if(ilen != expected_len)
+ {
+ SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT,SSL_R_RENEGOTIATION_MISMATCH);
+ *al=SSL_AD_HANDSHAKE_FAILURE;
+ return 0;
+ }
+
+ if(memcmp(d, s->s3->previous_client_finished,
+ s->s3->previous_client_finished_len))
+ {
+ SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT,SSL_R_RENEGOTIATION_MISMATCH);
+ *al=SSL_AD_HANDSHAKE_FAILURE;
+ return 0;
+ }
+ d += s->s3->previous_client_finished_len;
+
+ if(memcmp(d, s->s3->previous_server_finished,
+ s->s3->previous_server_finished_len))
+ {
+ SSLerr(SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT,SSL_R_RENEGOTIATION_MISMATCH);
+ *al=SSL_AD_ILLEGAL_PARAMETER;
+ return 0;
+ }
+#ifdef OPENSSL_RI_DEBUG
+ fprintf(stderr, "%s RI extension received by client\n",
+ ilen ? "Non-empty" : "Empty");
+#endif
+ s->s3->send_connection_binding=1;
+
+ return 1;
+ }
diff --git a/lib/libssl/test/CAtsa.cnf b/lib/libssl/test/CAtsa.cnf
new file mode 100644
index 00000000000..f5a275bfc23
--- /dev/null
+++ b/lib/libssl/test/CAtsa.cnf
@@ -0,0 +1,163 @@
+
+#
+# This config is used by the Time Stamp Authority tests.
+#
+
+RANDFILE = ./.rnd
+
+# Extra OBJECT IDENTIFIER info:
+oid_section = new_oids
+
+TSDNSECT = ts_cert_dn
+INDEX = 1
+
+[ new_oids ]
+
+# Policies used by the TSA tests.
+tsa_policy1 = 1.2.3.4.1
+tsa_policy2 = 1.2.3.4.5.6
+tsa_policy3 = 1.2.3.4.5.7
+
+#----------------------------------------------------------------------
+[ ca ]
+default_ca = CA_default # The default ca section
+
+[ CA_default ]
+
+dir = ./demoCA
+certs = $dir/certs # Where the issued certs are kept
+database = $dir/index.txt # database index file.
+new_certs_dir = $dir/newcerts # default place for new certs.
+
+certificate = $dir/cacert.pem # The CA certificate
+serial = $dir/serial # The current serial number
+private_key = $dir/private/cakey.pem# The private key
+RANDFILE = $dir/private/.rand # private random number file
+
+default_days = 365 # how long to certify for
+default_md = sha1 # which md to use.
+preserve = no # keep passed DN ordering
+
+policy = policy_match
+
+# For the CA policy
+[ policy_match ]
+countryName = supplied
+stateOrProvinceName = supplied
+organizationName = supplied
+organizationalUnitName = optional
+commonName = supplied
+emailAddress = optional
+
+#----------------------------------------------------------------------
+[ req ]
+default_bits = 1024
+default_md = sha1
+distinguished_name = $ENV::TSDNSECT
+encrypt_rsa_key = no
+prompt = no
+# attributes = req_attributes
+x509_extensions = v3_ca # The extentions to add to the self signed cert
+
+string_mask = nombstr
+
+[ ts_ca_dn ]
+countryName = HU
+stateOrProvinceName = Budapest
+localityName = Budapest
+organizationName = Gov-CA Ltd.
+commonName = ca1
+
+[ ts_cert_dn ]
+countryName = HU
+stateOrProvinceName = Budapest
+localityName = Buda
+organizationName = Hun-TSA Ltd.
+commonName = tsa$ENV::INDEX
+
+[ tsa_cert ]
+
+# TSA server cert is not a CA cert.
+basicConstraints=CA:FALSE
+
+# The following key usage flags are needed for TSA server certificates.
+keyUsage = nonRepudiation, digitalSignature
+extendedKeyUsage = critical,timeStamping
+
+# PKIX recommendations harmless if included in all certificates.
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid,issuer:always
+
+[ non_tsa_cert ]
+
+# This is not a CA cert and not a TSA cert, either (timeStamping usage missing)
+basicConstraints=CA:FALSE
+
+# The following key usage flags are needed for TSA server certificates.
+keyUsage = nonRepudiation, digitalSignature
+# timeStamping is not supported by this certificate
+# extendedKeyUsage = critical,timeStamping
+
+# PKIX recommendations harmless if included in all certificates.
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid,issuer:always
+
+[ v3_req ]
+
+# Extensions to add to a certificate request
+basicConstraints = CA:FALSE
+keyUsage = nonRepudiation, digitalSignature
+
+[ v3_ca ]
+
+# Extensions for a typical CA
+
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid:always,issuer:always
+basicConstraints = critical,CA:true
+keyUsage = cRLSign, keyCertSign
+
+#----------------------------------------------------------------------
+[ tsa ]
+
+default_tsa = tsa_config1 # the default TSA section
+
+[ tsa_config1 ]
+
+# These are used by the TSA reply generation only.
+dir = . # TSA root directory
+serial = $dir/tsa_serial # The current serial number (mandatory)
+signer_cert = $dir/tsa_cert1.pem # The TSA signing certificate
+ # (optional)
+certs = $dir/tsaca.pem # Certificate chain to include in reply
+ # (optional)
+signer_key = $dir/tsa_key1.pem # The TSA private key (optional)
+
+default_policy = tsa_policy1 # Policy if request did not specify it
+ # (optional)
+other_policies = tsa_policy2, tsa_policy3 # acceptable policies (optional)
+digests = md5, sha1 # Acceptable message digests (mandatory)
+accuracy = secs:1, millisecs:500, microsecs:100 # (optional)
+ordering = yes # Is ordering defined for timestamps?
+ # (optional, default: no)
+tsa_name = yes # Must the TSA name be included in the reply?
+ # (optional, default: no)
+ess_cert_id_chain = yes # Must the ESS cert id chain be included?
+ # (optional, default: no)
+
+[ tsa_config2 ]
+
+# This configuration uses a certificate which doesn't have timeStamping usage.
+# These are used by the TSA reply generation only.
+dir = . # TSA root directory
+serial = $dir/tsa_serial # The current serial number (mandatory)
+signer_cert = $dir/tsa_cert2.pem # The TSA signing certificate
+ # (optional)
+certs = $dir/demoCA/cacert.pem# Certificate chain to include in reply
+ # (optional)
+signer_key = $dir/tsa_key2.pem # The TSA private key (optional)
+
+default_policy = tsa_policy1 # Policy if request did not specify it
+ # (optional)
+other_policies = tsa_policy2, tsa_policy3 # acceptable policies (optional)
+digests = md5, sha1 # Acceptable message digests (mandatory)
diff --git a/lib/libssl/test/asn1test.c b/lib/libssl/test/asn1test.c
new file mode 100755
index 00000000000..9f53d803444
--- /dev/null
+++ b/lib/libssl/test/asn1test.c
@@ -0,0 +1,22 @@
+#include <openssl/x509.h>
+#include <openssl/asn1_mac.h>
+
+typedef struct X
+ {
+ STACK_OF(X509_EXTENSION) *ext;
+ } X;
+
+/* This isn't meant to run particularly, it's just to test type checking */
+int main(int argc, char **argv)
+ {
+ X *x = NULL;
+ unsigned char **pp = NULL;
+
+ M_ASN1_I2D_vars(x);
+ M_ASN1_I2D_len_SEQUENCE_opt_type(X509_EXTENSION, x->ext,
+ i2d_X509_EXTENSION);
+ M_ASN1_I2D_seq_total();
+ M_ASN1_I2D_put_SEQUENCE_opt_type(X509_EXTENSION, x->ext,
+ i2d_X509_EXTENSION);
+ M_ASN1_I2D_finish();
+ }
diff --git a/lib/libssl/test/cms-test.pl b/lib/libssl/test/cms-test.pl
index a84e089ddc4..9c50dff3e9a 100644
--- a/lib/libssl/test/cms-test.pl
+++ b/lib/libssl/test/cms-test.pl
@@ -54,8 +54,12 @@
# OpenSSL PKCS#7 and CMS implementations.
my $ossl_path;
-
-if ( -f "../apps/openssl" ) {
+my $redir = " 2>cms.err 1>cms.out";
+# Make MSYS work
+if ( $^O eq "MSWin32" && -f "../apps/openssl.exe" ) {
+ $ossl_path = "cmd /c ..\\apps\\openssl";
+}
+elsif ( -f "../apps/openssl$ENV{EXE_EXT}" ) {
$ossl_path = "../util/shlib_wrap.sh ../apps/openssl";
}
elsif ( -f "..\\out32dll\\openssl.exe" ) {
@@ -232,7 +236,7 @@ my @smime_cms_tests = (
[
"signed content MIME format, RSA key, signed receipt request",
"-sign -in smcont.txt -signer $smdir/smrsa1.pem -nodetach"
- . " -receipt_request_to test@openssl.org -receipt_request_all"
+ . " -receipt_request_to test\@openssl.org -receipt_request_all"
. " -out test.cms",
"-verify -in test.cms "
. " -CAfile $smdir/smroot.pem -out smtst.txt"
@@ -333,10 +337,6 @@ my @smime_cms_comp_tests = (
);
-print "PKCS#7 <=> PKCS#7 consistency tests\n";
-
-run_smime_tests( \$badcmd, \@smime_pkcs7_tests, $pk7cmd, $pk7cmd );
-
print "CMS => PKCS#7 compatibility tests\n";
run_smime_tests( \$badcmd, \@smime_pkcs7_tests, $cmscmd, $pk7cmd );
@@ -386,14 +386,14 @@ sub run_smime_tests {
$rscmd =~ s/-stream//;
$rvcmd =~ s/-stream//;
}
- system("$scmd$rscmd 2>cms.err 1>cms.out");
+ system("$scmd$rscmd$redir");
if ($?) {
print "$tnam: generation error\n";
$$rv++;
exit 1 if $halt_err;
next;
}
- system("$vcmd$rvcmd 2>cms.err 1>cms.out");
+ system("$vcmd$rvcmd$redir");
if ($?) {
print "$tnam: verify error\n";
$$rv++;
diff --git a/lib/libssl/test/pkits-test.pl b/lib/libssl/test/pkits-test.pl
new file mode 100644
index 00000000000..69dffa16f90
--- /dev/null
+++ b/lib/libssl/test/pkits-test.pl
@@ -0,0 +1,940 @@
+# test/pkits-test.pl
+# Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
+# project.
+#
+# ====================================================================
+# Copyright (c) 2008 The OpenSSL Project. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#
+# 3. All advertising materials mentioning features or use of this
+# software must display the following acknowledgment:
+# "This product includes software developed by the OpenSSL Project
+# for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
+#
+# 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
+# endorse or promote products derived from this software without
+# prior written permission. For written permission, please contact
+# licensing@OpenSSL.org.
+#
+# 5. Products derived from this software may not be called "OpenSSL"
+# nor may "OpenSSL" appear in their names without prior written
+# permission of the OpenSSL Project.
+#
+# 6. Redistributions of any form whatsoever must retain the following
+# acknowledgment:
+# "This product includes software developed by the OpenSSL Project
+# for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
+#
+# THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
+# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
+# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+# OF THE POSSIBILITY OF SUCH DAMAGE.
+# ====================================================================
+
+# Perl utility to run PKITS tests for RFC3280 compliance.
+
+my $ossl_path;
+
+if ( -f "../apps/openssl" ) {
+ $ossl_path = "../util/shlib_wrap.sh ../apps/openssl";
+}
+elsif ( -f "..\\out32dll\\openssl.exe" ) {
+ $ossl_path = "..\\out32dll\\openssl.exe";
+}
+elsif ( -f "..\\out32\\openssl.exe" ) {
+ $ossl_path = "..\\out32\\openssl.exe";
+}
+else {
+ die "Can't find OpenSSL executable";
+}
+
+my $pkitsdir = "pkits/smime";
+my $pkitsta = "pkits/certs/TrustAnchorRootCertificate.crt";
+
+die "Can't find PKITS test data" if !-d $pkitsdir;
+
+my $nist1 = "2.16.840.1.101.3.2.1.48.1";
+my $nist2 = "2.16.840.1.101.3.2.1.48.2";
+my $nist3 = "2.16.840.1.101.3.2.1.48.3";
+my $nist4 = "2.16.840.1.101.3.2.1.48.4";
+my $nist5 = "2.16.840.1.101.3.2.1.48.5";
+my $nist6 = "2.16.840.1.101.3.2.1.48.6";
+
+my $apolicy = "X509v3 Any Policy";
+
+# This table contains the chapter headings of the accompanying PKITS
+# document. They provide useful informational output and their names
+# can be converted into the filename to test.
+
+my @testlists = (
+ [ "4.1", "Signature Verification" ],
+ [ "4.1.1", "Valid Signatures Test1", 0 ],
+ [ "4.1.2", "Invalid CA Signature Test2", 7 ],
+ [ "4.1.3", "Invalid EE Signature Test3", 7 ],
+ [ "4.1.4", "Valid DSA Signatures Test4", 0 ],
+ [ "4.1.5", "Valid DSA Parameter Inheritance Test5", 0 ],
+ [ "4.1.6", "Invalid DSA Signature Test6", 7 ],
+ [ "4.2", "Validity Periods" ],
+ [ "4.2.1", "Invalid CA notBefore Date Test1", 9 ],
+ [ "4.2.2", "Invalid EE notBefore Date Test2", 9 ],
+ [ "4.2.3", "Valid pre2000 UTC notBefore Date Test3", 0 ],
+ [ "4.2.4", "Valid GeneralizedTime notBefore Date Test4", 0 ],
+ [ "4.2.5", "Invalid CA notAfter Date Test5", 10 ],
+ [ "4.2.6", "Invalid EE notAfter Date Test6", 10 ],
+ [ "4.2.7", "Invalid pre2000 UTC EE notAfter Date Test7", 10 ],
+ [ "4.2.8", "Valid GeneralizedTime notAfter Date Test8", 0 ],
+ [ "4.3", "Verifying Name Chaining" ],
+ [ "4.3.1", "Invalid Name Chaining EE Test1", 20 ],
+ [ "4.3.2", "Invalid Name Chaining Order Test2", 20 ],
+ [ "4.3.3", "Valid Name Chaining Whitespace Test3", 0 ],
+ [ "4.3.4", "Valid Name Chaining Whitespace Test4", 0 ],
+ [ "4.3.5", "Valid Name Chaining Capitalization Test5", 0 ],
+ [ "4.3.6", "Valid Name Chaining UIDs Test6", 0 ],
+ [ "4.3.7", "Valid RFC3280 Mandatory Attribute Types Test7", 0 ],
+ [ "4.3.8", "Valid RFC3280 Optional Attribute Types Test8", 0 ],
+ [ "4.3.9", "Valid UTF8String Encoded Names Test9", 0 ],
+ [ "4.3.10", "Valid Rollover from PrintableString to UTF8String Test10", 0 ],
+ [ "4.3.11", "Valid UTF8String Case Insensitive Match Test11", 0 ],
+ [ "4.4", "Basic Certificate Revocation Tests" ],
+ [ "4.4.1", "Missing CRL Test1", 3 ],
+ [ "4.4.2", "Invalid Revoked CA Test2", 23 ],
+ [ "4.4.3", "Invalid Revoked EE Test3", 23 ],
+ [ "4.4.4", "Invalid Bad CRL Signature Test4", 8 ],
+ [ "4.4.5", "Invalid Bad CRL Issuer Name Test5", 3 ],
+ [ "4.4.6", "Invalid Wrong CRL Test6", 3 ],
+ [ "4.4.7", "Valid Two CRLs Test7", 0 ],
+
+ # The test document suggests these should return certificate revoked...
+ # Subsquent discussion has concluded they should not due to unhandle
+ # critical CRL extensions.
+ [ "4.4.8", "Invalid Unknown CRL Entry Extension Test8", 36 ],
+ [ "4.4.9", "Invalid Unknown CRL Extension Test9", 36 ],
+
+ [ "4.4.10", "Invalid Unknown CRL Extension Test10", 36 ],
+ [ "4.4.11", "Invalid Old CRL nextUpdate Test11", 12 ],
+ [ "4.4.12", "Invalid pre2000 CRL nextUpdate Test12", 12 ],
+ [ "4.4.13", "Valid GeneralizedTime CRL nextUpdate Test13", 0 ],
+ [ "4.4.14", "Valid Negative Serial Number Test14", 0 ],
+ [ "4.4.15", "Invalid Negative Serial Number Test15", 23 ],
+ [ "4.4.16", "Valid Long Serial Number Test16", 0 ],
+ [ "4.4.17", "Valid Long Serial Number Test17", 0 ],
+ [ "4.4.18", "Invalid Long Serial Number Test18", 23 ],
+ [ "4.4.19", "Valid Separate Certificate and CRL Keys Test19", 0 ],
+ [ "4.4.20", "Invalid Separate Certificate and CRL Keys Test20", 23 ],
+
+ # CRL path is revoked so get a CRL path validation error
+ [ "4.4.21", "Invalid Separate Certificate and CRL Keys Test21", 54 ],
+ [ "4.5", "Verifying Paths with Self-Issued Certificates" ],
+ [ "4.5.1", "Valid Basic Self-Issued Old With New Test1", 0 ],
+ [ "4.5.2", "Invalid Basic Self-Issued Old With New Test2", 23 ],
+ [ "4.5.3", "Valid Basic Self-Issued New With Old Test3", 0 ],
+ [ "4.5.4", "Valid Basic Self-Issued New With Old Test4", 0 ],
+ [ "4.5.5", "Invalid Basic Self-Issued New With Old Test5", 23 ],
+ [ "4.5.6", "Valid Basic Self-Issued CRL Signing Key Test6", 0 ],
+ [ "4.5.7", "Invalid Basic Self-Issued CRL Signing Key Test7", 23 ],
+ [ "4.5.8", "Invalid Basic Self-Issued CRL Signing Key Test8", 20 ],
+ [ "4.6", "Verifying Basic Constraints" ],
+ [ "4.6.1", "Invalid Missing basicConstraints Test1", 24 ],
+ [ "4.6.2", "Invalid cA False Test2", 24 ],
+ [ "4.6.3", "Invalid cA False Test3", 24 ],
+ [ "4.6.4", "Valid basicConstraints Not Critical Test4", 0 ],
+ [ "4.6.5", "Invalid pathLenConstraint Test5", 25 ],
+ [ "4.6.6", "Invalid pathLenConstraint Test6", 25 ],
+ [ "4.6.7", "Valid pathLenConstraint Test7", 0 ],
+ [ "4.6.8", "Valid pathLenConstraint Test8", 0 ],
+ [ "4.6.9", "Invalid pathLenConstraint Test9", 25 ],
+ [ "4.6.10", "Invalid pathLenConstraint Test10", 25 ],
+ [ "4.6.11", "Invalid pathLenConstraint Test11", 25 ],
+ [ "4.6.12", "Invalid pathLenConstraint Test12", 25 ],
+ [ "4.6.13", "Valid pathLenConstraint Test13", 0 ],
+ [ "4.6.14", "Valid pathLenConstraint Test14", 0 ],
+ [ "4.6.15", "Valid Self-Issued pathLenConstraint Test15", 0 ],
+ [ "4.6.16", "Invalid Self-Issued pathLenConstraint Test16", 25 ],
+ [ "4.6.17", "Valid Self-Issued pathLenConstraint Test17", 0 ],
+ [ "4.7", "Key Usage" ],
+ [ "4.7.1", "Invalid keyUsage Critical keyCertSign False Test1", 20 ],
+ [ "4.7.2", "Invalid keyUsage Not Critical keyCertSign False Test2", 20 ],
+ [ "4.7.3", "Valid keyUsage Not Critical Test3", 0 ],
+ [ "4.7.4", "Invalid keyUsage Critical cRLSign False Test4", 35 ],
+ [ "4.7.5", "Invalid keyUsage Not Critical cRLSign False Test5", 35 ],
+
+ # Certificate policy tests need special handling. They can have several
+ # sub tests and we need to check the outputs are correct.
+
+ [ "4.8", "Certificate Policies" ],
+ [
+ "4.8.1.1",
+ "All Certificates Same Policy Test1",
+ "-policy anyPolicy -explicit_policy",
+ "True", $nist1, $nist1, 0
+ ],
+ [
+ "4.8.1.2",
+ "All Certificates Same Policy Test1",
+ "-policy $nist1 -explicit_policy",
+ "True", $nist1, $nist1, 0
+ ],
+ [
+ "4.8.1.3",
+ "All Certificates Same Policy Test1",
+ "-policy $nist2 -explicit_policy",
+ "True", $nist1, "<empty>", 43
+ ],
+ [
+ "4.8.1.4",
+ "All Certificates Same Policy Test1",
+ "-policy $nist1 -policy $nist2 -explicit_policy",
+ "True", $nist1, $nist1, 0
+ ],
+ [
+ "4.8.2.1",
+ "All Certificates No Policies Test2",
+ "-policy anyPolicy",
+ "False", "<empty>", "<empty>", 0
+ ],
+ [
+ "4.8.2.2",
+ "All Certificates No Policies Test2",
+ "-policy anyPolicy -explicit_policy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.8.3.1",
+ "Different Policies Test3",
+ "-policy anyPolicy",
+ "False", "<empty>", "<empty>", 0
+ ],
+ [
+ "4.8.3.2",
+ "Different Policies Test3",
+ "-policy anyPolicy -explicit_policy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.8.3.3",
+ "Different Policies Test3",
+ "-policy $nist1 -policy $nist2 -explicit_policy",
+ "True", "<empty>", "<empty>", 43
+ ],
+
+ [
+ "4.8.4",
+ "Different Policies Test4",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.8.5",
+ "Different Policies Test5",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.8.6.1",
+ "Overlapping Policies Test6",
+ "-policy anyPolicy",
+ "True", $nist1, $nist1, 0
+ ],
+ [
+ "4.8.6.2",
+ "Overlapping Policies Test6",
+ "-policy $nist1",
+ "True", $nist1, $nist1, 0
+ ],
+ [
+ "4.8.6.3",
+ "Overlapping Policies Test6",
+ "-policy $nist2",
+ "True", $nist1, "<empty>", 43
+ ],
+ [
+ "4.8.7",
+ "Different Policies Test7",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.8.8",
+ "Different Policies Test8",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.8.9",
+ "Different Policies Test9",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.8.10.1",
+ "All Certificates Same Policies Test10",
+ "-policy $nist1",
+ "True", "$nist1:$nist2", "$nist1", 0
+ ],
+ [
+ "4.8.10.2",
+ "All Certificates Same Policies Test10",
+ "-policy $nist2",
+ "True", "$nist1:$nist2", "$nist2", 0
+ ],
+ [
+ "4.8.10.3",
+ "All Certificates Same Policies Test10",
+ "-policy anyPolicy",
+ "True", "$nist1:$nist2", "$nist1:$nist2", 0
+ ],
+ [
+ "4.8.11.1",
+ "All Certificates AnyPolicy Test11",
+ "-policy anyPolicy",
+ "True", "$apolicy", "$apolicy", 0
+ ],
+ [
+ "4.8.11.2",
+ "All Certificates AnyPolicy Test11",
+ "-policy $nist1",
+ "True", "$apolicy", "$nist1", 0
+ ],
+ [
+ "4.8.12",
+ "Different Policies Test12",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.8.13.1",
+ "All Certificates Same Policies Test13",
+ "-policy $nist1",
+ "True", "$nist1:$nist2:$nist3", "$nist1", 0
+ ],
+ [
+ "4.8.13.2",
+ "All Certificates Same Policies Test13",
+ "-policy $nist2",
+ "True", "$nist1:$nist2:$nist3", "$nist2", 0
+ ],
+ [
+ "4.8.13.3",
+ "All Certificates Same Policies Test13",
+ "-policy $nist3",
+ "True", "$nist1:$nist2:$nist3", "$nist3", 0
+ ],
+ [
+ "4.8.14.1", "AnyPolicy Test14",
+ "-policy $nist1", "True",
+ "$nist1", "$nist1",
+ 0
+ ],
+ [
+ "4.8.14.2", "AnyPolicy Test14",
+ "-policy $nist2", "True",
+ "$nist1", "<empty>",
+ 43
+ ],
+ [
+ "4.8.15",
+ "User Notice Qualifier Test15",
+ "-policy anyPolicy",
+ "False", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.8.16",
+ "User Notice Qualifier Test16",
+ "-policy anyPolicy",
+ "False", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.8.17",
+ "User Notice Qualifier Test17",
+ "-policy anyPolicy",
+ "False", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.8.18.1",
+ "User Notice Qualifier Test18",
+ "-policy $nist1",
+ "True", "$nist1:$nist2", "$nist1", 0
+ ],
+ [
+ "4.8.18.2",
+ "User Notice Qualifier Test18",
+ "-policy $nist2",
+ "True", "$nist1:$nist2", "$nist2", 0
+ ],
+ [
+ "4.8.19",
+ "User Notice Qualifier Test19",
+ "-policy anyPolicy",
+ "False", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.8.20",
+ "CPS Pointer Qualifier Test20",
+ "-policy anyPolicy -explicit_policy",
+ "True", "$nist1", "$nist1", 0
+ ],
+ [ "4.9", "Require Explicit Policy" ],
+ [
+ "4.9.1",
+ "Valid RequireExplicitPolicy Test1",
+ "-policy anyPolicy",
+ "False", "<empty>", "<empty>", 0
+ ],
+ [
+ "4.9.2",
+ "Valid RequireExplicitPolicy Test2",
+ "-policy anyPolicy",
+ "False", "<empty>", "<empty>", 0
+ ],
+ [
+ "4.9.3",
+ "Invalid RequireExplicitPolicy Test3",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.9.4",
+ "Valid RequireExplicitPolicy Test4",
+ "-policy anyPolicy",
+ "True", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.9.5",
+ "Invalid RequireExplicitPolicy Test5",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.9.6",
+ "Valid Self-Issued requireExplicitPolicy Test6",
+ "-policy anyPolicy",
+ "False", "<empty>", "<empty>", 0
+ ],
+ [
+ "4.9.7",
+ "Invalid Self-Issued requireExplicitPolicy Test7",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.9.8",
+ "Invalid Self-Issued requireExplicitPolicy Test8",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [ "4.10", "Policy Mappings" ],
+ [
+ "4.10.1.1",
+ "Valid Policy Mapping Test1",
+ "-policy $nist1",
+ "True", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.10.1.2",
+ "Valid Policy Mapping Test1",
+ "-policy $nist2",
+ "True", "$nist1", "<empty>", 43
+ ],
+ [
+ "4.10.1.3",
+ "Valid Policy Mapping Test1",
+ "-policy anyPolicy -inhibit_map",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.10.2.1",
+ "Invalid Policy Mapping Test2",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.10.2.2",
+ "Invalid Policy Mapping Test2",
+ "-policy anyPolicy -inhibit_map",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.10.3.1",
+ "Valid Policy Mapping Test3",
+ "-policy $nist1",
+ "True", "$nist2", "<empty>", 43
+ ],
+ [
+ "4.10.3.2",
+ "Valid Policy Mapping Test3",
+ "-policy $nist2",
+ "True", "$nist2", "$nist2", 0
+ ],
+ [
+ "4.10.4",
+ "Invalid Policy Mapping Test4",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.10.5.1",
+ "Valid Policy Mapping Test5",
+ "-policy $nist1",
+ "True", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.10.5.2",
+ "Valid Policy Mapping Test5",
+ "-policy $nist6",
+ "True", "$nist1", "<empty>", 43
+ ],
+ [
+ "4.10.6.1",
+ "Valid Policy Mapping Test6",
+ "-policy $nist1",
+ "True", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.10.6.2",
+ "Valid Policy Mapping Test6",
+ "-policy $nist6",
+ "True", "$nist1", "<empty>", 43
+ ],
+ [ "4.10.7", "Invalid Mapping From anyPolicy Test7", 42 ],
+ [ "4.10.8", "Invalid Mapping To anyPolicy Test8", 42 ],
+ [
+ "4.10.9",
+ "Valid Policy Mapping Test9",
+ "-policy anyPolicy",
+ "True", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.10.10",
+ "Invalid Policy Mapping Test10",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.10.11",
+ "Valid Policy Mapping Test11",
+ "-policy anyPolicy",
+ "True", "$nist1", "$nist1", 0
+ ],
+
+ # TODO: check notice display
+ [
+ "4.10.12.1",
+ "Valid Policy Mapping Test12",
+ "-policy $nist1",
+ "True", "$nist1:$nist2", "$nist1", 0
+ ],
+
+ # TODO: check notice display
+ [
+ "4.10.12.2",
+ "Valid Policy Mapping Test12",
+ "-policy $nist2",
+ "True", "$nist1:$nist2", "$nist2", 0
+ ],
+ [
+ "4.10.13",
+ "Valid Policy Mapping Test13",
+ "-policy anyPolicy",
+ "True", "$nist1", "$nist1", 0
+ ],
+
+ # TODO: check notice display
+ [
+ "4.10.14",
+ "Valid Policy Mapping Test14",
+ "-policy anyPolicy",
+ "True", "$nist1", "$nist1", 0
+ ],
+ [ "4.11", "Inhibit Policy Mapping" ],
+ [
+ "4.11.1",
+ "Invalid inhibitPolicyMapping Test1",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.11.2",
+ "Valid inhibitPolicyMapping Test2",
+ "-policy anyPolicy",
+ "True", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.11.3",
+ "Invalid inhibitPolicyMapping Test3",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.11.4",
+ "Valid inhibitPolicyMapping Test4",
+ "-policy anyPolicy",
+ "True", "$nist2", "$nist2", 0
+ ],
+ [
+ "4.11.5",
+ "Invalid inhibitPolicyMapping Test5",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.11.6",
+ "Invalid inhibitPolicyMapping Test6",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.11.7",
+ "Valid Self-Issued inhibitPolicyMapping Test7",
+ "-policy anyPolicy",
+ "True", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.11.8",
+ "Invalid Self-Issued inhibitPolicyMapping Test8",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.11.9",
+ "Invalid Self-Issued inhibitPolicyMapping Test9",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.11.10",
+ "Invalid Self-Issued inhibitPolicyMapping Test10",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.11.11",
+ "Invalid Self-Issued inhibitPolicyMapping Test11",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [ "4.12", "Inhibit Any Policy" ],
+ [
+ "4.12.1",
+ "Invalid inhibitAnyPolicy Test1",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.12.2",
+ "Valid inhibitAnyPolicy Test2",
+ "-policy anyPolicy",
+ "True", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.12.3.1",
+ "inhibitAnyPolicy Test3",
+ "-policy anyPolicy",
+ "True", "$nist1", "$nist1", 0
+ ],
+ [
+ "4.12.3.2",
+ "inhibitAnyPolicy Test3",
+ "-policy anyPolicy -inhibit_any",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.12.4",
+ "Invalid inhibitAnyPolicy Test4",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.12.5",
+ "Invalid inhibitAnyPolicy Test5",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [
+ "4.12.6",
+ "Invalid inhibitAnyPolicy Test6",
+ "-policy anyPolicy",
+ "True", "<empty>", "<empty>", 43
+ ],
+ [ "4.12.7", "Valid Self-Issued inhibitAnyPolicy Test7", 0 ],
+ [ "4.12.8", "Invalid Self-Issued inhibitAnyPolicy Test8", 43 ],
+ [ "4.12.9", "Valid Self-Issued inhibitAnyPolicy Test9", 0 ],
+ [ "4.12.10", "Invalid Self-Issued inhibitAnyPolicy Test10", 43 ],
+ [ "4.13", "Name Constraints" ],
+ [ "4.13.1", "Valid DN nameConstraints Test1", 0 ],
+ [ "4.13.2", "Invalid DN nameConstraints Test2", 47 ],
+ [ "4.13.3", "Invalid DN nameConstraints Test3", 47 ],
+ [ "4.13.4", "Valid DN nameConstraints Test4", 0 ],
+ [ "4.13.5", "Valid DN nameConstraints Test5", 0 ],
+ [ "4.13.6", "Valid DN nameConstraints Test6", 0 ],
+ [ "4.13.7", "Invalid DN nameConstraints Test7", 48 ],
+ [ "4.13.8", "Invalid DN nameConstraints Test8", 48 ],
+ [ "4.13.9", "Invalid DN nameConstraints Test9", 48 ],
+ [ "4.13.10", "Invalid DN nameConstraints Test10", 48 ],
+ [ "4.13.11", "Valid DN nameConstraints Test11", 0 ],
+ [ "4.13.12", "Invalid DN nameConstraints Test12", 47 ],
+ [ "4.13.13", "Invalid DN nameConstraints Test13", 47 ],
+ [ "4.13.14", "Valid DN nameConstraints Test14", 0 ],
+ [ "4.13.15", "Invalid DN nameConstraints Test15", 48 ],
+ [ "4.13.16", "Invalid DN nameConstraints Test16", 48 ],
+ [ "4.13.17", "Invalid DN nameConstraints Test17", 48 ],
+ [ "4.13.18", "Valid DN nameConstraints Test18", 0 ],
+ [ "4.13.19", "Valid Self-Issued DN nameConstraints Test19", 0 ],
+ [ "4.13.20", "Invalid Self-Issued DN nameConstraints Test20", 47 ],
+ [ "4.13.21", "Valid RFC822 nameConstraints Test21", 0 ],
+ [ "4.13.22", "Invalid RFC822 nameConstraints Test22", 47 ],
+ [ "4.13.23", "Valid RFC822 nameConstraints Test23", 0 ],
+ [ "4.13.24", "Invalid RFC822 nameConstraints Test24", 47 ],
+ [ "4.13.25", "Valid RFC822 nameConstraints Test25", 0 ],
+ [ "4.13.26", "Invalid RFC822 nameConstraints Test26", 48 ],
+ [ "4.13.27", "Valid DN and RFC822 nameConstraints Test27", 0 ],
+ [ "4.13.28", "Invalid DN and RFC822 nameConstraints Test28", 47 ],
+ [ "4.13.29", "Invalid DN and RFC822 nameConstraints Test29", 47 ],
+ [ "4.13.30", "Valid DNS nameConstraints Test30", 0 ],
+ [ "4.13.31", "Invalid DNS nameConstraints Test31", 47 ],
+ [ "4.13.32", "Valid DNS nameConstraints Test32", 0 ],
+ [ "4.13.33", "Invalid DNS nameConstraints Test33", 48 ],
+ [ "4.13.34", "Valid URI nameConstraints Test34", 0 ],
+ [ "4.13.35", "Invalid URI nameConstraints Test35", 47 ],
+ [ "4.13.36", "Valid URI nameConstraints Test36", 0 ],
+ [ "4.13.37", "Invalid URI nameConstraints Test37", 48 ],
+ [ "4.13.38", "Invalid DNS nameConstraints Test38", 47 ],
+ [ "4.14", "Distribution Points" ],
+ [ "4.14.1", "Valid distributionPoint Test1", 0 ],
+ [ "4.14.2", "Invalid distributionPoint Test2", 23 ],
+ [ "4.14.3", "Invalid distributionPoint Test3", 44 ],
+ [ "4.14.4", "Valid distributionPoint Test4", 0 ],
+ [ "4.14.5", "Valid distributionPoint Test5", 0 ],
+ [ "4.14.6", "Invalid distributionPoint Test6", 23 ],
+ [ "4.14.7", "Valid distributionPoint Test7", 0 ],
+ [ "4.14.8", "Invalid distributionPoint Test8", 44 ],
+ [ "4.14.9", "Invalid distributionPoint Test9", 44 ],
+ [ "4.14.10", "Valid No issuingDistributionPoint Test10", 0 ],
+ [ "4.14.11", "Invalid onlyContainsUserCerts CRL Test11", 44 ],
+ [ "4.14.12", "Invalid onlyContainsCACerts CRL Test12", 44 ],
+ [ "4.14.13", "Valid onlyContainsCACerts CRL Test13", 0 ],
+ [ "4.14.14", "Invalid onlyContainsAttributeCerts Test14", 44 ],
+ [ "4.14.15", "Invalid onlySomeReasons Test15", 23 ],
+ [ "4.14.16", "Invalid onlySomeReasons Test16", 23 ],
+ [ "4.14.17", "Invalid onlySomeReasons Test17", 3 ],
+ [ "4.14.18", "Valid onlySomeReasons Test18", 0 ],
+ [ "4.14.19", "Valid onlySomeReasons Test19", 0 ],
+ [ "4.14.20", "Invalid onlySomeReasons Test20", 23 ],
+ [ "4.14.21", "Invalid onlySomeReasons Test21", 23 ],
+ [ "4.14.22", "Valid IDP with indirectCRL Test22", 0 ],
+ [ "4.14.23", "Invalid IDP with indirectCRL Test23", 23 ],
+ [ "4.14.24", "Valid IDP with indirectCRL Test24", 0 ],
+ [ "4.14.25", "Valid IDP with indirectCRL Test25", 0 ],
+ [ "4.14.26", "Invalid IDP with indirectCRL Test26", 44 ],
+ [ "4.14.27", "Invalid cRLIssuer Test27", 3 ],
+ [ "4.14.28", "Valid cRLIssuer Test28", 0 ],
+ [ "4.14.29", "Valid cRLIssuer Test29", 0 ],
+
+ # Although this test is valid it has a circular dependency. As a result
+ # an attempt is made to reursively checks a CRL path and rejected due to
+ # a CRL path validation error. PKITS notes suggest this test does not
+ # need to be run due to this issue.
+ [ "4.14.30", "Valid cRLIssuer Test30", 54 ],
+ [ "4.14.31", "Invalid cRLIssuer Test31", 23 ],
+ [ "4.14.32", "Invalid cRLIssuer Test32", 23 ],
+ [ "4.14.33", "Valid cRLIssuer Test33", 0 ],
+ [ "4.14.34", "Invalid cRLIssuer Test34", 23 ],
+ [ "4.14.35", "Invalid cRLIssuer Test35", 44 ],
+ [ "4.15", "Delta-CRLs" ],
+ [ "4.15.1", "Invalid deltaCRLIndicator No Base Test1", 3 ],
+ [ "4.15.2", "Valid delta-CRL Test2", 0 ],
+ [ "4.15.3", "Invalid delta-CRL Test3", 23 ],
+ [ "4.15.4", "Invalid delta-CRL Test4", 23 ],
+ [ "4.15.5", "Valid delta-CRL Test5", 0 ],
+ [ "4.15.6", "Invalid delta-CRL Test6", 23 ],
+ [ "4.15.7", "Valid delta-CRL Test7", 0 ],
+ [ "4.15.8", "Valid delta-CRL Test8", 0 ],
+ [ "4.15.9", "Invalid delta-CRL Test9", 23 ],
+ [ "4.15.10", "Invalid delta-CRL Test10", 12 ],
+ [ "4.16", "Private Certificate Extensions" ],
+ [ "4.16.1", "Valid Unknown Not Critical Certificate Extension Test1", 0 ],
+ [ "4.16.2", "Invalid Unknown Critical Certificate Extension Test2", 34 ],
+);
+
+
+my $verbose = 1;
+
+my $numtest = 0;
+my $numfail = 0;
+
+my $ossl = "ossl/apps/openssl";
+
+my $ossl_cmd = "$ossl_path cms -verify -verify_retcode ";
+$ossl_cmd .= "-CAfile pkitsta.pem -crl_check_all -x509_strict ";
+$ossl_cmd .= "-policy_check -extended_crl -use_deltas -out /dev/null 2>&1 ";
+
+system "$ossl_path x509 -inform DER -in $pkitsta -out pkitsta.pem";
+
+die "Can't create trust anchor file" if $?;
+
+print "Running PKITS tests:\n" if $verbose;
+
+foreach (@testlists) {
+ my $argnum = @$_;
+ if ( $argnum == 2 ) {
+ my ( $tnum, $title ) = @$_;
+ print "$tnum $title\n" if $verbose;
+ }
+ elsif ( $argnum == 3 ) {
+ my ( $tnum, $title, $exp_ret ) = @$_;
+ my $filename = $title;
+ $exp_ret += 32 if $exp_ret;
+ $filename =~ tr/ -//d;
+ $filename = "Signed${filename}.eml";
+ if ( !-f "$pkitsdir/$filename" ) {
+ print "\"$filename\" not found\n";
+ }
+ else {
+ my $ret;
+ my $test_fail = 0;
+ my $errmsg = "";
+ my $cmd = $ossl_cmd;
+ $cmd .= "-in $pkitsdir/$filename -policy anyPolicy";
+ my $cmdout = `$cmd`;
+ $ret = $? >> 8;
+ if ( $? & 0xff ) {
+ $errmsg .= "Abnormal OpenSSL termination\n";
+ $test_fail = 1;
+ }
+ if ( $exp_ret != $ret ) {
+ $errmsg .= "Return code:$ret, ";
+ $errmsg .= "expected $exp_ret\n";
+ $test_fail = 1;
+ }
+ if ($test_fail) {
+ print "$tnum $title : Failed!\n";
+ print "Filename: $pkitsdir/$filename\n";
+ print $errmsg;
+ print "Command output:\n$cmdout\n";
+ $numfail++;
+ }
+ $numtest++;
+ }
+ }
+ elsif ( $argnum == 7 ) {
+ my ( $tnum, $title, $exargs, $exp_epol, $exp_aset, $exp_uset, $exp_ret )
+ = @$_;
+ my $filename = $title;
+ $exp_ret += 32 if $exp_ret;
+ $filename =~ tr/ -//d;
+ $filename = "Signed${filename}.eml";
+ if ( !-f "$pkitsdir/$filename" ) {
+ print "\"$filename\" not found\n";
+ }
+ else {
+ my $ret;
+ my $cmdout = "";
+ my $errmsg = "";
+ my $epol = "";
+ my $aset = "";
+ my $uset = "";
+ my $pol = -1;
+ my $test_fail = 0;
+ my $cmd = $ossl_cmd;
+ $cmd .= "-in $pkitsdir/$filename $exargs -policy_print";
+ @oparr = `$cmd`;
+ $ret = $? >> 8;
+
+ if ( $? & 0xff ) {
+ $errmsg .= "Abnormal OpenSSL termination\n";
+ $test_fail = 1;
+ }
+ foreach (@oparr) {
+ my $test_failed = 0;
+ $cmdout .= $_;
+ if (/^Require explicit Policy: (.*)$/) {
+ $epol = $1;
+ }
+ if (/^Authority Policies/) {
+ if (/empty/) {
+ $aset = "<empty>";
+ }
+ else {
+ $pol = 1;
+ }
+ }
+ $test_fail = 1 if (/leak/i);
+ if (/^User Policies/) {
+ if (/empty/) {
+ $uset = "<empty>";
+ }
+ else {
+ $pol = 2;
+ }
+ }
+ if (/\s+Policy: (.*)$/) {
+ if ( $pol == 1 ) {
+ $aset .= ":" if $aset ne "";
+ $aset .= $1;
+ }
+ elsif ( $pol == 2 ) {
+ $uset .= ":" if $uset ne "";
+ $uset .= $1;
+ }
+ }
+ }
+
+ if ( $epol ne $exp_epol ) {
+ $errmsg .= "Explicit policy:$epol, ";
+ $errmsg .= "expected $exp_epol\n";
+ $test_fail = 1;
+ }
+ if ( $aset ne $exp_aset ) {
+ $errmsg .= "Authority policy set :$aset, ";
+ $errmsg .= "expected $exp_aset\n";
+ $test_fail = 1;
+ }
+ if ( $uset ne $exp_uset ) {
+ $errmsg .= "User policy set :$uset, ";
+ $errmsg .= "expected $exp_uset\n";
+ $test_fail = 1;
+ }
+
+ if ( $exp_ret != $ret ) {
+ print "Return code:$ret, expected $exp_ret\n";
+ $test_fail = 1;
+ }
+
+ if ($test_fail) {
+ print "$tnum $title : Failed!\n";
+ print "Filename: $pkitsdir/$filename\n";
+ print "Command output:\n$cmdout\n";
+ $numfail++;
+ }
+ $numtest++;
+ }
+ }
+}
+
+if ($numfail) {
+ print "$numfail tests failed out of $numtest\n";
+}
+else {
+ print "All Tests Successful.\n";
+}
+
+unlink "pkitsta.pem";
+
diff --git a/lib/libssl/test/test_padlock b/lib/libssl/test/test_padlock
new file mode 100755
index 00000000000..5c0f21043ce
--- /dev/null
+++ b/lib/libssl/test/test_padlock
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+PROG=$1
+
+if [ -x $PROG ]; then
+ if expr "x`$PROG version`" : "xOpenSSL" > /dev/null; then
+ :
+ else
+ echo "$PROG is not OpenSSL executable"
+ exit 1
+ fi
+else
+ echo "$PROG is not executable"
+ exit 1;
+fi
+
+if $PROG engine padlock | grep -v no-ACE; then
+
+ HASH=`cat $PROG | $PROG dgst -hex`
+
+ ACE_ALGS=" aes-128-ecb aes-192-ecb aes-256-ecb \
+ aes-128-cbc aes-192-cbc aes-256-cbc \
+ aes-128-cfb aes-192-cfb aes-256-cfb \
+ aes-128-ofb aes-192-ofb aes-256-ofb"
+
+ nerr=0
+
+ for alg in $ACE_ALGS; do
+ echo $alg
+ TEST=`( cat $PROG | \
+ $PROG enc -e -k "$HASH" -$alg -bufsize 999 -engine padlock | \
+ $PROG enc -d -k "$HASH" -$alg | \
+ $PROG dgst -hex ) 2>/dev/null`
+ if [ "$TEST" != "$HASH" ]; then
+ echo "-$alg encrypt test failed"
+ nerr=`expr $nerr + 1`
+ fi
+ TEST=`( cat $PROG | \
+ $PROG enc -e -k "$HASH" -$alg | \
+ $PROG enc -d -k "$HASH" -$alg -bufsize 999 -engine padlock | \
+ $PROG dgst -hex ) 2>/dev/null`
+ if [ "$TEST" != "$HASH" ]; then
+ echo "-$alg decrypt test failed"
+ nerr=`expr $nerr + 1`
+ fi
+ TEST=`( cat $PROG | \
+ $PROG enc -e -k "$HASH" -$alg -engine padlock | \
+ $PROG enc -d -k "$HASH" -$alg -engine padlock | \
+ $PROG dgst -hex ) 2>/dev/null`
+ if [ "$TEST" != "$HASH" ]; then
+ echo "-$alg en/decrypt test failed"
+ nerr=`expr $nerr + 1`
+ fi
+ done
+
+ if [ $nerr -gt 0 ]; then
+ echo "PadLock ACE test failed."
+ exit 1;
+ fi
+else
+ echo "PadLock ACE is not available"
+fi
+
+exit 0
diff --git a/lib/libssl/test/testtsa b/lib/libssl/test/testtsa
new file mode 100644
index 00000000000..bb653b5f73d
--- /dev/null
+++ b/lib/libssl/test/testtsa
@@ -0,0 +1,238 @@
+#!/bin/sh
+
+#
+# A few very basic tests for the 'ts' time stamping authority command.
+#
+
+SH="/bin/sh"
+if test "$OSTYPE" = msdosdjgpp; then
+ PATH="../apps\;$PATH"
+else
+ PATH="../apps:$PATH"
+fi
+export SH PATH
+
+OPENSSL_CONF="../CAtsa.cnf"
+export OPENSSL_CONF
+# Because that's what ../apps/CA.sh really looks at
+SSLEAY_CONFIG="-config $OPENSSL_CONF"
+export SSLEAY_CONFIG
+
+OPENSSL="`pwd`/../util/opensslwrap.sh"
+export OPENSSL
+
+error () {
+
+ echo "TSA test failed!" >&2
+ exit 1
+}
+
+setup_dir () {
+
+ rm -rf tsa 2>/dev/null
+ mkdir tsa
+ cd ./tsa
+}
+
+clean_up_dir () {
+
+ cd ..
+ rm -rf tsa
+}
+
+create_ca () {
+
+ echo "Creating a new CA for the TSA tests..."
+ TSDNSECT=ts_ca_dn
+ export TSDNSECT
+ ../../util/shlib_wrap.sh ../../apps/openssl req -new -x509 -nodes \
+ -out tsaca.pem -keyout tsacakey.pem
+ test $? != 0 && error
+}
+
+create_tsa_cert () {
+
+ INDEX=$1
+ export INDEX
+ EXT=$2
+ TSDNSECT=ts_cert_dn
+ export TSDNSECT
+
+ ../../util/shlib_wrap.sh ../../apps/openssl req -new \
+ -out tsa_req${INDEX}.pem -keyout tsa_key${INDEX}.pem
+ test $? != 0 && error
+echo Using extension $EXT
+ ../../util/shlib_wrap.sh ../../apps/openssl x509 -req \
+ -in tsa_req${INDEX}.pem -out tsa_cert${INDEX}.pem \
+ -CA tsaca.pem -CAkey tsacakey.pem -CAcreateserial \
+ -extfile $OPENSSL_CONF -extensions $EXT
+ test $? != 0 && error
+}
+
+print_request () {
+
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -query -in $1 -text
+}
+
+create_time_stamp_request1 () {
+
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -query -data ../testtsa -policy tsa_policy1 -cert -out req1.tsq
+ test $? != 0 && error
+}
+
+create_time_stamp_request2 () {
+
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -query -data ../testtsa -policy tsa_policy2 -no_nonce \
+ -out req2.tsq
+ test $? != 0 && error
+}
+
+create_time_stamp_request3 () {
+
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -query -data ../CAtsa.cnf -no_nonce -out req3.tsq
+ test $? != 0 && error
+}
+
+print_response () {
+
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -reply -in $1 -text
+ test $? != 0 && error
+}
+
+create_time_stamp_response () {
+
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -reply -section $3 -queryfile $1 -out $2
+ test $? != 0 && error
+}
+
+time_stamp_response_token_test () {
+
+ RESPONSE2=$2.copy.tsr
+ TOKEN_DER=$2.token.der
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -reply -in $2 -out $TOKEN_DER -token_out
+ test $? != 0 && error
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -reply -in $TOKEN_DER -token_in -out $RESPONSE2
+ test $? != 0 && error
+ cmp $RESPONSE2 $2
+ test $? != 0 && error
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -reply -in $2 -text -token_out
+ test $? != 0 && error
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -reply -in $TOKEN_DER -token_in -text -token_out
+ test $? != 0 && error
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -reply -queryfile $1 -text -token_out
+ test $? != 0 && error
+}
+
+verify_time_stamp_response () {
+
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -verify -queryfile $1 -in $2 -CAfile tsaca.pem \
+ -untrusted tsa_cert1.pem
+ test $? != 0 && error
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -verify -data $3 -in $2 -CAfile tsaca.pem \
+ -untrusted tsa_cert1.pem
+ test $? != 0 && error
+}
+
+verify_time_stamp_token () {
+
+ # create the token from the response first
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -reply -in $2 -out $2.token -token_out
+ test $? != 0 && error
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -verify -queryfile $1 -in $2.token -token_in \
+ -CAfile tsaca.pem -untrusted tsa_cert1.pem
+ test $? != 0 && error
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -verify -data $3 -in $2.token -token_in \
+ -CAfile tsaca.pem -untrusted tsa_cert1.pem
+ test $? != 0 && error
+}
+
+verify_time_stamp_response_fail () {
+
+ ../../util/shlib_wrap.sh ../../apps/openssl ts -verify -queryfile $1 -in $2 -CAfile tsaca.pem \
+ -untrusted tsa_cert1.pem
+ # Checks if the verification failed, as it should have.
+ test $? = 0 && error
+ echo Ok
+}
+
+# main functions
+
+echo "Setting up TSA test directory..."
+setup_dir
+
+echo "Creating CA for TSA tests..."
+create_ca
+
+echo "Creating tsa_cert1.pem TSA server cert..."
+create_tsa_cert 1 tsa_cert
+
+echo "Creating tsa_cert2.pem non-TSA server cert..."
+create_tsa_cert 2 non_tsa_cert
+
+echo "Creating req1.req time stamp request for file testtsa..."
+create_time_stamp_request1
+
+echo "Printing req1.req..."
+print_request req1.tsq
+
+echo "Generating valid response for req1.req..."
+create_time_stamp_response req1.tsq resp1.tsr tsa_config1
+
+echo "Printing response..."
+print_response resp1.tsr
+
+echo "Verifying valid response..."
+verify_time_stamp_response req1.tsq resp1.tsr ../testtsa
+
+echo "Verifying valid token..."
+verify_time_stamp_token req1.tsq resp1.tsr ../testtsa
+
+# The tests below are commented out, because invalid signer certificates
+# can no longer be specified in the config file.
+
+# echo "Generating _invalid_ response for req1.req..."
+# create_time_stamp_response req1.tsq resp1_bad.tsr tsa_config2
+
+# echo "Printing response..."
+# print_response resp1_bad.tsr
+
+# echo "Verifying invalid response, it should fail..."
+# verify_time_stamp_response_fail req1.tsq resp1_bad.tsr
+
+echo "Creating req2.req time stamp request for file testtsa..."
+create_time_stamp_request2
+
+echo "Printing req2.req..."
+print_request req2.tsq
+
+echo "Generating valid response for req2.req..."
+create_time_stamp_response req2.tsq resp2.tsr tsa_config1
+
+echo "Checking '-token_in' and '-token_out' options with '-reply'..."
+time_stamp_response_token_test req2.tsq resp2.tsr
+
+echo "Printing response..."
+print_response resp2.tsr
+
+echo "Verifying valid response..."
+verify_time_stamp_response req2.tsq resp2.tsr ../testtsa
+
+echo "Verifying response against wrong request, it should fail..."
+verify_time_stamp_response_fail req1.tsq resp2.tsr
+
+echo "Verifying response against wrong request, it should fail..."
+verify_time_stamp_response_fail req2.tsq resp1.tsr
+
+echo "Creating req3.req time stamp request for file CAtsa.cnf..."
+create_time_stamp_request3
+
+echo "Printing req3.req..."
+print_request req3.tsq
+
+echo "Verifying response against wrong request, it should fail..."
+verify_time_stamp_response_fail req3.tsq resp1.tsr
+
+echo "Cleaning up..."
+clean_up_dir
+
+exit 0
diff --git a/lib/libssl/test/testtsa.com b/lib/libssl/test/testtsa.com
new file mode 100644
index 00000000000..e3c586f14a2
--- /dev/null
+++ b/lib/libssl/test/testtsa.com
@@ -0,0 +1,248 @@
+$!
+$! A few very basic tests for the 'ts' time stamping authority command.
+$!
+$
+$ __arch := VAX
+$ if f$getsyi("cpu") .ge. 128 then -
+ __arch = f$edit( f$getsyi( "ARCH_NAME"), "UPCASE")
+$ if __arch .eqs. "" then __arch := UNK
+$ exe_dir := sys$disk:[-.'__arch'.exe.apps]
+$
+$ openssl := mcr 'f$parse(exe_dir+"openssl.exe")'
+$ OPENSSL_CONF := [-]CAtsa.cnf
+$ ! Because that's what ../apps/CA.sh really looks at
+$ SSLEAY_CONFIG = "-config " + OPENSSL_CONF
+$
+$ error:
+$ subroutine
+$ write sys$error "TSA test failed!"
+$ exit 3
+$ endsubroutine
+$
+$ setup_dir:
+$ subroutine
+$
+$ if f$search("tsa.dir") .nes ""
+$ then
+$ @[-.util]deltree [.tsa]*.*
+$ set file/prot=(S:RWED,O:RWED,G:RWED,W:RWED) tsa.dir;*
+$ delete tsa.dir;*
+$ endif
+$
+$ create/dir [.tsa]
+$ set default [.tsa]
+$ endsubroutine
+$
+$ clean_up_dir:
+$ subroutine
+$
+$ set default [-]
+$ @[-.util]deltree [.tsa]*.*
+$ set file/prot=(S:RWED,O:RWED,G:RWED,W:RWED) tsa.dir;*
+$ delete tsa.dir;*
+$ endsubroutine
+$
+$ create_ca:
+$ subroutine
+$
+$ write sys$output "Creating a new CA for the TSA tests..."
+$ TSDNSECT = "ts_ca_dn"
+$ openssl req -new -x509 -nodes -
+ -out tsaca.pem -keyout tsacakey.pem
+$ if $severity .ne. 1 then call error
+$ endsubroutine
+$
+$ create_tsa_cert:
+$ subroutine
+$
+$ INDEX=p1
+$ EXT=p2
+$ TSDNSECT = "ts_cert_dn"
+$
+$ openssl req -new -
+ -out tsa_req'INDEX'.pem -keyout tsa_key'INDEX'.pem
+$ if $severity .ne. 1 then call error
+$
+$ write sys$output "Using extension ''EXT'"
+$ openssl x509 -req -
+ -in tsa_req'INDEX'.pem -out tsa_cert'INDEX'.pem -
+ "-CA" tsaca.pem "-CAkey" tsacakey.pem "-CAcreateserial" -
+ -extfile 'OPENSSL_CONF' -extensions "''EXT'"
+$ if $severity .ne. 1 then call error
+$ endsubroutine
+$
+$ print_request:
+$ subroutine
+$
+$ openssl ts -query -in 'p1' -text
+$ endsubroutine
+$
+$ create_time_stamp_request1: subroutine
+$
+$ openssl ts -query -data [-]testtsa.com -policy tsa_policy1 -
+ -cert -out req1.tsq
+$ if $severity .ne. 1 then call error
+$ endsubroutine
+$
+$ create_time_stamp_request2: subroutine
+$
+$ openssl ts -query -data [-]testtsa.com -policy tsa_policy2 -
+ -no_nonce -out req2.tsq
+$ if $severity .ne. 1 then call error
+$ endsubroutine
+$
+$ create_time_stamp_request3: subroutine
+$
+$ openssl ts -query -data [-]CAtsa.cnf -no_nonce -out req3.tsq
+$ if $severity .ne. 1 then call error
+$ endsubroutine
+$
+$ print_response:
+$ subroutine
+$
+$ openssl ts -reply -in 'p1' -text
+$ if $severity .ne. 1 then call error
+$ endsubroutine
+$
+$ create_time_stamp_response:
+$ subroutine
+$
+$ openssl ts -reply -section 'p3' -queryfile 'p1' -out 'p2'
+$ if $severity .ne. 1 then call error
+$ endsubroutine
+$
+$ time_stamp_response_token_test:
+$ subroutine
+$
+$ RESPONSE2:='p2'.copy_tsr
+$ TOKEN_DER:='p2'.token_der
+$ openssl ts -reply -in 'p2' -out 'TOKEN_DER' -token_out
+$ if $severity .ne. 1 then call error
+$ openssl ts -reply -in 'TOKEN_DER' -token_in -out 'RESPONSE2'
+$ if $severity .ne. 1 then call error
+$ backup/compare 'RESPONSE2' 'p2'
+$ if $severity .ne. 1 then call error
+$ openssl ts -reply -in 'p2' -text -token_out
+$ if $severity .ne. 1 then call error
+$ openssl ts -reply -in 'TOKEN_DER' -token_in -text -token_out
+$ if $severity .ne. 1 then call error
+$ openssl ts -reply -queryfile 'p1' -text -token_out
+$ if $severity .ne. 1 then call error
+$ endsubroutine
+$
+$ verify_time_stamp_response:
+$ subroutine
+$
+$ openssl ts -verify -queryfile 'p1' -in 'p2' -
+ "-CAfile" tsaca.pem -untrusted tsa_cert1.pem
+$ if $severity .ne. 1 then call error
+$ openssl ts -verify -data 'p3' -in 'p2' -
+ "-CAfile" tsaca.pem -untrusted tsa_cert1.pem
+$ if $severity .ne. 1 then call error
+$ endsubroutine
+$
+$ verify_time_stamp_token:
+$ subroutine
+$
+$ ! create the token from the response first
+$ openssl ts -reply -in 'p2' -out 'p2'.token -token_out
+$ if $severity .ne. 1 then call error
+$ openssl ts -verify -queryfile 'p1' -in 'p2'.token -token_in -
+ "-CAfile" tsaca.pem -untrusted tsa_cert1.pem
+$ if $severity .ne. 1 then call error
+$ openssl ts -verify -data 'p3' -in 'p2'.token -token_in -
+ "-CAfile" tsaca.pem -untrusted tsa_cert1.pem
+$ if $severity .ne. 1 then call error
+$ endsubroutine
+$
+$ verify_time_stamp_response_fail:
+$ subroutine
+$
+$ openssl ts -verify -queryfile 'p1' -in 'p2' -
+ "-CAfile" tsaca.pem -untrusted tsa_cert1.pem
+$ ! Checks if the verification failed, as it should have.
+$ if $severity .eq. 1 then call error
+$ write sys$output "Ok"
+$ endsubroutine
+$
+$ ! Main body ----------------------------------------------------------
+$
+$ write sys$output "Setting up TSA test directory..."
+$ call setup_dir
+$
+$ write sys$output "Creating CA for TSA tests..."
+$ call create_ca
+$
+$ write sys$output "Creating tsa_cert1.pem TSA server cert..."
+$ call create_tsa_cert 1 "tsa_cert"
+$
+$ write sys$output "Creating tsa_cert2.pem non-TSA server cert..."
+$ call create_tsa_cert 2 "non_tsa_cert"
+$
+$ write sys$output "Creating req1.req time stamp request for file testtsa..."
+$ call create_time_stamp_request1
+$
+$ write sys$output "Printing req1.req..."
+$ call print_request req1.tsq
+$
+$ write sys$output "Generating valid response for req1.req..."
+$ call create_time_stamp_response req1.tsq resp1.tsr tsa_config1
+$
+$ write sys$output "Printing response..."
+$ call print_response resp1.tsr
+$
+$ write sys$output "Verifying valid response..."
+$ call verify_time_stamp_response req1.tsq resp1.tsr [-]testtsa.com
+$
+$ write sys$output "Verifying valid token..."
+$ call verify_time_stamp_token req1.tsq resp1.tsr [-]testtsa.com
+$
+$ ! The tests below are commented out, because invalid signer certificates
+$ ! can no longer be specified in the config file.
+$
+$ ! write sys$output "Generating _invalid_ response for req1.req..."
+$ ! call create_time_stamp_response req1.tsq resp1_bad.tsr tsa_config2
+$
+$ ! write sys$output "Printing response..."
+$ ! call print_response resp1_bad.tsr
+$
+$ ! write sys$output "Verifying invalid response, it should fail..."
+$ ! call verify_time_stamp_response_fail req1.tsq resp1_bad.tsr
+$
+$ write sys$output "Creating req2.req time stamp request for file testtsa..."
+$ call create_time_stamp_request2
+$
+$ write sys$output "Printing req2.req..."
+$ call print_request req2.tsq
+$
+$ write sys$output "Generating valid response for req2.req..."
+$ call create_time_stamp_response req2.tsq resp2.tsr tsa_config1
+$
+$ write sys$output "Checking '-token_in' and '-token_out' options with '-reply'..."
+$ call time_stamp_response_token_test req2.tsq resp2.tsr
+$
+$ write sys$output "Printing response..."
+$ call print_response resp2.tsr
+$
+$ write sys$output "Verifying valid response..."
+$ call verify_time_stamp_response req2.tsq resp2.tsr [-]testtsa.com
+$
+$ write sys$output "Verifying response against wrong request, it should fail..."
+$ call verify_time_stamp_response_fail req1.tsq resp2.tsr
+$
+$ write sys$output "Verifying response against wrong request, it should fail..."
+$ call verify_time_stamp_response_fail req2.tsq resp1.tsr
+$
+$ write sys$output "Creating req3.req time stamp request for file CAtsa.cnf..."
+$ call create_time_stamp_request3
+$
+$ write sys$output "Printing req3.req..."
+$ call print_request req3.tsq
+$
+$ write sys$output "Verifying response against wrong request, it should fail..."
+$ call verify_time_stamp_response_fail req3.tsq resp1.tsr
+$
+$ write sys$output "Cleaning up..."
+$ call clean_up_dir
+$
+$ exit