Fixed valgrind complaint due to BN_consttime_swap reading uninitialised data.
[openssl.git] / test / testtsa
index 746aa258d6ab360cc37e62758bf9d97592498899..bb653b5f73d6f5761ab564e02ddc035bd4cecb01 100644 (file)
@@ -5,18 +5,25 @@
 #
 
 SH="/bin/sh"
-PATH=../../apps:$PATH
+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="../util/opensslwrap.sh"
+OPENSSL="`pwd`/../util/opensslwrap.sh"
 export OPENSSL
 
 error () {
 
-    echo "ERROR DURING TSA TESTS!!!!!!!!!!!!!!!!" >&2
+    echo "TSA test failed!" >&2
     exit 1
 }
 
@@ -36,36 +43,29 @@ clean_up_dir () {
 create_ca () {
 
     echo "Creating a new CA for the TSA tests..."
-    /bin/rm -fr demoCA
-    $SH ../../apps/CA.sh -newca <<EOF
-
-HU
-Budapest
-Budapest
-Gov-CA Ltd.
-ca1
-EOF
+    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
-    ../../util/shlib_wrap.sh ../../apps/openssl req -new -out tsa_req${INDEX}.pem -keyout tsa_key${INDEX}.pem <<EOF
-HU
-Budapest
-Buda
-Hun-TSA Ltd.
-tsa${INDEX}
-EOF
-    test $? != 0 && error
+    TSDNSECT=ts_cert_dn
+    export TSDNSECT   
 
-    ../../util/shlib_wrap.sh ../../apps/openssl ca -in tsa_req${INDEX}.pem -out tsa_cert${INDEX}.pem \
-       -extensions $EXT <<EOF
-y
-y
-EOF
+    ../../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
 }
 
@@ -125,10 +125,10 @@ time_stamp_response_token_test () {
 
 verify_time_stamp_response () {
 
-    ../../util/shlib_wrap.sh ../../apps/openssl ts -verify -queryfile $1 -in $2 -CAfile demoCA/cacert.pem \
+    ../../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 demoCA/cacert.pem \
+    ../../util/shlib_wrap.sh ../../apps/openssl ts -verify -data $3 -in $2 -CAfile tsaca.pem \
        -untrusted tsa_cert1.pem
     test $? != 0 && error
 }
@@ -139,19 +139,20 @@ verify_time_stamp_token () {
     ../../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 demoCA/cacert.pem -untrusted tsa_cert1.pem
+       -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 demoCA/cacert.pem -untrusted tsa_cert1.pem
+       -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 demoCA/cacert.pem \
+    ../../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
+    test $? = 0 && error
+    echo Ok
 }
 
 # main functions