Skip to content

Commit

Permalink
Merge pull request tpm2-software#104 from gwei3/fix-test-scripts-2016…
Browse files Browse the repository at this point in the history
…1013

test: fix test scripts issues
  • Loading branch information
Gang(Jimmy) Wei authored Oct 13, 2016
2 parents 5318f2a + e73835c commit ae322d5
Show file tree
Hide file tree
Showing 38 changed files with 124 additions and 169 deletions.
6 changes: 3 additions & 3 deletions test/test_algs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ for halg_p in 0x0004 0x000B 0x000C 0x000D 0x0012

tpm2_createprimary -A e -g $halg_p -G $kalg_p -C context.p_"$halg_p"_"$kalg_p"
if [ $? != 0 ];then
echo "createprimary for context.p_"$halg_p"_"$kalg_p" fail, pelase check the environment or parameters!"
echo "createprimary for context.p_"$halg_p"_"$kalg_p" fail, please check the environment or parameters!"
fi

############create & load key context############
Expand All @@ -59,14 +59,14 @@ for halg_p in 0x0004 0x000B 0x000C 0x000D 0x0012
tpm2_create -g $halg_c -G $kalg_c -o opu_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" -O opr_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" -c context.p_"$halg_p"_"$kalg_p"

if [ $? != 0 ];then
echo "create used context.p_"$halg_p"_"$kalg_p" with algs:"$halg_c""$kalg_c" fail, pelase check the environment or parameters!"
echo "create used context.p_"$halg_p"_"$kalg_p" with algs:"$halg_c""$kalg_c" fail, please check the environment or parameters!"
echo "create used context.p_"$halg_p"_"$kalg_p" with algs:"$halg_c""$kalg_c" fail" >>create_error.log

else

tpm2_load -c context.p_"$halg_p"_"$kalg_p" -u opu_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" -r opr_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" -n name.load_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" -C context_load_"$halg_p""$kalg_p"_"$halg_c""$kalg_c"
if [ $? != 0 ];then
echo "load for context.p_"$halg_p"_"$kalg_p" fail, pelase check the environment or parameters!"
echo "load for context.p_"$halg_p"_"$kalg_p" fail, please check the environment or parameters!"
echo "load context.p_"$halg_p"_"$kalg_p" for create context_load_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" fail" >>load_error.log
fi

Expand Down
17 changes: 12 additions & 5 deletions test/test_algs_tpm2_encryptdecrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,39 @@

context_p=
halg=
new_path=`dirname $0`
PATH="$PATH":"$new_path"

ctx_count=`ls |grep -c context_load`
if [ $ctx_count -le 1 ];then
echo "we should execute test_algs.sh first!"
wait 5
./test_algs.sh
test_algs.sh
fi

rm test_algs_encryptdecrypt_*.log

if [ ! -e "secret.data" ]
then
echo "12345678" > secret.data
fi

#for halg_p in 0x0004 0x000B 0x000C 0x000D 0x0012
for context_p in `ls context_load*`
do

./tpm2_encryptdecrypt -c $context_p -D NO -I secret.data -o endecrypt_"$context_p".f
tpm2_encryptdecrypt -c $context_p -D NO -I secret.data -o endecrypt_"$context_p".f


if [ $? != 0 ];then
echo "encryptdecrypt for endecrypt_"$context_p".f fail, pelase check the environment or parameters!"
echo "encryptdecrypt for endecrypt_"$context_p".f fail, please check the environment or parameters!"
echo "encryptdecrypt for endecrypt_"$context_p".f fail" >>test_encryptdecrypt_error.log
else
echo "encryptdecrypt for endecrypt_"$context_p".f pass" >>test_encryptdecrypt_pass.log
./tpm2_encryptdecrypt -c $context_p -D YES -I endecrypt_"$context_p".f -o decrypt_"$context_p".f
tpm2_encryptdecrypt -c $context_p -D YES -I endecrypt_"$context_p".f -o decrypt_"$context_p".f

if [ $? != 0 ];then
echo "encryptdecrypt for decrypt_"$context_p".f fail, pelase check the environment or parameters!"
echo "encryptdecrypt for decrypt_"$context_p".f fail, please check the environment or parameters!"
echo "encryptdecrypt for decrypt_"$context_p".f fail" >>test_encryptdecrypt_error.log
else
echo "encryptdecrypt for decrypt_"$context_p".f pass" >>test_encryptdecrypt_pass.log
Expand Down
4 changes: 2 additions & 2 deletions test/test_algs_tpm2_getpubak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ signAlg=

