~jocave/checkbox/hybrid-amd-gpu-mods

« back to all changes in this revision

Viewing changes to providers/plainbox-provider-tpm2/bin/test_smoking.sh

  • Committer: Tarmac
  • Author(s): Brendan Donegan
  • Date: 2013-06-03 11:12:58 UTC
  • mfrom: (2154.2.1 bug1185759)
  • Revision ID: tarmac-20130603111258-1b3m5ydvkf1accts
"[r=zkrynicki][bug=1185759][author=brendan-donegan] automatic merge by tarmac"

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
new_path=`pwd`
3
 
PATH="$PATH":"$new_path"
4
 
 
5
 
ekHandle=0x81010007 
6
 
akHandle=0x81010008 
7
 
 
8
 
 
9
 
fail()
10
 
{
11
 
            echo "$1 test fail, please check the environment or parameters!"
12
 
 exit 1
13
 
}
14
 
Pass()
15
 
{
16
 
            echo ""$1" pass" >>test_getpubak_pass.log
17
 
}
18
 
 
19
 
 
20
 
rm *.out
21
 
 
22
 
tpm2_takeownership -c
23
 
 
24
 
  if [ $? != 0 ];then
25
 
        fail takeownership 
26
 
  fi
27
 
 
28
 
./test_tpm2_nv.sh
29
 
 
30
 
tpm2_getpubek  -H $ekHandle  -g 0x01 -f ek.pub1.out 
31
 
 
32
 
  if [ $? != 0 ];then
33
 
        fail getpubek 
34
 
  fi
35
 
 
36
 
 
37
 
tpm2_getpubak  -E $ekHandle -k $akHandle -f ak.pub1.out -n ak.name_1.out |tee output_ak
38
 
  if [ $? != 0 ] || [ ! -e ak.nake_1.out ];then
39
 
        fail getpubak 
40
 
  fi
41
 
 
42
 
  grep  -A 3 "Name of loaded key:" output_ak|tr "\n" " " >grep.txt
43
 
  Loadkeyname=`sed -e 's/ //g'  grep.txt | awk  -F':' '{print $2}'`
44
 
 
45
 
tpm2_makecredential -e ek.pub1.out  -s secret.data  -n $Loadkeyname -o makecredential.out
46
 
 
47
 
  if [ $? != 0 ];then
48
 
        fail makecredential
49
 
  fi
50
 
 
51
 
 
52
 
tpm2_activatecredential  -H $akHandle -k $ekHandle -f makecredential.out  -o act_credential.out 
53
 
  if [ $? != 0 ];then
54
 
        fail activatecredential
55
 
  fi
56
 
 
57
 
tpm2_akparse -f ak.pub1  -k akparse.out
58
 
 
59
 
  if [ $? != 0 ];then
60
 
        fail akparse 
61
 
  fi
62
 
 
63
 
##### getrandom & hash  
64
 
tpm2_getrandom -s 20 -o random.out
65
 
  if [ $? != 0 ];then
66
 
        fail getrandom 
67
 
  fi
68
 
 
69
 
tpm2_hash -H n -g 0x004 -I random.out -o hash.out -t hash_tk.out
70
 
  if [ $? != 0 ];then
71
 
        fail hash
72
 
  fi
73
 
 
74
 
 
75
 
############context ##############
76
 
###unseal
77
 
tpm2_createprimary -A p -g 0x0004 -G 0x001 -C context.p1.out
78
 
  if [ $? != 0 ];then
79
 
        fail createprimary
80
 
  fi
81
 
 
82
 
tpm2_create -c context.p1.out -g 0x000B -G 0x0008 -o opu1.out -O opr1.out -I secret.data 
83
 
  if [ $? != 0 ];then
84
 
        fail create
85
 
  fi
86
 
tpm2_load -c context.p1.out  -u opu1.out -r opr1.out -n name.load.1.out -C context_load_out1.out
87
 
  if [ $? != 0 ];then
88
 
        fail load
89
 
  fi
90
 
tpm2_unseal -c context_load_out1.out -o usl.data.out
91
 
  if [ $? != 0 ];then
92
 
        fail unseal
93
 
  fi
94
 
 
95
 
  #####quote
96
 
