[477bfa]: test / tpm_changeownerauth01.sh Maximize Restore History

Download this file

tpm_changeownerauth01.sh    262 lines (248 with data), 7.0 kB

  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
#!/usr/bin/expect -f
########################################################################
# The Initial Developer of the Original Code is International
# Business Machines Corporation. Portions created by IBM
# Corporation are Copyright (C) 2007 International Business
# Machines Corporation. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the Common Public License as published by
# IBM Corporation; either version 1 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Common Public License for more details.
#
# You should have received a copy of the Common Public License
# along with this program; if not, a copy can be viewed at
# http://www.opensource.org/licenses/cpl1.0.php.
#
#
# Program: tpm_changeownerauth01.sh
# Purpose: Test transitions between plain text, unicode and well-known
# for Owner and SRK passwords, using tpm_changeownerauth from tpm-tools
# package.
# Pre-Conditions: Owner and SRK password must be set to a plain text
# password before running this test.
#
# Author: Ramon Brand��o <ramongb@br.ibm.com>
# Date: Nov/07
#
########################################################################
set timeout -1
set options {"-s" "-o"}
# States if the current owner password is the Well Known secret
set wnOpt ""
# States if the crrent owner password is a Unicode one
set isU ""
#Prompts for the owner and SRK Passwords
send_user "Enter the current Owner Password: "
expect_user -re "(.*)\n"
set ownerPasswd $expect_out(1,string)
send_user "Enter the current SRK Password: "
expect_user -re "(.*)\n"
set SRKPasswd $expect_out(1,string)
# Start of changeauth tests
foreach opt $options {
if {$opt == "-s"} {
send_user "\n\n#############################################################\n"
send_user "####### Testing tpm_changeownerauth for SRK password:########\n"
send_user "#############################################################\n\n"
} else {
send_user "\n\n###############################################################\n"
send_user "####### Testing tpm_changeownerauth for OWNER password:########\n"
send_user "###############################################################\n\n"
}
# Plaintext -> Unicode
puts stdout "Test 1) tpm_changeownerauth \"$opt\": Changing password from PLAINTEXT to UNICODE:"
spawn tpm_changeownerauth $opt -n -l debug
sleep 1
expect "Enter owner password" {
exp_send "$ownerPasswd\r"
if {$opt == "-s"} {
expect "Enter new SRK" {
exp_send "$SRKPasswd\r"
expect "Confirm" {
exp_send "$SRKPasswd\r"
}
}
} else {
expect "Enter new owner" {
exp_send "$ownerPasswd\r"
expect "Confirm" {
exp_send "$ownerPasswd\r"
set isU "-g"
}
}
}
expect {
"ngeAuth success" {
expect "Tspi_Context_Close success" {
send_user "PLAINTEXT to UNICODE auth change SUCCEED. \n\n"
}
}
"*Auth*ailed" {
expect "Tspi_Context_Close success" {
send_user "PLAINTEXT to UNICODE auth change FAILED. \n\n"
}
}
}
}
sleep 4
# Unicode -> plaintext
puts stdout "Test 2) tpm_changeownerauth \"$opt\": Changing password from UNICODE to PLAINTEXT:"
spawn tpm_changeownerauth $opt $isU -l debug
sleep 1
expect "Enter owner password" {
exp_send "$ownerPasswd\r"
if {$opt == "-s"} {
expect "Enter new SRK" {
exp_send "$SRKPasswd\r"
expect "Confirm" {
exp_send "$SRKPasswd\r"
}
}
} else {
expect "Enter new owner" {
exp_send "$ownerPasswd\r"
expect "Confirm" {
exp_send "$ownerPasswd\r"
set isU ""
}
}
}
expect {
"ngeAuth success" {
expect "Tspi_Context_Close success" {
send_user "UNICODE to PLAINTEXT auth change SUCCEED. \n\n"
}
}
"*Auth*ailed" {
expect "Tspi_Context_Close success" {
send_user "UNICODE to PLAINTEXT auth change FAILED. \n\n"
}
}
}
}
sleep 4
# Plaintext -> Well Known
puts stdout "Test 3) tpm_changeownerauth \"$opt\": Changing password from PLAINTEXT to WELL KNOWN:"
spawn tpm_changeownerauth $opt -r -l debug
sleep 1
expect "Enter owner password" {
exp_send "$ownerPasswd\r"
if {$opt == "-o"} {
set wnOpt "-z"
}
expect {
"ngeAuth success" {
expect "Tspi_Context_Close success" {
send_user "PLAINTEXT to WELL KNOWN auth change SUCCEED. \n\n"
}
}
"*Auth*ailed" {
expect "Tspi_Context_Close success" {
send_user "PLAINTEXT to WELL KNOWN auth change FAILED. \n\n"
}
}
}
}
sleep 4
# Well Known -> Unicode
puts stdout "Test 4) tpm_changeownerauth \"$opt\": Changing password from WELL KNOWN to UNICODE:"
spawn tpm_changeownerauth $opt $wnOpt -n -l debug
sleep 1
if {$wnOpt != "-z"} {
expect "Enter owner password" {exp_send "$ownerPasswd\r"}
}
if {$opt == "-s"} {
expect "Enter new SRK" {
exp_send "$SRKPasswd\r"
expect "Confirm" {
exp_send "$SRKPasswd\r"
}
}
} else {
expect "Enter new owner" {
exp_send "$ownerPasswd\r"
expect "Confirm" {
exp_send "$ownerPasswd\r"
set wnOpt ""
set isU "-g"
}
}
}
expect {
"ngeAuth success" {
expect "Tspi_Context_Close success" {
send_user "WELL KNOWN to UNICODE auth change SUCCEED. \n\n"
}
}
"*Auth*ailed" {
expect "Tspi_Context_Close success" {
send_user "WELL KNOWN to UNICODE auth change FAILED. \n\n"
}
}
}
sleep 4
# Unicode -> Well Known
puts stdout "Test 5) tpm_changeownerauth \"$opt\": Changing password from UNICODE to WELL KNOWN:"
spawn tpm_changeownerauth $opt $isU -r -l debug
sleep 1
if {$wnOpt != "-z"} {
expect "Enter owner password" {exp_send "$ownerPasswd\r"}
}
if {$opt == "-o"} {
set wnOpt "-z"
}
expect {
"ngeAuth success" {
expect "Tspi_Context_Close success" {
send_user "UNICODE to WELL KNOWN auth change SUCCEED. \n\n"
}
}
"*Auth*ailed" {
expect "Tspi_Context_Close success" {
send_user "UNICODE to WELL KNOWN auth change FAILED. \n\n"
}
}
}
sleep 4
# Well Known -> Plain - return to the starting state
puts stdout "Test 6) tpm_changeownerauth \"$opt\": Changing password from WELL KNOWN to PLAIN:"
spawn tpm_changeownerauth $opt $wnOpt -l debug
sleep 1
if {$wnOpt != "-z"} {
expect "Enter owner password" {exp_send "$ownerPasswd\r"}
}
if {$opt == "-s" } {
expect "Enter new SRK" {
exp_send "$SRKPasswd\r"
expect "Confirm" {
exp_send "$SRKPasswd\r"
}
}
} else {
expect "Enter new owner" {
exp_send "$ownerPasswd\r"
expect "Confirm" {
exp_send "$ownerPasswd\r"
}
}
}
expect {
"ngeAuth succes" {
expect "Tspi_Context_Close success" {
send_user "WELL KNOWN to PLAIN auth change SUCCEED. \n\n"
}
}
"*Auth*ailed" {
expect "Tspi_Context_Close success" {
send_user "WELL KNOWN to PLAIN auth change FAILED. \n\n"
}
}
}
sleep 4
}