1 
2 /*
3  * Licensed Materials - Property of IBM
4  *
5  * trousers - An open source TCG Software Stack
6  *
7  * (C) Copyright International Business Machines Corp. 2004-2007
8  *
9  */
10 
11 
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <string.h>
15 #include <unistd.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #include <sys/mman.h>
19 #include <fcntl.h>
20 #include <errno.h>
21 
22 #include "trousers/tss.h"
23 #include "trousers_types.h"
24 #include "trousers_types.h"
25 #include "tcs_tsp.h"
26 #include "tcs_utils.h"
27 #include "tcs_int_literals.h"
28 #include "capabilities.h"
29 #include "tcsps.h"
30 #include "tcslog.h"
31 #include "tddl.h"
32 #include "req_mgr.h"
33 #include "tcsd_wrap.h"
34 #include "tcsd.h"
35 
36 TSS_RESULT
UnloadBlob_PCR_INFO_SHORT(UINT64 * offset,BYTE * blob,TPM_PCR_INFO_SHORT * pcrInfoOut)37 UnloadBlob_PCR_INFO_SHORT(UINT64 *offset, BYTE *blob, TPM_PCR_INFO_SHORT *pcrInfoOut)
38 {
39 	TSS_RESULT result;
40 	BYTE locAtRelease;
41 	TPM_DIGEST digest;
42 
43 	LogDebugFn("UnloadBlob_PCR_INFO_SHORT.");
44 	/* Only adjust the offset until the end of this data type */
45 	if (!pcrInfoOut) {
46 		if ((result = UnloadBlob_PCR_SELECTION(offset, blob, NULL)))
47 			return result;
48 		/* What should go to &pcrInfoOut->localityAtRelease */
49 		UnloadBlob_BYTE(offset, NULL, blob);
50 		/* What should go to &pcrInfoOut->digestAtRelease */
51 		UnloadBlob_DIGEST(offset, blob, NULL);
52 		return TSS_SUCCESS;
53 	}
54 
55 	/* Normal retrieve or TPM_PCR_INFO_SHORT (not used yet, kept for
56 	 * integrity purposes.
57 	 * TPM_PCR_SELECTION pcrSelection
58 	 * TPM_LOCALITY_SELECTION localityAtRelease
59 	 * TPM_COMPOSITE_HASH digestAtRelease
60 	 *  */
61 	if ((result = UnloadBlob_PCR_SELECTION(offset, blob, &pcrInfoOut->pcrSelection)))
62 		return result;
63 
64 	UnloadBlob_BYTE(offset, &locAtRelease, blob);
65 	pcrInfoOut->localityAtRelease = locAtRelease;
66 	UnloadBlob_DIGEST(offset, blob, &digest);
67 	pcrInfoOut->digestAtRelease = digest;
68 
69 	return TSS_SUCCESS;
70 }
71 
72 
73