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

Side by Side Diff: tpm/tpm_marshalling.h

Issue 660204: Upgrade to tpm-emulator version 0.7. (Closed)
Patch Set: Created 10 years, 9 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
« no previous file with comments | « tpm/tpm_management.c ('k') | tpm/tpm_marshalling.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Software-Based Trusted Platform Module (TPM) Emulator for Linux 1 /* Software-based Trusted Platform Module (TPM) Emulator
2 * Copyright (C) 2004 Mario Strasser <mast@gmx.net>, 2 * Copyright (C) 2004-2010 Mario Strasser <mast@gmx.net>
3 * Swiss Federal Institute of Technology (ETH) Zurich
4 * 3 *
5 * This module is free software; you can redistribute it and/or modify 4 * This module is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published 5 * it under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License, 6 * by the Free Software Foundation; either version 2 of the License,
8 * or (at your option) any later version. 7 * or (at your option) any later version.
9 * 8 *
10 * This module is distributed in the hope that it will be useful, 9 * This module is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 12 * GNU General Public License for more details.
14 * 13 *
15 * $Id$ 14 * $Id: tpm_marshalling.h 384 2010-02-17 14:17:43Z mast $
16 */ 15 */
17 16
18 #ifndef _MARSHALLING_H_ 17 #ifndef _TPM_MARSHALLING_H_
19 #define _MARSHALLING_H_ 18 #define _TPM_MARSHALLING_H_
20 19
21 #include "tpm_emulator.h" 20 #include "tpm_emulator.h"
22 #include "tpm_structures.h" 21 #include "tpm_structures.h"
23 22
24 /* 23 /*
25 * The following functions perform the data marshalling of all 24 * The following functions perform the data marshalling of all
26 * TPM structures (as defined in [TPM_Part2]) which are used 25 * TPM structures (as defined in [TPM_Part2]) which are used
27 * either as an input or an output parameter by one of the 26 * either as an input or an output parameter by one of the
28 * TPM commands (as defined in [TPM_Part3]). 27 * TPM commands (as defined in [TPM_Part3]).
29 */ 28 */
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 { 67 {
69 if (*length < 1) return -1; 68 if (*length < 1) return -1;
70 *v = **ptr; 69 *v = **ptr;
71 *ptr += 1; *length -= 1; 70 *ptr += 1; *length -= 1;
72 return 0; 71 return 0;
73 } 72 }
74 73
75 static inline int tpm_marshal_UINT16(BYTE **ptr, UINT32 *length, UINT16 v) 74 static inline int tpm_marshal_UINT16(BYTE **ptr, UINT32 *length, UINT16 v)
76 { 75 {
77 if (*length < 2) return -1; 76 if (*length < 2) return -1;
78 (*ptr)[0] = (v >> 8) & 0xff; 77 (*ptr)[0] = (BYTE)((v >> 8) & 0xff);
79 (*ptr)[1] = v & 0xff; 78 (*ptr)[1] = (BYTE)(v & 0xff);
80 *ptr += 2; *length -= 2; 79 *ptr += 2; *length -= 2;
81 return 0; 80 return 0;
82 } 81 }
83 82
84 static inline int tpm_unmarshal_UINT16(BYTE **ptr, UINT32 *length, UINT16 *v) 83 static inline int tpm_unmarshal_UINT16(BYTE **ptr, UINT32 *length, UINT16 *v)
85 { 84 {
86 if (*length < 2) return -1; 85 if (*length < 2) return -1;
87 *v = (((UINT16)(*ptr)[0] << 8) | (*ptr)[1]); 86 *v = (((UINT16)(*ptr)[0] << 8) | (*ptr)[1]);
88 *ptr += 2; *length -= 2; 87 *ptr += 2; *length -= 2;
89 return 0; 88 return 0;
90 } 89 }
91 90
92 static inline int tpm_marshal_UINT32(BYTE **ptr, UINT32 *length, UINT32 v) 91 static inline int tpm_marshal_UINT32(BYTE **ptr, UINT32 *length, UINT32 v)
93 { 92 {
94 if (*length < 4) return -1; 93 if (*length < 4) return -1;
95 (*ptr)[0] = (v >> 24) & 0xff; (*ptr)[1] = (v >> 16) & 0xff; 94 (*ptr)[0] = (BYTE)((v >> 24) & 0xff); (*ptr)[1] = (BYTE)((v >> 16) & 0xff);
96 (*ptr)[2] = (v >> 8) & 0xff; (*ptr)[3] = v & 0xff; 95 (*ptr)[2] = (BYTE)((v >> 8) & 0xff); (*ptr)[3] = (BYTE)(v & 0xff);
97 *ptr += 4; *length -= 4; 96 *ptr += 4; *length -= 4;
98 return 0; 97 return 0;
99 } 98 }
100 99
101 static inline int tpm_unmarshal_UINT32(BYTE **ptr, UINT32 *length, UINT32 *v) 100 static inline int tpm_unmarshal_UINT32(BYTE **ptr, UINT32 *length, UINT32 *v)
102 { 101 {
103 if (*length < 4) return -1; 102 if (*length < 4) return -1;
104 *v = (((UINT32)(*ptr)[0] << 24) | ((UINT32)(*ptr)[1] << 16) | 103 *v = (((UINT32)(*ptr)[0] << 24) | ((UINT32)(*ptr)[1] << 16) |
105 ((UINT32)(*ptr)[2] << 8) | (*ptr)[3]); 104 ((UINT32)(*ptr)[2] << 8) | (*ptr)[3]);
106 *ptr += 4; *length -= 4; 105 *ptr += 4; *length -= 4;
107 return 0; 106 return 0;
108 } 107 }
109 108
110 static inline int tpm_marshal_UINT64(BYTE **ptr, UINT32 *length, UINT64 v) 109 static inline int tpm_marshal_UINT64(BYTE **ptr, UINT32 *length, UINT64 v)
111 { 110 {
112 if (*length < 8) return -1; 111 if (*length < 8) return -1;
113 (*ptr)[0] = (v >> 56) & 0xff; (*ptr)[1] = (v >> 48) & 0xff; 112 (*ptr)[0] = (BYTE)((v >> 56) & 0xff); (*ptr)[1] = (BYTE)((v >> 48) & 0xff);
114 (*ptr)[2] = (v >> 40) & 0xff; (*ptr)[3] = (v >> 32) & 0xff; 113 (*ptr)[2] = (BYTE)((v >> 40) & 0xff); (*ptr)[3] = (BYTE)((v >> 32) & 0xff);
115 (*ptr)[4] = (v >> 24) & 0xff; (*ptr)[5] = (v >> 16) & 0xff; 114 (*ptr)[4] = (BYTE)((v >> 24) & 0xff); (*ptr)[5] = (BYTE)((v >> 16) & 0xff);
116 (*ptr)[6] = (v >> 8) & 0xff; (*ptr)[7] = v & 0xff; 115 (*ptr)[6] = (BYTE)((v >> 8) & 0xff); (*ptr)[7] = (BYTE)(v & 0xff);
117 *ptr += 8; *length -= 8; 116 *ptr += 8; *length -= 8;
118 return 0; 117 return 0;
119 } 118 }
120 119
121 static inline int tpm_unmarshal_UINT64(BYTE **ptr, UINT32 *length, UINT64 *v) 120 static inline int tpm_unmarshal_UINT64(BYTE **ptr, UINT32 *length, UINT64 *v)
122 { 121 {
123 if (*length < 8) return -1; 122 if (*length < 8) return -1;
124 *v = (((UINT64)(*ptr)[0] << 56) | ((UINT64)(*ptr)[1] << 48) | 123 *v = (((UINT64)(*ptr)[0] << 56) | ((UINT64)(*ptr)[1] << 48) |
125 ((UINT64)(*ptr)[2] << 40) | ((UINT64)(*ptr)[3] << 32) | 124 ((UINT64)(*ptr)[2] << 40) | ((UINT64)(*ptr)[3] << 32) |
126 ((UINT64)(*ptr)[4] << 24) | ((UINT64)(*ptr)[5] << 16) | 125 ((UINT64)(*ptr)[4] << 24) | ((UINT64)(*ptr)[5] << 16) |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 475
477 int tpm_marshal_TPM_STCLEAR_FLAGS(BYTE **ptr, UINT32 *length, TPM_STCLEAR_FLAGS *v); 476 int tpm_marshal_TPM_STCLEAR_FLAGS(BYTE **ptr, UINT32 *length, TPM_STCLEAR_FLAGS *v);
478 int tpm_unmarshal_TPM_STCLEAR_FLAGS(BYTE **ptr, UINT32 *length, TPM_STCLEAR_FLAG S *v); 477 int tpm_unmarshal_TPM_STCLEAR_FLAGS(BYTE **ptr, UINT32 *length, TPM_STCLEAR_FLAG S *v);
479 478
480 int tpm_marshal_TPM_STANY_FLAGS(BYTE **ptr, UINT32 *length, TPM_STANY_FLAGS *v); 479 int tpm_marshal_TPM_STANY_FLAGS(BYTE **ptr, UINT32 *length, TPM_STANY_FLAGS *v);
481 int tpm_unmarshal_TPM_STANY_FLAGS(BYTE **ptr, UINT32 *length, TPM_STANY_FLAGS *v ); 480 int tpm_unmarshal_TPM_STANY_FLAGS(BYTE **ptr, UINT32 *length, TPM_STANY_FLAGS *v );
482 481
483 int tpm_marshal_RSA(BYTE **ptr, UINT32 *length, tpm_rsa_private_key_t *v); 482 int tpm_marshal_RSA(BYTE **ptr, UINT32 *length, tpm_rsa_private_key_t *v);
484 int tpm_unmarshal_RSA(BYTE **ptr, UINT32 *length, tpm_rsa_private_key_t *v); 483 int tpm_unmarshal_RSA(BYTE **ptr, UINT32 *length, tpm_rsa_private_key_t *v);
485 484
485 int tpm_marshal_RSAPub(BYTE **ptr, UINT32 *length, tpm_rsa_public_key_t *v);
486 int tpm_unmarshal_RSAPub(BYTE **ptr, UINT32 *length, tpm_rsa_public_key_t *v);
487
486 int tpm_marshal_TPM_KEY_DATA(BYTE **ptr, UINT32 *length, TPM_KEY_DATA *v); 488 int tpm_marshal_TPM_KEY_DATA(BYTE **ptr, UINT32 *length, TPM_KEY_DATA *v);
487 int tpm_unmarshal_TPM_KEY_DATA(BYTE **ptr, UINT32 *length, TPM_KEY_DATA *v); 489 int tpm_unmarshal_TPM_KEY_DATA(BYTE **ptr, UINT32 *length, TPM_KEY_DATA *v);
488 490
489 int tpm_marshal_TPM_PERMANENT_DATA(BYTE **ptr, UINT32 *length, TPM_PERMANENT_DAT A *); 491 int tpm_marshal_TPM_PERMANENT_DATA(BYTE **ptr, UINT32 *length, TPM_PERMANENT_DAT A *);
490 int tpm_unmarshal_TPM_PERMANENT_DATA(BYTE **ptr, UINT32 *length, TPM_PERMANENT_D ATA *); 492 int tpm_unmarshal_TPM_PERMANENT_DATA(BYTE **ptr, UINT32 *length, TPM_PERMANENT_D ATA *);
491 493
492 int tpm_marshal_TPM_STCLEAR_DATA(BYTE **ptr, UINT32 *length, TPM_STCLEAR_DATA *v ); 494 int tpm_marshal_TPM_STCLEAR_DATA(BYTE **ptr, UINT32 *length, TPM_STCLEAR_DATA *v );
493 int tpm_unmarshal_TPM_STCLEAR_DATA(BYTE **ptr, UINT32 *length, TPM_STCLEAR_DATA *v); 495 int tpm_unmarshal_TPM_STCLEAR_DATA(BYTE **ptr, UINT32 *length, TPM_STCLEAR_DATA *v);
494 496
495 int tpm_marshal_TPM_SESSION_DATA(BYTE **ptr, UINT32 *length, TPM_SESSION_DATA *v ); 497 int tpm_marshal_TPM_SESSION_DATA(BYTE **ptr, UINT32 *length, TPM_SESSION_DATA *v );
496 int tpm_unmarshal_TPM_SESSION_DATA(BYTE **ptr, UINT32 *length, TPM_SESSION_DATA *v); 498 int tpm_unmarshal_TPM_SESSION_DATA(BYTE **ptr, UINT32 *length, TPM_SESSION_DATA *v);
497 499
498 int tpm_marshal_TPM_STANY_DATA(BYTE **ptr, UINT32 *length, TPM_STANY_DATA *v); 500 int tpm_marshal_TPM_STANY_DATA(BYTE **ptr, UINT32 *length, TPM_STANY_DATA *v);
499 int tpm_unmarshal_TPM_STANY_DATA(BYTE **ptr, UINT32 *length, TPM_STANY_DATA *v); 501 int tpm_unmarshal_TPM_STANY_DATA(BYTE **ptr, UINT32 *length, TPM_STANY_DATA *v);
500 502
503 int tpm_unmarshal_TPM_DATA(BYTE **ptr, UINT32 *length, TPM_DATA *v);
504 int tpm_marshal_TPM_DATA(BYTE **ptr, UINT32 *length, TPM_DATA *v);
505
501 int tpm_marshal_TPM_RESPONSE(BYTE **ptr, UINT32 *length, TPM_RESPONSE *v); 506 int tpm_marshal_TPM_RESPONSE(BYTE **ptr, UINT32 *length, TPM_RESPONSE *v);
502 int tpm_unmarshal_TPM_REQUEST(BYTE **ptr, UINT32 *length, TPM_REQUEST *v); 507 int tpm_unmarshal_TPM_REQUEST(BYTE **ptr, UINT32 *length, TPM_REQUEST *v);
503 508
504 #endif /* _MARSHALLING_H_ */ 509 #endif /* _TPM_MARSHALLING_H_ */
OLDNEW
« no previous file with comments | « tpm/tpm_management.c ('k') | tpm/tpm_marshalling.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698