File: testnv.sh

package info (click to toggle)
tss2 1045-2
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 6,868 kB
  • sloc: ansic: 58,589; sh: 5,124; php: 1,247; makefile: 380; cpp: 23
file content (703 lines) | stat: -rwxr-xr-x 19,742 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
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
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
#!/bin/bash
#

#################################################################################
#										#
#			TPM2 regression test					#
#			     Written by Ken Goldman				#
#		       IBM Thomas J. Watson Research Center			#
#		$Id: testnv.sh 979 2017-04-04 17:57:18Z kgoldman $		#
#										#
# (c) Copyright IBM Corporation 2015, 2016					#
# 										#
# All rights reserved.								#
# 										#
# Redistribution and use in source and binary forms, with or without		#
# modification, are permitted provided that the following conditions are	#
# met:										#
# 										#
# Redistributions of source code must retain the above copyright notice,	#
# this list of conditions and the following disclaimer.				#
# 										#
# Redistributions in binary form must reproduce the above copyright		#
# notice, this list of conditions and the following disclaimer in the		#
# documentation and/or other materials provided with the distribution.		#
# 										#
# Neither the names of the IBM Corporation nor the names of its			#
# contributors may be used to endorse or promote products derived from		#
# this software without specific prior written permission.			#
# 										#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS		#
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT		#
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR		#
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT		#
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,	#
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT		#
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,		#
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY		#
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT		#
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE		#
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.		#
#										#
#################################################################################

echo ""
echo "NV"
echo ""

echo ""
echo "NV Ordinary Index"
echo ""

echo "Start an HMAC auth session"
${PREFIX}startauthsession -se h > run.out
checkSuccess $?

NALG=(sha1 sha256 sha384)
BADNALG=(sha256 sha384 sha1)