tpm2_createprimary -A p -g 0x000B -G 0x001 -C context.p2.out
97
 
  if [ $? != 0 ];then
98
 
        fail createprimary 
99
 
  fi
100
 
tpm2_create -c context.p2.out -g 0x000B -G 0x0008 -o opu2.out -O opr2.out 
101
 
  if [ $? != 0 ];then
102
 
        fail create 
103
 
  fi
104
 
tpm2_load -c context.p2.out  -u opu2.out -r opr2.out -n name.load_2.out -C context_load_out2.out
105
 
  if [ $? != 0 ];then
106
 
        fail load
107
 
  fi
108
 
tpm2_quote -c context_load_out2.out -g 0x4 -l 16,17,18 -o quote_outFile.out
109
 
  if [ $? != 0 ];then
110
 
        fail quote
111
 
  fi
112
 
 
113
 
######Hmac
114
 
tpm2_createprimary -A e -g 0x000B -G 0x0001 -C context.p3.out
115
 
  if [ $? != 0 ];then
116
 
        fail createprimary 
117
 
  fi
118
 
tpm2_create  -c  context.p3.out -g 0x000B -G 0x0008  -o opu3.out -O opr3.out
119
 
  if [ $? != 0 ];then
120
 
        fail create 
121
 
  fi
122
 
tpm2_load -c context.p3.out  -u opu3.out -r opr3.out -n name.load.3.out -C context_load_out3.out
123
 
  if [ $? != 0 ];then
124
 
        fail load 
125
 
  fi
126
 
tpm2_hmac  -c context_load_out3.out  -g 0x00B -I secret.data -o hmac.out
127
 
  if [ $? != 0 ];then
128
 
        fail hmac 
129
 
  fi
130
 
 
131
 
######readpublic
132
 
tpm2_createprimary -A e -g 0x000B -G 0x0001 -C context.p4.out
133
 
  if [ $? != 0 ];then
134
 
        fail createprimary 
135
 
  fi
136
 
tpm2_create  -c  context.p4.out -g 0x000B -G 0x0008  -o opu4.out -O opr4.out
137
 
  if [ $? != 0 ];then
138
 
        fail create 
139
 
  fi
140
 
tpm2_load -c context.p4.out  -u opu4.out -r opr4.out -n name.load.4.out -C context_load_out4.out
141
 
  if [ $? != 0 ];then
142
 
        fail load 
143
 
  fi
144
 
tpm2_readpublic -c context_load_out4.out -o rd-opu.out
145
 
  if [ $? != 0 ];then
146
 
        fail readpublic 
147
 
  fi
148
 
 
149
 
######evictcontrol
150
 
tpm2_createprimary -A e -g 0x000B -G 0x0001 -C context.p5.out
151
 
  if [ $? != 0 ];then
152
 
        fail createprimary 
153
 
  fi
154
 
tpm2_create -g 0x000B -G 0x0008 -o opu5.out -O opr5.out -c context.p5.out
155
 
  if [ $? != 0 ];then
156
 
        fail create 
157
 
  fi
158
 
tpm2_load -c context.p5.out  -u opu5.out -r opr5.out -n name.load5.out -C context_load_out5.out
159
 
  if [ $? != 0 ];then
160
 
        fail load 
161
 
  fi
162
 
tpm2_evictcontrol -A o -c context_load_out5.out  -S 0x81010003
163
 
  if [ $? != 0 ];then
164
 
        fail evictontronl
165
 
  else 
166
 
tpm2_evictcontrol -A o -H 0x81010003  -S 0x81010003
167
 
    if [ $? != 0 ];then
168
 
         fail evictcontrol_release_Handle 
169
 
    fi
170
 
  fi
171
 
 
172
 
#####rsaencrypt & rsadecrypt
173
 
tpm2_createprimary -A e -g 0x000B -G 0x0001 -C context.p6.out
174
 
  if [ $? != 0 ];then
175
 
        fail createprimary 
176
 
  fi
177
 
tpm2_create  -g 0x000B -G 0x0001 -o opu6.out -O opr6.out -c context.p6.out
178
 
  if [ $? != 0 ];then
179
 
        fail create 
180
 
  fi
181
 