fail()
{
echo "$1 test fail, pelase check the environment or parameters!"
echo "$1 test fail, please check the environment or parameters!"
echo ""$1" fail" >>test_getpubak_error.log
}

Expand All @@ -68,7 +68,7 @@ for ak_alg in 0x0001 0x0008 0x0023
for signAlg in 0x0005 0x0014 0x0016 0x0018 0x001A 0x001B 0x001C
do

./tpm2_getpubak -E "$handle_ek" -k $handle_ak -g $ak_alg -D $digestAlg -s $signAlg -f ak.pub_"$ak_alg"_"$digestAlg"_"$signAlg" -n ak.name_"$ak_alg"_"$digestAlg"_"$signAlg"
tpm2_getpubak -E "$handle_ek" -k $handle_ak -g $ak_alg -D $digestAlg -s $signAlg -f ak.pub_"$ak_alg"_"$digestAlg"_"$signAlg" -n ak.name_"$ak_alg"_"$digestAlg"_"$signAlg"
if [ $? != 0 ];then
fail "Ak_alg_"$ak_alg"_"$digestAlg"_"$signAlg""
else
Expand Down
2 changes: 1 addition & 1 deletion test/test_algs_tpm2_getpubek.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ signAlg=

fail()
{
echo "getpubek for ek.pub_"$1" fail, pelase check the environment or parameters!"
echo "getpubek for ek.pub_"$1" fail, please check the environment or parameters!"
echo "getpubek for ek.pub_"$1" fail" >>test_getpubek_error.log
}

Expand Down
11 changes: 9 additions & 2 deletions test/test_algs_tpm2_hmac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,22 @@
context_p=
halg=
ctx_count=
new_path=`dirname $0`
PATH="$PATH":"$new_path"

ctx_count=`ls |grep -c context_load`
if [ $ctx_count -le 1 ];then
echo "we should execute test_algs.sh first!"
wait 5
./test_algs.sh
test_algs.sh
fi
rm -f test_hmac_*.log

if [ ! -e "secret.data" ]
then
echo "12345678" > secret.data
fi

#for halg_p in 0x0004 0x000B 0x000C 0x000D 0x0012
for context_p in `ls context_load*`
do
Expand All @@ -51,7 +58,7 @@ for context_p in `ls context_load*`
## echo "halg_p: "$halg_p" kalg_p: "$kalg_p"" >>test.log
tpm2_hmac -c $context_p -g $halg -I secret.data -o hmac_out_"$context_p"_"$halg_h"
if [ $? != 0 ];then
echo "hmac for hmac_out_"$context_p"_"$halg" fail, pelase check the environment or parameters!"
echo "hmac for hmac_out_"$context_p"_"$halg" fail, please check the environment or parameters!"
echo "hmac for hmac_out_"$context_p"_"$halg" fail" >>test_hmac_error.log
else
echo "hmac for hmac_out_"$context_p"_"$halg" pass" >>test_hmac_pass.log
Expand Down
6 changes: 4 additions & 2 deletions test/test_algs_tpm2_quote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
##before this script, you should make sure all kinds of context already loaded
context_p=
halg=
new_path=`dirname $0`
PATH="$PATH":"$new_path"

ctx_count=`ls |grep -c context_load`
if [ $ctx_count -le 1 ];then
echo "we should execute test_algs.sh first!"
wait 5
./test_algs.sh
test_algs.sh
fi


Expand All @@ -52,7 +54,7 @@ for context_p in `ls context_load*`

tpm2_quote -c $context_p -g $halg -l 16,17,18 -o quote_out_"$context_p"_"$halg_h"_"$halg"
if [ $? != 0 ];then
echo "quote for quote_"$context_p"_"$halg" fail, pelase check the environment or parameters!"
echo "quote for quote_"$context_p"_"$halg" fail, please check the environment or parameters!"
echo " quote for quote_"$context_p"_"$halg" fail" >>test_quote_error.log
else
echo "quote for quote_"$context_p"_"$halg" pass" >>test_quote_pass.log
Expand Down
12 changes: 7 additions & 5 deletions test/test_algs_tpm2_readpublic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,24 @@
# THE POSSIBILITY OF SUCH DAMAGE.
#;**********************************************************************;
#!/bin/bash
context_p=
halg=
context_p=
halg=
new_path=`dirname $0`
PATH="$PATH":"$new_path"

