1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
|
set -e
source helpers.sh
start_up
CRYPTO_PROFILE="RSA"
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
QUOTE_EMPTY_INFO=$TEMP_DIR/quote_empty.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 exportkey --pathOfKeyToDuplicate=$KEY_PATH --exportedData=$PUBLIC_QUOTE_KEY --force
tss2 import --path="ext/myNewParent" --importData=$PUBLIC_QUOTE_KEY
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
tss2 verifyquote --publicKeyPath="ext/myNewParent" \
--qualifyingData=$NONCE_FILE --quoteInfo=$QUOTE_INFO \
--signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG
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_EMPTY_INFO --force
echo "tss2 verifyquote with EMPTY_FILE qualifyingData" # Expected to succeed
tss2 verifyquote --publicKeyPath="ext/myNewParent" \
--qualifyingData=$EMPTY_FILE --quoteInfo=$QUOTE_EMPTY_INFO \
--signature=$SIGNATURE_FILE --pcrLog=$PCR_LOG
# Try with missing qualifyingData
tss2 verifyquote --publicKeyPath="ext/myNewParent" \
--quoteInfo=$QUOTE_EMPTY_INFO \
--signature=$SIGNATURE_FILE
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
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
exit 0
|