File: fapi-nv-increment.sh

package info (click to toggle)
tpm2-tools 5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,988 kB
  • sloc: ansic: 45,737; sh: 14,915; xml: 8,342; makefile: 610; python: 51
file content (47 lines) | stat: -rw-r--r-- 914 bytes parent folder | download | duplicates (3)
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

set -e
source helpers.sh

start_up

CRYPTO_PROFILE="RSA"
setup_fapi $CRYPTO_PROFILE

function cleanup {
    tss2 delete --path=/
    shut_down
}

trap cleanup EXIT

NV_PATH=/nv/Owner/myNVcounter
NV_COUNTER_READ_FILE=$TEMP_DIR/nv_counter_read_data.file
PCR_POLICY_DATA=$TEMP_DIR/pol_pcr16_0.json
POLICY_PCR=policy/pcr-policy

tss2 provision

tss2 import --path=$POLICY_PCR --importData=$PCR_POLICY_DATA

tss2 createnv --path=$NV_PATH --policyPath=$POLICY_PCR --type="counter, noDa" \
    --size=0 --authValue=""

tss2 nvincrement --nvPath=$NV_PATH

tss2 nvread --nvPath=$NV_PATH --data=$NV_COUNTER_READ_FILE --force

tss2 nvincrement --nvPath=$NV_PATH

tss2 nvread --nvPath=$NV_PATH --data=$NV_COUNTER_READ_FILE --force

expect <<EOF
# Try with missing nvPath
spawn tss2 nvincrement
set ret [wait]
if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
    Command has not failed as expected\n"
    exit 1
}
EOF

exit 0