ctx_count=`ls |grep -c context_load`
if [ $ctx_count -le 1 ];then
echo "we should execute test_algs.sh first!"
wait 5
./test_algs.sh
test_algs.sh
fi
rm test_readpublic_*.log

for context_p in `ls context_load*`
do
./tpm2_readpublic -c $context_p -o rd-opu_"$context_p"
tpm2_readpublic -c $context_p -o rd-opu_"$context_p"
if [ $? != 0 ];then
echo "readpublic for "$context_p" fail, pelase check the environment or parameters!"
echo "readpublic for "$context_p" fail, please check the environment or parameters!"
echo "readpublic for "$context_p" fail" >>test_readpublic_error.log
else
echo "readpublic for "$context_p" pass" >>test_readpublic__pass.log
Expand Down
11 changes: 9 additions & 2 deletions test/test_algs_tpm2_sign.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,23 @@

context_p=
halg=
new_path=`dirname $0`
PATH="$PATH":"$new_path"

ctx_count=`ls |grep -c context_load`
if [ $ctx_count -le 1 ];then
echo "we should execute test_algs.sh first!"
wait 5
./test_algs.sh
test_algs.sh
fi

rm test_algs_sign_*.log sign_*

if [ ! -e "secret.data" ]
then
echo "12345678" > secret.data
fi

#for halg_p in 0x0004 0x000B 0x000C 0x000D 0x0012
for context_p in `ls context_load*`
do
Expand All @@ -53,7 +60,7 @@ for context_p in `ls context_load*`

tpm2_sign -c $context_p -g $halg -m secret.data -s sign_"$context_p"_"$halg_h"_"$halg"
if [ $? != 0 ];then
echo "sign for sign_"$context_p"_"$halg" fail, pelase check the environment or parameters!"
echo "sign for sign_"$context_p"_"$halg" fail, please check the environment or parameters!"
echo " sign for sign_"$context_p"_"$halg" fail" >>test_algs_sign_error.log
else
echo "sign for sign_"$context_p"_"$halg" pass" >>test_algs_sign_pass.log
Expand Down
12 changes: 8 additions & 4 deletions test/test_algs_tpm2_unseal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ kalg_c=

rm *.log context* op* name.load*

if [ ! -e "secret.data" ]
then
echo "12345678" > secret.data
fi

for halg_p in 0x0004 0x000B 0x000C 0x000D 0x0012
do
Expand All @@ -48,7 +52,7 @@ for halg_p in 0x0004 0x000B 0x000C 0x000D 0x0012

tpm2_createprimary -A p -g $halg_p -G $kalg_p -C context.p_"$halg_p"_"$kalg_p"
if [ $? != 0 ];then
echo "createprimary for context.p_"$halg_p"_"$kalg_p" fail, pelase check the environment or parameters!"
echo "createprimary for context.p_"$halg_p"_"$kalg_p" fail, please check the environment or parameters!"
continue
fi

Expand All @@ -60,14 +64,14 @@ for halg_p in 0x0004 0x000B 0x000C 0x000D 0x0012
tpm2_create -g $halg_c -G $kalg_c -o opu_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" -O opr_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" -I secret.data -c context.p_"$halg_p"_"$kalg_p"

if [ $? != 0 ];then
echo "create used context.p_"$halg_p"_"$kalg_p" with algs:"$halg_c""$kalg_c" fail, pelase check the environment or parameters!"
echo "create used context.p_"$halg_p"_"$kalg_p" with algs:"$halg_c""$kalg_c" fail, please check the environment or parameters!"
echo "create used context.p_"$halg_p"_"$kalg_p" with algs:"$halg_c""$kalg_c" fail" >>create_error.log

else