tpm2_loadexternal  -H n -u opu6.out -C context_loadexternal_out6.out
182
 
  if [ $? != 0 ];then
183
 
        fail loadexternal 
184
 
  fi
185
 
tpm2_rsaencrypt -c context_loadexternal_out6.out -I secret.data -o rsa_en.out
186
 
  if [ $? != 0 ];then
187
 
        fail rsa_encrypt 
188
 
  fi
189
 
tpm2_load -c context.p6.out  -u opu6.out -r opr6.out -n name.load6.out -C context_load_out6.out
190
 
  if [ $? != 0 ];then
191
 
        fail load 
192
 
  fi
193
 
tpm2_rsadecrypt -c context_load_out6.out  -I rsa_en.out -o rsa_de.out
194
 
  if [ $? != 0 ];then
195
 
        fail rsa_decrypt 
196
 
  fi
197
 
 
198
 
#####sign
199
 
tpm2_createprimary -A e -g 0x000B -G 0x0001 -C context.p7.out
200
 
  if [ $? != 0 ];then
201
 
        fail createprimary 
202
 
  fi
203
 
  
204
 
tpm2_create -g 0x000B -G 0x0008 -o opu7.out -O opr7.out -c context.p7.out
205
 
  if [ $? != 0 ];then
206
 
        fail create 
207
 
  fi
208
 
tpm2_load -c context.p7.out  -u opu7.out -r opr7.out -n name.load7.out -C context_load_out7.out
209
 
  if [ $? != 0 ];then
210
 
        fail load 
211
 
  fi
212
 
tpm2_sign -c context_load_out7.out -g 0x00B -m secret.data -s sign.f.out
213
 
  if [ $? != 0 ];then
214
 
        fail sign 
215
 
  fi
216
 
 
217
 
tpm2_verifysignature -c context_load_out7.out  -g 0x000B -m secret.data  -s sign.f.out -t tickt_verify_sign.out 
218
 
  if [ $? != 0 ];then
219
 
        fail verifysignature
220
 
  fi
221
 
 
222
 
######encryptdecrypt
223
 
tpm2_createprimary -A e -g 0x000B -G 0x0001 -C context.p8.out
224
 
  if [ $? != 0 ];then
225
 
        fail createprimary 
226
 
  fi
227
 
tpm2_create  -g 0x000B -G 0x0025 -o opu8.out -O opr8.out -c context.p8.out
228
 
  if [ $? != 0 ];then
229
 
        fail create 
230
 
  fi
231
 
tpm2_load -c context.p8.out  -u opu8.out -r opr8.out -n name.load8.out -C context_load_out8.out
232
 
  if [ $? != 0 ];then
233
 
        fail load 
234
 
  fi
235
 
tpm2_encryptdecrypt -c context_load_out8.out -D NO -I secret.data -o endecrypt.out
236
 
  if [ $? != 0 ];then
237
 
        fail encrypt 
238
 
  fi
239
 
tpm2_encryptdecrypt -c context_load_out8.out -D YES -I endecrypt.out -o endecrypt_de.out
240
 
  if [ $? != 0 ];then
241
 
        fail decrypt
242
 
  fi
243
 
 
244
 
######certify
245
 
tpm2_createprimary -A e -g 0x000B -G 0x0001 -C context.p9.out
246
 
  if [ $? != 0 ];then
247
 
        fail createprimary 
248
 
  fi
249
 
tpm2_create -g 0x000B -G 0x0001 -o opu9.out -O opr9.out -c context.p9.out 
250
 
  if [ $? != 0 ];then
251
 
        fail create 
252
 
  fi
253
 
tpm2_load -c context.p9.out  -u opu9.out -r opr9.out -n name.load9.out -C context_load_out9.out -d 3
254
 
  if [ $? != 0 ];then
255
 
        fail load 
256
 
  fi
257
 
tpm2_certify -C context.p9.out -c context_load_out9.out -g 0x000B -a attest.out -s certify_signature.out
258
 
  if [ $? != 0 ];then
259
 
        fail certify 
260
 
  fi
261
 
 
262
 
tpm2_listpcrs 
263
 
  if [ $? != 0 ];then
264
 
        fail listpcrs
265
 
  fi