File: fapi-export-policy.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 (58 lines) | stat: -rw-r--r-- 1,099 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
48
49
50
51
52
53
54
55
56
57
58

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/myRSASign"
POLICY_NAME=policy_pcr
POLICY_DATA=$TEMP_DIR/pol_pcr16_0.json
JSON_POLICY=policy/pcr-policy
EXPORTED_POLICY=$TEMP_DIR/exported-pcr-policy

tss2 provision

tss2 import --path=$JSON_POLICY --importData=$POLICY_DATA

tss2 createkey --path=$KEY_PATH --type="noDa, sign" --policyPath=$JSON_POLICY \
    --authValue=""

tss2 exportpolicy --path=$KEY_PATH --jsonPolicy=$EXPORTED_POLICY --force

if [ ! -s $EXPORTED_POLICY ]
then
     echo "Exported policy is empty"
     exit 1
fi

expect <<EOF
# Try with missing path
spawn tss2 exportpolicy --jsonPolicy=$EXPORTED_POLICY
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 jsonPolicy
spawn tss2 exportpolicy --path=$KEY_PATH
set ret [wait]
if {[lindex \$ret 2] || [lindex \$ret 3] != 1} {
    Command has not failed as expected\n"
    exit 1
}
EOF

exit 0