tpm2_load -c context.p_"$halg_p"_"$kalg_p" -u opu_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" -r opr_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" -n name.load_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" -C context_load_"$halg_p""$kalg_p"_"$halg_c""$kalg_c"
if [ $? != 0 ];then
echo "load for context.p_"$halg_p"_"$kalg_p" fail, pelase check the environment or parameters!"
echo "load for context.p_"$halg_p"_"$kalg_p" fail, please check the environment or parameters!"
echo "load context.p_"$halg_p"_"$kalg_p" for create context_load_"$halg_p""$kalg_p"_"$halg_c""$kalg_c" fail" >>load_error.log
fi

Expand All @@ -92,7 +96,7 @@ do

tpm2_unseal -c $context_p -o usl_"$context_p".out
if [ $? != 0 ];then
echo "unseal fail, pelase check the environment or parameters!"
echo "unseal fail, please check the environment or parameters!"
echo "unseal for_"$context_p" fail" >>test_unseal_error.log
else
echo "unseal for_"$context_p" pass" >>test_unseal_pass.log
Expand Down
13 changes: 10 additions & 3 deletions test/test_algs_tpm2_verifysignature.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,23 @@

context_p=
halg=
new_path=`dirname $0`
PATH="$PATH":"$new_path"

ctx_count=`ls |grep -c context_load`
if [ $ctx_count -le 1 ];then
echo "we should execute test_algs.sh first!"
wait 5
./test_algs.sh
test_algs.sh
fi

rm test_algs_*.log sign_* verifysig_* tickt_verify*

if [ ! -e "secret.data" ]
then
echo "12345678" > secret.data
fi

#for halg_p in 0x0004 0x000B 0x000C 0x000D 0x0012
for context_p in `ls context_load*`
do
Expand All @@ -52,7 +59,7 @@ for context_p in `ls context_load*`

tpm2_sign -c $context_p -g $halg -m secret.data -s sign_"$context_p"_"$halg"
if [ $? != 0 ];then
echo "sign for sign_"$context_p"_"$halg" fail, pelase check the environment or parameters!"
echo "sign for sign_"$context_p"_"$halg" fail, please check the environment or parameters!"
echo " sign for sign_"$context_p"_"$halg" fail" >>test_algs_sign_error.log
else
echo "sign for sign_"$context_p"_"$halg" pass" >>test_algs_sign_pass.log
Expand All @@ -62,7 +69,7 @@ for context_p in `ls context_load*`

tpm2_verifysignature -c $context_p -g $halg_ver -m secret.data -s sign_"$context_p"_"$halg" -t tickt_verify_sign_"$context_p"_"$halg"_"$halg_ver".out
if [ $? != 0 ];then
echo "verifysignature for sign_"$context_p"_"$halg"_"$halg_ver" fail, pelase check the environment or parameters!"
echo "verifysignature for sign_"$context_p"_"$halg"_"$halg_ver" fail, please check the environment or parameters!"
echo " verifysignature for sign_"$context_p"_"$halg"_"$halg_ver" fail" >>test_algs_verifysignature_error.log
else
echo " verifysignature for sign_"$context_p"_"$halg"_"$halg_ver" pass" >>test_algs_verifysignature_pass.log
Expand Down
2 changes: 1 addition & 1 deletion test/test_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
####before this script, please make sure all test scripts copy here, TPM is initialized.

#!/bin/bash
new_path=`pwd`
new_path=`dirname $0`
PATH="$PATH":"$new_path"

rm test_all_pass.log test_all_fail.log
Expand Down
54 changes: 0 additions & 54 deletions test/test_create.sh

This file was deleted.

6 changes: 3 additions & 3 deletions test/test_smoking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# THE POSSIBILITY OF SUCH DAMAGE.
#;**********************************************************************;
#!/bin/sh
new_path=`pwd`
new_path=`dirname $0`
PATH="$PATH":"$new_path"

ekHandle=0x81010007
Expand All @@ -39,7 +39,7 @@ akHandle=0x81010008

fail()
{
echo "$1 test fail, pelase check the environment or parameters!"
echo "$1 test fail, please check the environment or parameters!"
exit 1
}
Pass()
Expand All @@ -56,7 +56,7 @@ tpm2_takeownership -c
fail takeownership
fi

./test_tpm2_nv.sh
test_tpm2_nv.sh

tpm2_getpubek -H $ekHandle -g 0x01 -f ek.pub1.out

Expand Down
Loading

0 comments on commit ae322d5

Please sign in to comment.