Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: src/tlcl/tlcl.c

Issue 2663002: Add space redefinition test, early NV read test and early extend test. (Closed) Base URL: ssh://git@chromiumos-git/tpm_lite.git
Patch Set: Fix printf Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* A lightweight TPM command library. 6 /* A lightweight TPM command library.
7 * 7 *
8 * The general idea is that TPM commands are array of bytes whose fields are 8 * The general idea is that TPM commands are array of bytes whose fields are
9 * mostly compile-time constant. The goal is to build much of the commands at 9 * mostly compile-time constant. The goal is to build much of the commands at
10 * compile time (or build time) and change some of the fields at run time as 10 * compile time (or build time) and change some of the fields at run time as
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 244 }
245 245
246 void TlclStartup(void) { 246 void TlclStartup(void) {
247 Send(tpm_startup_cmd.buffer); 247 Send(tpm_startup_cmd.buffer);
248 } 248 }
249 249
250 void TlclSelftestfull(void) { 250 void TlclSelftestfull(void) {
251 Send(tpm_selftestfull_cmd.buffer); 251 Send(tpm_selftestfull_cmd.buffer);
252 } 252 }
253 253
254 void TlclContinueSelfTest(void) {
255 Send(tpm_continueselftest_cmd.buffer);
256 }
257
254 void TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size) { 258 void TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size) {
255 ToTpmUint32(tpm_nv_definespace_cmd.index, index); 259 ToTpmUint32(tpm_nv_definespace_cmd.index, index);
256 ToTpmUint32(tpm_nv_definespace_cmd.perm, perm); 260 ToTpmUint32(tpm_nv_definespace_cmd.perm, perm);
257 ToTpmUint32(tpm_nv_definespace_cmd.size, size); 261 ToTpmUint32(tpm_nv_definespace_cmd.size, size);
258 Send(tpm_nv_definespace_cmd.buffer); 262 Send(tpm_nv_definespace_cmd.buffer);
259 } 263 }
260 264
265 uint32_t TlclDefineSpaceResult(uint32_t index, uint32_t perm, uint32_t size) {
266 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
267 ToTpmUint32(tpm_nv_definespace_cmd.index, index);
268 ToTpmUint32(tpm_nv_definespace_cmd.perm, perm);
269 ToTpmUint32(tpm_nv_definespace_cmd.size, size);
270 SendReceive(tpm_nv_definespace_cmd.buffer, response, sizeof(response));
271 return TpmReturnCode(response);
272 }
273
261 uint32_t TlclWrite(uint32_t index, uint8_t* data, uint32_t length) { 274 uint32_t TlclWrite(uint32_t index, uint8_t* data, uint32_t length) {
262 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; 275 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
263 const int total_length = 276 const int total_length =
264 kTpmRequestHeaderLength + kWriteInfoLength + length; 277 kTpmRequestHeaderLength + kWriteInfoLength + length;
265 278
266 assert(total_length <= TPM_LARGE_ENOUGH_COMMAND_SIZE); 279 assert(total_length <= TPM_LARGE_ENOUGH_COMMAND_SIZE);
267 SetTpmCommandSize(tpm_nv_write_cmd.buffer, total_length); 280 SetTpmCommandSize(tpm_nv_write_cmd.buffer, total_length);
268 281
269 ToTpmUint32(tpm_nv_write_cmd.index, index); 282 ToTpmUint32(tpm_nv_write_cmd.index, index);
270 ToTpmUint32(tpm_nv_write_cmd.length, length); 283 ToTpmUint32(tpm_nv_write_cmd.length, length);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 void TlclReadLock(uint32_t index) { 318 void TlclReadLock(uint32_t index) {
306 if (TlclRead(index, NULL, 0) != TPM_SUCCESS) { 319 if (TlclRead(index, NULL, 0) != TPM_SUCCESS) {
307 error("failed to read lock space 0x%x\n", index); 320 error("failed to read lock space 0x%x\n", index);
308 } 321 }
309 } 322 }
310 323
311 void TlclAssertPhysicalPresence(void) { 324 void TlclAssertPhysicalPresence(void) {
312 Send(tpm_ppassert_cmd.buffer); 325 Send(tpm_ppassert_cmd.buffer);
313 } 326 }
314 327
328 uint32_t TlclAssertPhysicalPresenceResult(void) {
329 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
330 SendReceive(tpm_ppassert_cmd.buffer, response, sizeof(response));
331 return TpmReturnCode(response);
332 }
333
315 uint32_t TlclLockPhysicalPresence(void) { 334 uint32_t TlclLockPhysicalPresence(void) {
316 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; 335 uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
317 SendReceive(tpm_pplock_cmd.buffer, response, sizeof(response)); 336 SendReceive(tpm_pplock_cmd.buffer, response, sizeof(response));
318 return TpmReturnCode(response); 337 return TpmReturnCode(response);
319 } 338 }
320 339
321 void TlclSetNvLocked(void) { 340 void TlclSetNvLocked(void) {
322 TlclDefineSpace(TPM_NV_INDEX_LOCK, 0, 0); 341 TlclDefineSpace(TPM_NV_INDEX_LOCK, 0, 0);
323 } 342 }
324 343
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 (TPM_PERMANENT_FLAGS*) (response + kTpmResponseHeaderLength + sizeof(size)); 390 (TPM_PERMANENT_FLAGS*) (response + kTpmResponseHeaderLength + sizeof(size));
372 *disable = pflags->disable; 391 *disable = pflags->disable;
373 *deactivated = pflags->deactivated; 392 *deactivated = pflags->deactivated;
374 return result; 393 return result;
375 } 394 }
376 395
377 uint32_t TlclSetGlobalLock(void) { 396 uint32_t TlclSetGlobalLock(void) {
378 uint32_t x; 397 uint32_t x;
379 return TlclWrite(TPM_NV_INDEX0, (uint8_t*) &x, 0); 398 return TlclWrite(TPM_NV_INDEX0, (uint8_t*) &x, 0);
380 } 399 }
400
401 uint32_t TlclExtend(int pcr_num, uint8_t* in_digest, uint8_t* out_digest) {
402 uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength];
403 ToTpmUint32(tpm_extend_cmd.pcrNum, pcr_num);
404 memcpy(tpm_extend_cmd.inDigest, in_digest, kPcrDigestLength);
405 SendReceive(tpm_extend_cmd.buffer, response, sizeof(response));
406 memcpy(out_digest, response + kTpmResponseHeaderLength, kPcrDigestLength);
407 return TpmReturnCode(response);
408 }
OLDNEW
« src/testsuite/earlyextend.c ('K') | « src/tlcl/tlcl.h ('k') | src/tlcl/tlcl_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698