for ((i = 0 ; i < 3; i++))
do

    for SESS in "" "-se0 02000000 1"
    do

	echo "NV Define Space ${NALG[$i]}"
	${PREFIX}nvdefinespace -hi o -ha 01000000 -pwdn nnn -sz 16 -nalg ${NALG[$i]} > run.out
	checkSuccess $?

	echo "NV Read Public, unwritten Name  bad Name algorithm ${BADNALG[$i]} - should fail"
	${PREFIX}nvreadpublic -ha 01000000 -nalg ${BADNALG[$i]} > run.out
	checkFailure $?

	echo "NV read - should fail before write ${SESS}"
	${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 16 ${SESS} > run.out
	checkFailure $?

	echo "NV write ${SESS}"
	${PREFIX}nvwrite -ha 01000000 -pwdn nnn -if policies/aaa ${SESS} > run.out
	checkSuccess $?

	echo "NV read ${SESS}"
	${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 3 -of tmp.bin ${SESS} > run.out
	checkSuccess $?

	echo "Verify the read data"
	diff policies/aaa tmp.bin
	checkSuccess $?

	echo "NV read, invalid offset - should fail ${SESS}"
	${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 16 -off 1 -of tmp.bin ${SESS} > run.out
	checkFailure $?

	echo "NV read, invalid size - should fail ${SESS}"
	${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 17 -of tmp.bin ${SESS} > run.out
	checkFailure $?

	echo "NV Undefine Space"
	${PREFIX}nvundefinespace -hi o -ha 01000000 > run.out
	checkSuccess $?

    done
done

echo "Flush the auth session"
${PREFIX}flushcontext -ha 02000000 > run.out
checkSuccess $?

echo "NV Undefine Space again should fail"
${PREFIX}nvundefinespace -hi o -ha 01000000 > run.out
checkFailure $?

echo "NV Define Space out of range - should fail"
${PREFIX}nvdefinespace -hi o -ha 02000000 -pwdn nnn  -sz 16 > run.out
checkFailure $?

echo ""
echo "NV Set Bits Index"
echo ""

echo "Start an HMAC auth session"
${PREFIX}startauthsession -se h > run.out
checkSuccess $?

for SESS in "" "-se0 02000000 1"
do

    echo "NV Define Space"
    ${PREFIX}nvdefinespace -hi o -ha 01000000 -pwdn nnn -ty b > run.out
    checkSuccess $?

    echo "NV read - should fail before write ${SESS}"
    ${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 16  ${SESS} > run.out
    checkFailure $?

    echo "Set bits 0, 16, 32, 48 ${SESS}" 
    ${PREFIX}nvsetbits -ha 01000000 -pwdn nnn -bit 0 -bit 16 -bit 32 -bit 48 ${SESS} > run.out
    checkSuccess $?

    echo "Read the set bits ${SESS}" 
    ${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 8 -of tmp.bin ${SESS} > run.out
    checkSuccess $?

    echo "Verify the read data"
    diff policies/bits48321601.bin tmp.bin
    checkSuccess $?

    echo "NV Undefine Space"
    ${PREFIX}nvundefinespace -hi o -ha 01000000 > run.out
    checkSuccess $?

done

echo "Flush the auth session"
${PREFIX}flushcontext -ha 02000000 > run.out
checkSuccess $?

echo ""
echo "NV Counter Index"
echo ""

echo "Start an HMAC auth session"
${PREFIX}startauthsession -se h > run.out
checkSuccess $?

for SESS in "" "-se0 02000000 1"
do

    echo "NV Define Space"
    ${PREFIX}nvdefinespace -hi o -ha 01000000 -pwdn nnn -ty c > run.out
    checkSuccess $?

    echo "NV Read Public, unwritten Name"
    ${PREFIX}nvreadpublic -ha 01000000 > run.out
    checkSuccess $?

    echo "Read the count - should fail before write ${SESS}" 
    ${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 8 -of tmp.bin  ${SESS} > run.out
    checkFailure $?

    echo "Increment the count ${SESS}" 
    ${PREFIX}nvincrement -ha 01000000 -pwdn nnn  ${SESS} > run.out
    checkSuccess $?

    echo "Read the count ${SESS}" 
    ${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 8 -of tmp.bin  ${SESS} > run.out
    checkSuccess $?

# FIXME need some way to verify the count

    echo "NV Undefine Space"
    ${PREFIX}nvundefinespace -hi o -ha 01000000 > run.out
    checkSuccess $?

done

echo "Flush the auth session"
${PREFIX}flushcontext -ha 02000000 > run.out
checkSuccess $?

echo ""
echo "NV Extend Index"
echo ""

echo "Start an HMAC auth session"
${PREFIX}startauthsession -se h > run.out
checkSuccess $?

for SESS in "" "-se0 02000000 1"
do

    SZ=(20 32 48)
    HALG=(sha1 sha256 sha384)

    for ((i = 0 ; i < 3; i++))
    do

	echo "NV Define Space ${HALG[$i]}"
	${PREFIX}nvdefinespace -hi o -ha 01000000 -pwdn nnn -ty e -nalg ${HALG[$i]} > run.out
	checkSuccess $?

	echo "NV Read Public ${HALG[$i]}"
	${PREFIX}nvreadpublic -ha 01000000 -nalg ${HALG[$i]} > run.out
	checkSuccess $?

	echo "NV read, unwritten Name - should fail before write ${SESS}"
	${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 32 -of tmp.bin ${SESS} > run.out
	checkFailure $?

	echo "NV extend ${SESS}"
	${PREFIX}nvextend -ha 01000000 -pwdn nnn -if policies/aaa ${SESS} > run.out
	checkSuccess $?

	echo "NV read size ${SZ[$i]} ${SESS}"
	${PREFIX}nvread -ha 01000000 -pwdn nnn -sz ${SZ[$i]} -of tmp.bin ${SESS} > run.out
	checkSuccess $?

	echo "Verify the read data ${HALG[$i]}"
	diff policies/${HALG[$i]}extaaa.bin tmp.bin
	checkSuccess $?

	echo "NV Undefine Space"
	${PREFIX}nvundefinespace -hi o -ha 01000000 > run.out
	checkSuccess $?

    done
done

echo "Flush the auth session"
${PREFIX}flushcontext -ha 02000000 > run.out
checkSuccess $?

# getcapability  -cap 1 -pr 80000000
# getcapability  -cap 1 -pr 02000000
# getcapability  -cap 1 -pr 01000000

echo ""
echo "NV Owner auth"
echo ""

echo "Start an HMAC auth session"
${PREFIX}startauthsession -se h > run.out
checkSuccess $?

for SESS in "" "-se0 02000000 1"
do

    echo "Set owner auth ${SESS}"
    ${PREFIX}hierarchychangeauth -hi o -pwdn ooo ${SESS} > run.out
    checkSuccess $?

    echo "Define an NV index with owner auth ${SESS}"
    ${PREFIX}nvdefinespace -hi o -hia o -ha 01000000 -pwdp ooo ${SESS} > run.out
    checkSuccess $?

    echo "NV Read public, get Name, not written"
    ${PREFIX}nvreadpublic -ha 01000000 > run.out
    checkSuccess $?

    echo "NV write with NV password ${SESS} - should fail"
    ${PREFIX}nvwrite -ha 01000000 -pwdn nnn ${SESS}> run.out
    checkFailure $?

    echo "NV write with owner password ${SESS}"
    ${PREFIX}nvwrite -ha 01000000 -hia o -pwdn ooo  ${SESS}> run.out 
    checkSuccess $?

    echo "NV read with NV password ${SESS} - should fail"
    ${PREFIX}nvread -ha 01000000 ${SESS} -pwdn nnn > run.out
    checkFailure $?

    echo "NV read with owner password ${SESS}"
    ${PREFIX}nvread -ha 01000000 -hia o -pwdn ooo ${SESS} > run.out 
    checkSuccess $?

    echo "NV Undefine authorizing index ${SESS}"
    ${PREFIX}nvundefinespace -hi o -ha 01000000 -pwdp ooo ${SESS} > run.out
    checkSuccess $?

    echo "Clear owner auth ${SESS}"
    ${PREFIX}hierarchychangeauth -hi o -pwda ooo ${SESS} > run.out
    checkSuccess $?

done

echo "Flush the auth session"
${PREFIX}flushcontext -ha 02000000 > run.out
checkSuccess $?

# getcapability  -cap 1 -pr 80000000
# getcapability  -cap 1 -pr 02000000
# getcapability  -cap 1 -pr 01000000

echo ""
echo "NV Platform auth"
echo ""

echo "Start an HMAC auth session"
${PREFIX}startauthsession -se h > run.out
checkSuccess $?

for SESS in "" "-se0 02000000 1"
do

    echo "Set platform auth ${SESS}"
    ${PREFIX}hierarchychangeauth -hi p -pwdn ppp  ${SESS}> run.out
    checkSuccess $?

    echo "Define an NV index with platform auth ${SESS}"
    ${PREFIX}nvdefinespace -hi p -hia p -ha 01000000 -pwdp ppp ${SESS} > run.out
    checkSuccess $?

    echo "NV Read public, get Name, not written"
    ${PREFIX}nvreadpublic -ha 01000000 > run.out
    checkSuccess $?

    echo "NV write with NV password ${SESS} - should fail"
    ${PREFIX}nvwrite -ha 01000000 -pwdn nnn ${SESS} > run.out
    checkFailure $?

    echo "NV write with platform password ${SESS}"
    ${PREFIX}nvwrite -ha 01000000 -hia p -pwdn ppp ${SESS} > run.out 
    checkSuccess $?

    echo "NV read with NV password ${SESS} - should fail"
    ${PREFIX}nvread -ha 01000000 -pwdn nnn ${SESS} > run.out
    checkFailure $?

    echo "NV write with platform password ${SESS}"
    ${PREFIX}nvread -ha 01000000 -hia p -pwdn ppp ${SESS} > run.out 
    checkSuccess $?

    echo "NV Undefine authorizing index ${SESS}"
    ${PREFIX}nvundefinespace -hi p -ha 01000000 -pwdp ppp ${SESS} > run.out
    checkSuccess $?

    echo "Clear platform auth ${SESS}"
    ${PREFIX}hierarchychangeauth -hi p -pwda ppp ${SESS} > run.out
    checkSuccess $?

done

echo "Flush the auth session"
${PREFIX}flushcontext -ha 02000000 > run.out
checkSuccess $?

echo ""
echo "Write Lock"
echo ""

echo "Start an HMAC auth session"
${PREFIX}startauthsession -se h > run.out
checkSuccess $?

for SESS in "" "-se0 02000000 1"
do

    echo "NV Define Space with write define"
    ${PREFIX}nvdefinespace -hi o -ha 01000000 -pwdn nnn -sz 16 +at wd > run.out
    checkSuccess $?

    echo "NV Read Public, unwritten Name"
    ${PREFIX}nvreadpublic -ha 01000000 > run.out
    checkSuccess $?

    echo "NV write ${SESS}"
    ${PREFIX}nvwrite -ha 01000000 -pwdn nnn -if policies/aaa ${SESS} > run.out
    checkSuccess $?

    echo "NV read ${SESS}"
    ${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 16 ${SESS} > run.out
    checkSuccess $?

    echo "Write lock ${SESS}"
    ${PREFIX}nvwritelock -ha 01000000 -pwdn nnn ${SESS} > run.out  
    checkSuccess $?

    echo "NV write ${SESS} - should fail"
    ${PREFIX}nvwrite -ha 01000000 -pwdn nnn -if policies/aaa ${SESS} > run.out
    checkFailure $?

    echo "NV read ${SESS}"
    ${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 16 ${SESS} > run.out
    checkSuccess $?

    echo "NV Undefine Space"
    ${PREFIX}nvundefinespace -hi p -ha 01000000 > run.out
    checkSuccess $?

done

echo "Flush the auth session"
${PREFIX}flushcontext -ha 02000000 > run.out
checkSuccess $?

echo ""
echo "Read Lock"
echo ""

echo "Start an HMAC auth session"
${PREFIX}startauthsession -se h > run.out
checkSuccess $?

for SESS in "" "-se0 02000000 1"
do

    echo "NV Define Space with read stclear"
    ${PREFIX}nvdefinespace -hi o -ha 01000000 -pwdn nnn -sz 16 +at rst > run.out
    checkSuccess $?

    echo "NV Read Public, unwritten Name"
    ${PREFIX}nvreadpublic -ha 01000000 > run.out
    checkSuccess $?

    echo "NV write ${SESS}"
    ${PREFIX}nvwrite -ha 01000000 -pwdn nnn -if policies/aaa ${SESS} > run.out
    checkSuccess $?

    echo "NV read ${SESS}"
    ${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 16 ${SESS} > run.out
    checkSuccess $?

     echo "Read lock ${SESS}"
    ${PREFIX}nvreadlock -ha 01000000 -pwdn nnn ${SESS} > run.out 
    checkSuccess $?

    echo "NV write ${SESS}"
    ${PREFIX}nvwrite -ha 01000000 -pwdn nnn -if policies/aaa ${SESS} > run.out
    checkSuccess $?

    echo "NV read ${SESS} - should fail"
    ${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 16 ${SESS} > run.out
    checkFailure $?

    echo "NV Undefine Space"
    ${PREFIX}nvundefinespace -hi p -ha 01000000 > run.out
    checkSuccess $?

done

echo "Flush the auth session"
${PREFIX}flushcontext -ha 02000000 > run.out
checkSuccess $?

echo ""
echo "Global Lock"
echo ""

echo "Start an HMAC auth session"
${PREFIX}startauthsession -se h > run.out
checkSuccess $?

for SESS in "" "-se0 02000000 1"
do

    echo "NV Define Space 01000000 with global lock"
    ${PREFIX}nvdefinespace -hi o -ha 01000000 -pwdn nnn -sz 16 +at gl > run.out
    checkSuccess $?

    echo "NV Define Space 01000001 with global lock"
    ${PREFIX}nvdefinespace -hi o -ha 01000001 -pwdn nnn -sz 16 +at gl > run.out
    checkSuccess $?

    echo "NV write 01000000 ${SESS}"
    ${PREFIX}nvwrite -ha 01000000 -pwdn nnn -if policies/aaa ${SESS} > run.out
    checkSuccess $?

    echo "NV write 01000001 ${SESS}"
    ${PREFIX}nvwrite -ha 01000001 -pwdn nnn -if policies/aaa ${SESS} > run.out
    checkSuccess $?

    echo "NV global lock"
    ${PREFIX}nvglobalwritelock -hia p
    checkSuccess $?

    echo "NV Read Public, 01000000, locked"
    ${PREFIX}nvreadpublic -ha 01000000 > run.out
    checkSuccess $?

    echo "NV Read Public, 01000001, locked"
    ${PREFIX}nvreadpublic -ha 01000001 > run.out
    checkSuccess $?

    echo "NV write 01000000 ${SESS} - should fail"
    ${PREFIX}nvwrite -ha 01000000 -pwdn nnn -if policies/aaa ${SESS} > run.out
    checkFailure $?

    echo "NV write 01000001 ${SESS} - should fail"
    ${PREFIX}nvwrite -ha 01000001 -pwdn nnn -if policies/aaa ${SESS} > run.out
    checkFailure $?

    echo "NV read 01000000 ${SESS}"
    ${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 16 ${SESS} > run.out
    checkSuccess $?

    echo "NV read 01000001 ${SESS}"
    ${PREFIX}nvread -ha 01000001 -pwdn nnn -sz 16 ${SESS} > run.out
    checkSuccess $?

    echo "NV Undefine Space 01000000"
    ${PREFIX}nvundefinespace -hi p -ha 01000000 > run.out
    checkSuccess $?

    echo "NV Undefine Space 01000001"
    ${PREFIX}nvundefinespace -hi p -ha 01000001 > run.out
    checkSuccess $?

done

echo "Flush the auth session"
${PREFIX}flushcontext -ha 02000000 > run.out
checkSuccess $?

# policy is policycommandcode + policyauthvalue
# aa 83 a5 98 d9 3a 56 c9 ca 6f ea 7c 3f fc 4e 10 
# 63 57 ff 6d 93 e1 1a 9b 4a c2 b6 aa e1 2b a0 de 

echo "NV Define Space with POLICY_DELETE and no policy - should fail"
${PREFIX}nvdefinespace -hi o -ha 01000000 +at pold > run.out
checkFailure $?

echo ""
echo "NV Change Authorization"
echo ""

echo "Start an HMAC session"
${PREFIX}startauthsession -se h > run.out
checkSuccess $?

for SESS in "" "-se0 02000000 1"
do

    echo "NV Define Space 0100000"
    ${PREFIX}nvdefinespace -hi o -ha 01000000 -pwdn nnn -sz 16 -pol policies/policyccnvchangeauth-auth.bin > run.out
    checkSuccess $?

    echo "NV Read Public, unwritten Name"
    ${PREFIX}nvreadpublic -ha 01000000 > run.out
    checkSuccess $?

    echo "NV write ${SESS}"
    ${PREFIX}nvwrite -ha 01000000 -pwdn nnn -if policies/aaa ${SESS} > run.out
    checkSuccess $?

    echo "NV read ${SESS}"
    ${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 16 ${SESS} > run.out
    checkSuccess $?

    echo "Start a policy session"
    ${PREFIX}startauthsession -se p > run.out
    checkSuccess $?

    echo "Policy command code"    
    ${PREFIX}policycommandcode -ha 03000001 -cc 0000013b
    checkSuccess $?

    echo "Policy authvalue"    
    ${PREFIX}policyauthvalue -ha 03000001
    checkSuccess $?

   echo "NV Change authorization"
    ${PREFIX}nvchangeauth -ha 01000000 -pwdo nnn -pwdn xxx -se0 03000001 1 > run.out 
    checkSuccess $?

    echo "NV write ${SESS}, old auth - should fail"
    ${PREFIX}nvwrite -ha 01000000 -pwdn nnn -if policies/aaa ${SESS} > run.out
    checkFailure $?

    echo "NV read ${SESS}, old auth - should fail"
    ${PREFIX}nvread -ha 01000000 -pwdn nnn -sz 3 ${SESS} > run.out
    checkFailure $?

    echo "NV write ${SESS}"
    ${PREFIX}nvwrite -ha 01000000 -pwdn xxx -if policies/aaa ${SESS} > run.out
    checkSuccess $?

    echo "NV read ${SESS}"
    ${PREFIX}nvread -ha 01000000 -pwdn xxx -sz 3 ${SESS} > run.out
    checkSuccess $?

    echo "NV Undefine Space"
    ${PREFIX}nvundefinespace -hi p -ha 01000000 > run.out
    checkSuccess $?

    echo "Flush the auth session"
    ${PREFIX}flushcontext -ha 03000001 > run.out
    checkSuccess $?

done

echo "Flush the auth session"
${PREFIX}flushcontext -ha 02000000 > run.out
checkSuccess $?

echo ""
echo "NV Change Authorization with bind"
echo ""

echo "NV Define Space 0100000"
${PREFIX}nvdefinespace -hi o -ha 01000000 -pwdn nnn -sz 16 -pol policies/policyccnvchangeauth-auth.bin > run.out
checkSuccess $?

echo "Start an HMAC session, bind to NV index"
${PREFIX}startauthsession -se h -bi 01000000 -pwdb nnn > run.out
checkSuccess $?

echo "Start a policy session"
${PREFIX}startauthsession -se p > run.out
checkSuccess $?

echo "Policy command code"    
${PREFIX}policycommandcode -ha 03000001 -cc 0000013b
checkSuccess $?

echo "Policy authvalue"    
${PREFIX}policyauthvalue -ha 03000001
checkSuccess $?

echo "NV Change authorization"
${PREFIX}nvchangeauth -ha 01000000 -pwdo nnn -pwdn xxx -se0 03000001 1 > run.out 
checkSuccess $?

echo "NV Undefine Space"
${PREFIX}nvundefinespace -hi p -ha 01000000 > run.out
checkSuccess $?

echo "Flush the auth session"
${PREFIX}flushcontext -ha 03000001 > run.out
checkSuccess $?

echo "Flush the auth session"
${PREFIX}flushcontext -ha 02000000 > run.out
checkSuccess $?

echo ""
echo "NV Undefine space special"
echo ""

# policy is policy command code + policy password

echo "Start a policy session"
${PREFIX}startauthsession -se p > run.out
checkSuccess $?

for POL in "policyauthvalue" "policypassword"
do

    echo "NV Define Space 0100000"
    ${PREFIX}nvdefinespace -hi p -ha 01000000 -pwdn nnn -sz 16 +at pold -pol policies/policyccundefinespacespecial-auth.bin > run.out
    checkSuccess $?

    echo "Undefine space special - should fail"
    ${PREFIX}nvundefinespacespecial -ha 01000000 -pwdn nnn > run.out
    checkFailure $?

    echo "Undefine space special - should fail"
    ${PREFIX}nvundefinespacespecial -ha 01000000 -se0 03000000 1 -pwdn nnn > run.out
    checkFailure $?

    echo "Policy command code, NV undefine space special"
    ${PREFIX}policycommandcode -ha 03000000 -cc 11f > run.out
    checkSuccess $?

    echo "Undefine space special - should fail"
    ${PREFIX}nvundefinespacespecial -ha 01000000 -se0 03000000 1 -pwdn nnn > run.out
    checkFailure $?

    echo "Policy ${POL}"
    ${PREFIX}${POL} -ha 03000000 > run.out
    checkSuccess $?

    echo "Undefine space special"
    ${PREFIX}nvundefinespacespecial -ha 01000000 -se0 03000000 1 -pwdn nnn > run.out
    checkSuccess $?

done

echo "Flush the session"
${PREFIX}flushcontext -ha 03000000 > run.out
checkSuccess $?

# ${PREFIX}getcapability  -cap 1 -pr 80000000
# ${PREFIX}getcapability  -cap 1 -pr 02000000
# ${PREFIX}getcapability  -cap 1 -pr 01000000