123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545 |
- set -e
- source helpers.sh
- start_up
- CRYPTO_PROFILE="ECC"
- setup_fapi $CRYPTO_PROFILE
- function cleanup {
- tss2 delete --path=/
- shut_down
- }
- trap cleanup EXIT
- KEY_PATH=HS/SRK/quotekey
- NONCE_FILE=$TEMP_DIR/nonce.file
- PUBLIC_QUOTE_KEY=$TEMP_DIR/public_quote.key
- QUOTE_INFO=$TEMP_DIR/quote.info
- SIGNATURE_FILE=$TEMP_DIR/signature.file
- CERTIFICATE_FILE=$TEMP_DIR/certificate.file
- PCR_LOG=$TEMP_DIR/pcr.log
- printf "01234567890123456789" > $NONCE_FILE
- printf "01234567890123456789" > $PCR_LOG
- EMPTY_FILE=$TEMP_DIR/empty.file
- BIG_FILE=$TEMP_DIR/big_file.file
- LOG_FILE=$TEMP_DIR/log.file
- touch $LOG_FILE
- tss2 provision
- tss2 createkey --path=$KEY_PATH --type="noDa, restricted, sign" --authValue=""
- tss2 quote --keyPath=$KEY_PATH --pcrList="11, 12, 13, 14, 15, 16" --qualifyingData=$NONCE_FILE \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG \
- --certificate=$CERTIFICATE_FILE --quoteInfo=$QUOTE_INFO --force
- echo "tss2 quote with EMPTY_FILE" # Expected to succeed
- tss2 quote --keyPath=$KEY_PATH --pcrList="11, 12, 13, 14, 15, 16" \
- --qualifyingData=$EMPTY_FILE --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG \
- --certificate=$CERTIFICATE_FILE --quoteInfo=$QUOTE_INFO --force
- echo "tss2 quote with BIG_FILE" # Expected to fail
- expect <<EOF
- spawn sh -c "tss2 quote --keyPath=$KEY_PATH --pcrList=\"11, 12, 13, 14, 15, 16\" \
- --qualifyingData=$BIG_FILE --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG \
- --certificate=$CERTIFICATE_FILE --quoteInfo=$QUOTE_INFO --force 2> $LOG_FILE"
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- set file [open $LOG_FILE r]
- set log [read \$file]
- close $file
- send_user "[lindex \$log]\n"
- exit 1
- }
- EOF
- if [[ "`cat $LOG_FILE`" == $SANITIZER_FILTER ]]; then
- echo "Error: AddressSanitizer triggered."
- cat $LOG_FILE
- exit 1
- fi
- tss2 exportkey --pathOfKeyToDuplicate=$KEY_PATH --exportedData=$PUBLIC_QUOTE_KEY --force
- tss2 import --path="ext/myNewParent" --importData=$PUBLIC_QUOTE_KEY
- tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=$NONCE_FILE --quoteInfo=$QUOTE_INFO \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG
- echo "tss2 verifyquote with EMPTY_FILE qualifyingData" # Expected to succeed
- tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=$EMPTY_FILE --quoteInfo=$QUOTE_INFO \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG
- echo "tss2 verifyquote with BIG_FILE qualifyingData" # Expected to fail
- expect <<EOF
- spawn sh -c "tss2 verifyquote --publicKeyPath=\"ext/myNewParent\" \
- --qualifyingData=$BIG_FILE --quoteInfo=$QUOTE_INFO \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG 2> $LOG_FILE"
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- set file [open $LOG_FILE r]
- set log [read \$file]
- close $file
- send_user "[lindex \$log]\n"
- exit 1
- }
- EOF
- if [[ "`cat $LOG_FILE`" == $SANITIZER_FILTER ]]; then
- echo "Error: AddressSanitizer triggered."
- cat $LOG_FILE
- exit 1
- fi
- echo "tss2 verifyquote with EMPTY_FILE signature" # Expected to fail
- expect <<EOF
- spawn sh -c "tss2 verifyquote --publicKeyPath=\"ext/myNewParent\" \
- --qualifyingData=$NONCE_FILE --quoteInfo=$QUOTE_INFO \
- --signature=$EMPTY_FILE --pcrLog=$PCR_LOG 2> $LOG_FILE"
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- set file [open $LOG_FILE r]
- set log [read \$file]
- close $file
- send_user "[lindex \$log]\n"
- exit 1
- }
- EOF
- if [[ "`cat $LOG_FILE`" == $SANITIZER_FILTER ]]; then
- echo "Error: AddressSanitizer triggered."
- cat $LOG_FILE
- exit 1
- fi
- echo "tss2 verifyquote with BIG_FILE signature" # Expected to fail
- expect <<EOF
- spawn sh -c "tss2 verifyquote --publicKeyPath=\"ext/myNewParent\" \
- --qualifyingData=$NONCE_FILE --quoteInfo=$QUOTE_INFO \
- --signature=$BIG_FILE --pcrLog=$PCR_LOG 2> $LOG_FILE"
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- set file [open $LOG_FILE r]
- set log [read \$file]
- close $file
- send_user "[lindex \$log]\n"
- exit 1
- }
- EOF
- if [[ "`cat $LOG_FILE`" == $SANITIZER_FILTER ]]; then
- echo "Error: AddressSanitizer triggered."
- cat $LOG_FILE
- exit 1
- fi
- echo "tss2 verifyquote with EMPTY_FILE quoteInfo" # Expected to fail
- expect <<EOF
- spawn sh -c "tss2 verifyquote --publicKeyPath=\"ext/myNewParent\" \
- --qualifyingData=$NONCE_FILE --quoteInfo=$EMPTY_FILE \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG 2> $LOG_FILE"
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- set file [open $LOG_FILE r]
- set log [read \$file]
- close $file
- send_user "[lindex \$log]\n"
- exit 1
- }
- EOF
- if [[ "`cat $LOG_FILE`" == $SANITIZER_FILTER ]]; then
- echo "Error: AddressSanitizer triggered."
- cat $LOG_FILE
- exit 1
- fi
- echo "tss2 verifyquote with BIG_FILE quoteInfo" # Expected to fail
- expect <<EOF
- spawn sh -c "tss2 verifyquote --publicKeyPath=\"ext/myNewParent\" \
- --qualifyingData=$NONCE_FILE --quoteInfo=$BIG_FILE \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG 2> $LOG_FILE"
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- set file [open $LOG_FILE r]
- set log [read \$file]
- close $file
- send_user "[lindex \$log]\n"
- exit 1
- }
- EOF
- if [[ "`cat $LOG_FILE`" == $SANITIZER_FILTER ]]; then
- echo "Error: AddressSanitizer triggered."
- cat $LOG_FILE
- exit 1
- fi
- echo "tss2 verifyquote with EMPTY_FILE pcrLog" # Expected to fail
- expect <<EOF
- spawn sh -c "tss2 verifyquote --publicKeyPath=\"ext/myNewParent\" \
- --qualifyingData=$NONCE_FILE --quoteInfo=$QUOTE_INFO \
- --signature=$SIGNATURE_FILE --pcrLog=$EMPTY_FILE 2> $LOG_FILE"
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- set file [open $LOG_FILE r]
- set log [read \$file]
- close $file
- send_user "[lindex \$log]\n"
- exit 1
- }
- EOF
- if [[ "`cat $LOG_FILE`" == $SANITIZER_FILTER ]]; then
- echo "Error: AddressSanitizer triggered."
- cat $LOG_FILE
- exit 1
- fi
- echo "tss2 verifyquote with BIG_FILE pcrLog" # Expected to fail
- expect <<EOF
- spawn sh -c "tss2 verifyquote --publicKeyPath=\"ext/myNewParent\" \
- --qualifyingData=$NONCE_FILE --quoteInfo=$QUOTE_INFO \
- --signature=$SIGNATURE_FILE --pcrLog=$BIG_FILE 2> $LOG_FILE"
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- set file [open $LOG_FILE r]
- set log [read \$file]
- close $file
- send_user "[lindex \$log]\n"
- exit 1
- }
- EOF
- if [[ "`cat $LOG_FILE`" == $SANITIZER_FILTER ]]; then
- echo "Error: AddressSanitizer triggered."
- cat $LOG_FILE
- exit 1
- fi
- expect <<EOF
- # Try with missing keyPath
- spawn tss2 quote --pcrList="16" \
- --qualifyingData=$NONCE_FILE --signature=$SIGNATURE_FILE \
- --pcrLog=$PCR_LOG --certificate=$CERTIFICATE_FILE \
- --quoteInfo=$QUOTE_INFO --force
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with missing pcrList
- spawn tss2 quote \
- --qualifyingData=$NONCE_FILE --signature=$SIGNATURE_FILE \
- --pcrLog=$PCR_LOG --certificate=$CERTIFICATE_FILE \
- --quoteInfo=$QUOTE_INFO --force
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with missing signature
- spawn tss2 quote --keyPath=$KEY_PATH --pcrList="16" \
- --qualifyingData=$NONCE_FILE \
- --pcrLog=$PCR_LOG --certificate=$CERTIFICATE_FILE \
- --quoteInfo=$QUOTE_INFO --force
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with missing quoteInfo
- spawn tss2 quote --keyPath=$KEY_PATH --pcrList="16" \
- --qualifyingData=$NONCE_FILE --signature=$SIGNATURE_FILE \
- --pcrLog=$PCR_LOG --certificate=$CERTIFICATE_FILE \
- --force
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with multiple stdout (1)
- spawn tss2 quote --keyPath=$KEY_PATH --pcrList="16" \
- --qualifyingData=$NONCE_FILE --signature=- \
- --pcrLog=- --certificate=$CERTIFICATE_FILE \
- --quoteInfo=$QUOTE_INFO --force
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with multiple stdout (2)
- spawn tss2 quote --keyPath=$KEY_PATH --pcrList="16" \
- --qualifyingData=$NONCE_FILE --signature=$SIGNATURE_FILE \
- --pcrLog=- --certificate=- \
- --quoteInfo=$QUOTE_INFO --force
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with multiple stdout (3)
- spawn tss2 quote --keyPath=$KEY_PATH --pcrList="16" \
- --qualifyingData=$NONCE_FILE --signature=$SIGNATURE_FILE \
- --pcrLog=$PCR_LOG --certificate=- \
- --quoteInfo=- --force
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with multiple stdout (4)
- spawn tss2 quote --keyPath=$KEY_PATH --pcrList "16" \
- --qualifyingData=- --signature $SIGNATURE_FILE \
- --pcrLog=- --certificate=$CERTIFICATE_FILE \
- --quoteInfo=- --force
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with wrong pcrs
- spawn tss2 quote --keyPath=$KEY_PATH --pcrList=abc --qualifyingData=$NONCE_FILE \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG \
- --certificate=$CERTIFICATE_FILE --quoteInfo=$QUOTE_INFO --force
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Fail quote
- spawn tss2 quote --keyPath="/abc/def" --pcrList="16" --qualifyingData=$NONCE_FILE \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG \
- --certificate=$CERTIFICATE_FILE --quoteInfo=$QUOTE_INFO --force
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with already existing directory
- spawn tss2 quote --keyPath=$KEY_PATH --pcrList="16" --qualifyingData=$NONCE_FILE \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG \
- --certificate=$CERTIFICATE_FILE --quoteInfo=$QUOTE_INFO
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- # Try with missing qualifyingData
- tss2 quote --keyPath=$KEY_PATH --pcrList="16" \
- --signature=$SIGNATURE_FILE \
- --pcrLog=$PCR_LOG --certificate=$CERTIFICATE_FILE \
- --quoteInfo=$QUOTE_INFO --force
- # Try with missing pcrLog
- tss2 quote --keyPath=$KEY_PATH --pcrList="16" \
- --qualifyingData=$NONCE_FILE --signature=$SIGNATURE_FILE \
- --certificate=$CERTIFICATE_FILE \
- --quoteInfo=$QUOTE_INFO --force
- # Try with missing certificate
- tss2 quote --keyPath=$KEY_PATH --pcrList="16" \
- --qualifyingData=$NONCE_FILE --signature=$SIGNATURE_FILE \
- --pcrLog=$PCR_LOG \
- --quoteInfo=$QUOTE_INFO --force
- expect <<EOF
- # Try with missing publicKeyPath
- spawn tss2 verifyquote \
- --qualifyingData=$NONCE_FILE --quoteInfo=$QUOTE_INFO \
- --signature=$SIGNATURE_FILE
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with missing quoteInfo
- spawn tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=$NONCE_FILE \
- --signature=$SIGNATURE_FILE
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with missing signature
- spawn tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=$NONCE_FILE --quoteInfo=$QUOTE_INFO
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with multiple stdins (1)
- spawn tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=- --quoteInfo=- \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with multiple stdins (2)
- spawn tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=$NONCE_FILE --quoteInfo=- \
- --signature=- --pcrLog=$PCR_LOG
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with multiple stdins (3)
- spawn tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=$NONCE_FILE --quoteInfo=$QUOTE_INFO \
- --signature=- --pcrLog=-
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with multiple stdins (4)
- spawn tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=- --quoteInfo=$QUOTE_INFO \
- --signature=$SIGNATURE_FILE --pcrLog=-
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with multiple stdins (5)
- spawn tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=$NONCE_FILE --quoteInfo=- \
- --signature=- --pcrLog=$PCR_LOG
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with multiple stdins (6)
- spawn tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=- --quoteInfo=- \
- --signature=- --pcrLog=-
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with wrong qualifyingData file
- spawn tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=abc --quoteInfo=$QUOTE_INFO \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with wrong signature file
- spawn tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=$NONCE_FILE --quoteInfo=$QUOTE_INFO \
- --signature=abc --pcrLog=$PCR_LOG
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try with wrong quoteInfo file
- spawn tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --qualifyingData=$NONCE_FILE --quoteInfo=abc \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- expect <<EOF
- # Try failing tss2 verifyquote
- spawn tss2 verifyquote --publicKeyPath="ext/abc" \
- --qualifyingData=$NONCE_FILE --quoteInfo=abc \
- --signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG
- set ret [wait]
- if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
- Command has not failed as expected\n"
- exit 1
- }
- EOF
- # Try with missing qualifyingData
- tss2 verifyquote --publicKeyPath="ext/myNewParent" \
- --quoteInfo=$QUOTE_INFO \
- --signature=$SIGNATURE_FILE
- exit 0
|