[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] vtpmmgr: make inline functions static
gcc7 is more strict with functions marked as inline. They are not automatically inlined. Instead a function call is generated, but the actual code is not visible by the linker. Do a mechanical change and mark every 'inline' as 'static inline'. For simpler review the static goes into an extra line. Signed-off-by: Olaf Hering <olaf@xxxxxxxxx> --- stubdom/vtpmmgr/marshal.h | 76 ++++++++++++++++++++++++++++++++++++++++++ stubdom/vtpmmgr/tcg.h | 14 ++++++++ stubdom/vtpmmgr/tpm2_marshal.h | 58 ++++++++++++++++++++++++++++++++ stubdom/vtpmmgr/tpmrsa.h | 1 + 4 files changed, 149 insertions(+) diff --git a/stubdom/vtpmmgr/marshal.h b/stubdom/vtpmmgr/marshal.h index d826f19d89..dce19c6439 100644 --- a/stubdom/vtpmmgr/marshal.h +++ b/stubdom/vtpmmgr/marshal.h @@ -47,16 +47,19 @@ typedef enum UnpackPtr { UNPACK_ALLOC } UnpackPtr; +static inline BYTE* pack_BYTE(BYTE* ptr, BYTE t) { ptr[0] = t; return ++ptr; } +static inline BYTE* unpack_BYTE(BYTE* ptr, BYTE* t) { t[0] = ptr[0]; return ++ptr; } +static inline int unpack3_BYTE(BYTE* ptr, UINT32* pos, UINT32 max, BYTE *t) { if (*pos + 1 > max) @@ -72,18 +75,21 @@ inline int unpack3_BYTE(BYTE* ptr, UINT32* pos, UINT32 max, BYTE *t) #define unpack3_BOOL(p, x, m, t) unpack3_BYTE(p, x, m, t) #define sizeof_BOOL(t) 1 +static inline BYTE* pack_UINT16(void* ptr, UINT16 t) { UINT16* p = ptr; *p = cpu_to_be16(t); return ptr + sizeof(UINT16); } +static inline BYTE* unpack_UINT16(void* ptr, UINT16* t) { UINT16* p = ptr; *t = be16_to_cpu(*p); return ptr + sizeof(UINT16); } +static inline int unpack3_UINT16(BYTE* ptr, UINT32* pos, UINT32 max, UINT16 *t) { if (*pos + 2 > max) @@ -93,18 +99,21 @@ inline int unpack3_UINT16(BYTE* ptr, UINT32* pos, UINT32 max, UINT16 *t) return 0; } +static inline BYTE* pack_UINT32(void* ptr, UINT32 t) { UINT32* p = ptr; *p = cpu_to_be32(t); return ptr + sizeof(UINT32); } +static inline BYTE* unpack_UINT32(void* ptr, UINT32* t) { UINT32* p = ptr; *t = be32_to_cpu(*p); return ptr + sizeof(UINT32); } +static inline int unpack3_UINT32(BYTE* ptr, UINT32* pos, UINT32 max, UINT32 *t) { if (*pos + 4 > max) @@ -236,16 +245,19 @@ inline int unpack3_UINT32(BYTE* ptr, UINT32* pos, UINT32 max, UINT32 *t) #define sizeof_TCS_KEY_HANDLE(t) sizeof_UINT32(t) +static inline BYTE* pack_BUFFER(BYTE* ptr, const BYTE* buf, UINT32 size) { memcpy(ptr, buf, size); return ptr + size; } +static inline BYTE* unpack_BUFFER(BYTE* ptr, BYTE* buf, UINT32 size) { memcpy(buf, ptr, size); return ptr + size; } +static inline int unpack3_BUFFER(BYTE* ptr, UINT32* pos, UINT32 max, BYTE* buf, UINT32 size) { if (*pos + size > max) return TPM_SIZE; @@ -256,11 +268,13 @@ inline int unpack3_BUFFER(BYTE* ptr, UINT32* pos, UINT32 max, BYTE* buf, UINT32 #define sizeof_BUFFER(b, s) s +static inline BYTE* unpack_ALIAS(BYTE* ptr, BYTE** buf, UINT32 size) { *buf = ptr; return ptr + size; } +static inline BYTE* unpack_ALLOC(BYTE* ptr, BYTE** buf, UINT32 size) { if(size) { *buf = malloc(size); @@ -271,6 +285,7 @@ inline BYTE* unpack_ALLOC(BYTE* ptr, BYTE** buf, UINT32 size) { return ptr + size; } +static inline BYTE* unpack_PTR(BYTE* ptr, BYTE** buf, UINT32 size, UnpackPtr alloc) { if(alloc == UNPACK_ALLOC) { return unpack_ALLOC(ptr, buf, size); @@ -279,6 +294,7 @@ inline BYTE* unpack_PTR(BYTE* ptr, BYTE** buf, UINT32 size, UnpackPtr alloc) { } } +static inline int unpack3_PTR(BYTE* ptr, UINT32* pos, UINT32 max, BYTE** buf, UINT32 size, UnpackPtr alloc) { if (size > max || *pos + size > max) return TPM_SIZE; @@ -292,14 +308,17 @@ inline int unpack3_PTR(BYTE* ptr, UINT32* pos, UINT32 max, BYTE** buf, UINT32 si } #define unpack3_VPTR(ptr, pos, max, buf, size, alloc) unpack3_PTR(ptr, pos, max, (void*)(buf), size, alloc) +static inline BYTE* pack_TPM_AUTHDATA(BYTE* ptr, const TPM_AUTHDATA* d) { return pack_BUFFER(ptr, *d, TPM_DIGEST_SIZE); } +static inline BYTE* unpack_TPM_AUTHDATA(BYTE* ptr, TPM_AUTHDATA* d) { return unpack_BUFFER(ptr, *d, TPM_DIGEST_SIZE); } +static inline int unpack3_TPM_AUTHDATA(BYTE* ptr, UINT32* pos, UINT32 len, TPM_AUTHDATA* d) { return unpack3_BUFFER(ptr, pos, len, *d, TPM_DIGEST_SIZE); } @@ -325,6 +344,7 @@ inline int unpack3_TPM_AUTHDATA(BYTE* ptr, UINT32* pos, UINT32 len, TPM_AUTHDATA #define sizeof_TPM_TAG(t) sizeof_UINT16(t) #define sizeof_TPM_STRUCTURE_TAG(t) sizeof_UINT16(t) +static inline BYTE* pack_TPM_VERSION(BYTE* ptr, const TPM_VERSION* t) { ptr[0] = t->major; ptr[1] = t->minor; @@ -333,6 +353,7 @@ inline BYTE* pack_TPM_VERSION(BYTE* ptr, const TPM_VERSION* t) { return ptr + 4; } +static inline BYTE* unpack_TPM_VERSION(BYTE* ptr, TPM_VERSION* t) { t->major = ptr[0]; t->minor = ptr[1]; @@ -341,6 +362,7 @@ inline BYTE* unpack_TPM_VERSION(BYTE* ptr, TPM_VERSION* t) { return ptr + 4; } +static inline int unpack3_TPM_VERSION(BYTE* ptr, UINT32 *pos, UINT32 max, TPM_VERSION* t) { if (*pos + 4 > max) return TPM_SIZE; @@ -355,6 +377,7 @@ inline int unpack3_TPM_VERSION(BYTE* ptr, UINT32 *pos, UINT32 max, TPM_VERSION* #define sizeof_TPM_VERSION(x) 4 +static inline BYTE* pack_TPM_CAP_VERSION_INFO(BYTE* ptr, const TPM_CAP_VERSION_INFO* v) { ptr = pack_TPM_STRUCTURE_TAG(ptr, v->tag); ptr = pack_TPM_VERSION(ptr, &v->version); @@ -366,6 +389,7 @@ inline BYTE* pack_TPM_CAP_VERSION_INFO(BYTE* ptr, const TPM_CAP_VERSION_INFO* v) return ptr; } +static inline BYTE* unpack_TPM_CAP_VERSION_INFO(BYTE* ptr, TPM_CAP_VERSION_INFO* v, UnpackPtr alloc) { ptr = unpack_TPM_STRUCTURE_TAG(ptr, &v->tag); ptr = unpack_TPM_VERSION(ptr, &v->version); @@ -377,14 +401,17 @@ inline BYTE* unpack_TPM_CAP_VERSION_INFO(BYTE* ptr, TPM_CAP_VERSION_INFO* v, Unp return ptr; } +static inline BYTE* pack_TPM_DIGEST(BYTE* ptr, const TPM_DIGEST* d) { return pack_BUFFER(ptr, d->digest, TPM_DIGEST_SIZE); } +static inline BYTE* unpack_TPM_DIGEST(BYTE* ptr, TPM_DIGEST* d) { return unpack_BUFFER(ptr, d->digest, TPM_DIGEST_SIZE); } +static inline int unpack3_TPM_DIGEST(BYTE* ptr, UINT32* pos, UINT32 max, TPM_DIGEST* d) { return unpack3_BUFFER(ptr, pos, max, d->digest, TPM_DIGEST_SIZE); } @@ -409,20 +436,24 @@ inline int unpack3_TPM_DIGEST(BYTE* ptr, UINT32* pos, UINT32 max, TPM_DIGEST* d) #define pack_TPM_CHOSENID_HASH(ptr, d) pack_TPM_DIGEST(ptr, d) #define unpack_TPM_CHOSENID_HASH(ptr, d) unpack_TPM_DIGEST(ptr, d) +static inline BYTE* pack_TPM_NONCE(BYTE* ptr, const TPM_NONCE* n) { return pack_BUFFER(ptr, n->nonce, TPM_DIGEST_SIZE); } +static inline BYTE* unpack_TPM_NONCE(BYTE* ptr, TPM_NONCE* n) { return unpack_BUFFER(ptr, n->nonce, TPM_DIGEST_SIZE); } #define sizeof_TPM_NONCE(x) TPM_DIGEST_SIZE +static inline int unpack3_TPM_NONCE(BYTE* ptr, UINT32* pos, UINT32 max, TPM_NONCE* n) { return unpack3_BUFFER(ptr, pos, max, n->nonce, TPM_DIGEST_SIZE); } +static inline BYTE* pack_TPM_SYMMETRIC_KEY_PARMS(BYTE* ptr, const TPM_SYMMETRIC_KEY_PARMS* k) { ptr = pack_UINT32(ptr, k->keyLength); ptr = pack_UINT32(ptr, k->blockSize); @@ -430,6 +461,7 @@ inline BYTE* pack_TPM_SYMMETRIC_KEY_PARMS(BYTE* ptr, const TPM_SYMMETRIC_KEY_PAR return pack_BUFFER(ptr, k->IV, k->ivSize); } +static inline BYTE* pack_TPM_SYMMETRIC_KEY(BYTE* ptr, const TPM_SYMMETRIC_KEY* k) { ptr = pack_UINT32(ptr, k->algId); ptr = pack_UINT16(ptr, k->encScheme); @@ -437,6 +469,7 @@ inline BYTE* pack_TPM_SYMMETRIC_KEY(BYTE* ptr, const TPM_SYMMETRIC_KEY* k) { return pack_BUFFER(ptr, k->data, k->size); } +static inline int unpack3_TPM_SYMMETRIC_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 max, TPM_SYMMETRIC_KEY_PARMS* k, UnpackPtr alloc) { return unpack3_UINT32(ptr, pos, max, &k->keyLength) || unpack3_UINT32(ptr, pos, max, &k->blockSize) || @@ -444,10 +477,12 @@ inline int unpack3_TPM_SYMMETRIC_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 max, T unpack3_PTR(ptr, pos, max, &k->IV, k->ivSize, alloc); } +static inline int sizeof_TPM_SYMMETRIC_KEY_PARMS(const TPM_SYMMETRIC_KEY_PARMS* k) { return 12 + k->ivSize; } +static inline int unpack3_TPM_SYMMETRIC_KEY(BYTE* ptr, UINT32* pos, UINT32 max, TPM_SYMMETRIC_KEY* k, UnpackPtr alloc) { return unpack3_UINT32(ptr, pos, max, &k->algId) || unpack3_UINT16(ptr, pos, max, &k->encScheme) || @@ -455,6 +490,7 @@ inline int unpack3_TPM_SYMMETRIC_KEY(BYTE* ptr, UINT32* pos, UINT32 max, TPM_SYM unpack3_PTR(ptr, pos, max, &k->data, k->size, alloc); } +static inline BYTE* pack_TPM_RSA_KEY_PARMS(BYTE* ptr, const TPM_RSA_KEY_PARMS* k) { ptr = pack_UINT32(ptr, k->keyLength); ptr = pack_UINT32(ptr, k->numPrimes); @@ -462,6 +498,7 @@ inline BYTE* pack_TPM_RSA_KEY_PARMS(BYTE* ptr, const TPM_RSA_KEY_PARMS* k) { return pack_BUFFER(ptr, k->exponent, k->exponentSize); } +static inline int unpack3_TPM_RSA_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 max, TPM_RSA_KEY_PARMS* k, UnpackPtr alloc) { return unpack3_UINT32(ptr, pos, max, &k->keyLength) || unpack3_UINT32(ptr, pos, max, &k->numPrimes) || @@ -469,11 +506,13 @@ inline int unpack3_TPM_RSA_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 max, TPM_RSA unpack3_PTR(ptr, pos, max, &k->exponent, k->exponentSize, alloc); } +static inline int sizeof_TPM_RSA_KEY_PARMS(const TPM_RSA_KEY_PARMS* k) { return 12 + k->exponentSize; } +static inline BYTE* pack_TPM_KEY_PARMS(BYTE* ptr, const TPM_KEY_PARMS* k) { ptr = pack_TPM_ALGORITHM_ID(ptr, k->algorithmID); ptr = pack_TPM_ENC_SCHEME(ptr, k->encScheme); @@ -493,6 +532,7 @@ inline BYTE* pack_TPM_KEY_PARMS(BYTE* ptr, const TPM_KEY_PARMS* k) { return ptr; } +static inline int unpack3_TPM_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 len, TPM_KEY_PARMS* k, UnpackPtr alloc) { int rc = unpack3_TPM_ALGORITHM_ID(ptr, pos, len, &k->algorithmID) || unpack3_TPM_ENC_SCHEME(ptr, pos, len, &k->encScheme) || @@ -511,6 +551,7 @@ inline int unpack3_TPM_KEY_PARMS(BYTE* ptr, UINT32* pos, UINT32 len, TPM_KEY_PAR return TPM_FAIL; } +static inline int sizeof_TPM_KEY_PARMS(const TPM_KEY_PARMS* k) { int rc = 0; rc += sizeof_TPM_ALGORITHM_ID(&k->algorithmID); @@ -532,52 +573,62 @@ inline int sizeof_TPM_KEY_PARMS(const TPM_KEY_PARMS* k) { return rc; } +static inline BYTE* pack_TPM_STORE_PUBKEY(BYTE* ptr, const TPM_STORE_PUBKEY* k) { ptr = pack_UINT32(ptr, k->keyLength); ptr = pack_BUFFER(ptr, k->key, k->keyLength); return ptr; } +static inline int unpack3_TPM_STORE_PUBKEY(BYTE* ptr, UINT32* pos, UINT32 max, TPM_STORE_PUBKEY* k, UnpackPtr alloc) { return unpack3_UINT32(ptr, pos, max, &k->keyLength) || unpack3_PTR(ptr, pos, max, &k->key, k->keyLength, alloc); } +static inline int sizeof_TPM_STORE_PUBKEY(const TPM_STORE_PUBKEY* k) { return 4 + k->keyLength; } +static inline BYTE* pack_TPM_PUBKEY(BYTE* ptr, const TPM_PUBKEY* k) { ptr = pack_TPM_KEY_PARMS(ptr, &k->algorithmParms); return pack_TPM_STORE_PUBKEY(ptr, &k->pubKey); } +static inline int unpack3_TPM_PUBKEY(BYTE* ptr, UINT32* pos, UINT32 len, TPM_PUBKEY* k, UnpackPtr alloc) { return unpack3_TPM_KEY_PARMS(ptr, pos, len, &k->algorithmParms, alloc) || unpack3_TPM_STORE_PUBKEY(ptr, pos, len, &k->pubKey, alloc); } +static inline BYTE* pack_TPM_PCR_SELECTION(BYTE* ptr, const TPM_PCR_SELECTION* p) { ptr = pack_UINT16(ptr, p->sizeOfSelect); ptr = pack_BUFFER(ptr, p->pcrSelect, p->sizeOfSelect); return ptr; } +static inline BYTE* unpack_TPM_PCR_SELECTION(BYTE* ptr, TPM_PCR_SELECTION* p, UnpackPtr alloc) { ptr = unpack_UINT16(ptr, &p->sizeOfSelect); ptr = unpack_PTR(ptr, &p->pcrSelect, p->sizeOfSelect, alloc); return ptr; } +static inline int unpack3_TPM_PCR_SELECTION(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_SELECTION* p, UnpackPtr alloc) { return unpack3_UINT16(ptr, pos, max, &p->sizeOfSelect) || unpack3_PTR(ptr, pos, max, &p->pcrSelect, p->sizeOfSelect, alloc); } +static inline int sizeof_TPM_PCR_SELECTION(const TPM_PCR_SELECTION* p) { return 2 + p->sizeOfSelect; } +static inline BYTE* pack_TPM_PCR_INFO(BYTE* ptr, const TPM_PCR_INFO* p) { ptr = pack_TPM_PCR_SELECTION(ptr, &p->pcrSelection); ptr = pack_TPM_COMPOSITE_HASH(ptr, &p->digestAtRelease); @@ -585,12 +636,14 @@ inline BYTE* pack_TPM_PCR_INFO(BYTE* ptr, const TPM_PCR_INFO* p) { return ptr; } +static inline int unpack3_TPM_PCR_INFO(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_INFO* p, UnpackPtr alloc) { return unpack3_TPM_PCR_SELECTION(ptr, pos, max, &p->pcrSelection, alloc) || unpack3_TPM_COMPOSITE_HASH(ptr, pos, max, &p->digestAtRelease) || unpack3_TPM_COMPOSITE_HASH(ptr, pos, max, &p->digestAtCreation); } +static inline int sizeof_TPM_PCR_INFO(const TPM_PCR_INFO* p) { int rc = 0; rc += sizeof_TPM_PCR_SELECTION(&p->pcrSelection); @@ -599,6 +652,7 @@ inline int sizeof_TPM_PCR_INFO(const TPM_PCR_INFO* p) { return rc; } +static inline BYTE* pack_TPM_PCR_INFO_LONG(BYTE* ptr, const TPM_PCR_INFO_LONG* p) { ptr = pack_TPM_STRUCTURE_TAG(ptr, p->tag); ptr = pack_TPM_LOCALITY_SELECTION(ptr, p->localityAtCreation); @@ -610,6 +664,7 @@ inline BYTE* pack_TPM_PCR_INFO_LONG(BYTE* ptr, const TPM_PCR_INFO_LONG* p) { return ptr; } +static inline int sizeof_TPM_PCR_INFO_LONG(const TPM_PCR_INFO_LONG* p) { int rc = 0; rc += sizeof_TPM_STRUCTURE_TAG(p->tag); @@ -622,6 +677,7 @@ inline int sizeof_TPM_PCR_INFO_LONG(const TPM_PCR_INFO_LONG* p) { return rc; } +static inline int unpack3_TPM_PCR_INFO_LONG(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_INFO_LONG* p, UnpackPtr alloc) { return unpack3_TPM_STRUCTURE_TAG(ptr, pos, max, &p->tag) || unpack3_TPM_LOCALITY_SELECTION(ptr, pos, max, @@ -637,6 +693,7 @@ inline int unpack3_TPM_PCR_INFO_LONG(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR unpack3_TPM_COMPOSITE_HASH(ptr, pos, max, &p->digestAtRelease); } +static inline BYTE* pack_TPM_PCR_COMPOSITE(BYTE* ptr, const TPM_PCR_COMPOSITE* p) { ptr = pack_TPM_PCR_SELECTION(ptr, &p->select); ptr = pack_UINT32(ptr, p->valueSize); @@ -644,12 +701,14 @@ inline BYTE* pack_TPM_PCR_COMPOSITE(BYTE* ptr, const TPM_PCR_COMPOSITE* p) { return ptr; } +static inline int unpack3_TPM_PCR_COMPOSITE(BYTE* ptr, UINT32* pos, UINT32 max, TPM_PCR_COMPOSITE* p, UnpackPtr alloc) { return unpack3_TPM_PCR_SELECTION(ptr, pos, max, &p->select, alloc) || unpack3_UINT32(ptr, pos, max, &p->valueSize) || unpack3_PTR(ptr, pos, max, (BYTE**)&p->pcrValue, p->valueSize, alloc); } +static inline BYTE* pack_TPM_KEY(BYTE* ptr, const TPM_KEY* k) { ptr = pack_TPM_VERSION(ptr, &k->ver); ptr = pack_TPM_KEY_USAGE(ptr, k->keyUsage); @@ -665,6 +724,7 @@ inline BYTE* pack_TPM_KEY(BYTE* ptr, const TPM_KEY* k) { return pack_BUFFER(ptr, k->encData, k->encDataSize); } +static inline int unpack3_TPM_KEY(BYTE* ptr, UINT32* pos, UINT32 max, TPM_KEY* k, UnpackPtr alloc) { int rc = unpack3_TPM_VERSION(ptr, pos, max, &k->ver) || unpack3_TPM_KEY_USAGE(ptr, pos, max, &k->keyUsage) || @@ -682,6 +742,7 @@ inline int unpack3_TPM_KEY(BYTE* ptr, UINT32* pos, UINT32 max, TPM_KEY* k, Unpac unpack3_PTR(ptr, pos, max, &k->encData, k->encDataSize, alloc); } +static inline int sizeof_TPM_KEY(const TPM_KEY* k) { int rc = 0; rc += sizeof_TPM_VERSION(&k->ver); @@ -699,18 +760,21 @@ inline int sizeof_TPM_KEY(const TPM_KEY* k) { return rc; } +static inline BYTE* pack_TPM_BOUND_DATA(BYTE* ptr, const TPM_BOUND_DATA* b, UINT32 payloadSize) { ptr = pack_TPM_VERSION(ptr, &b->ver); ptr = pack_TPM_PAYLOAD_TYPE(ptr, b->payload); return pack_BUFFER(ptr, b->payloadData, payloadSize); } +static inline BYTE* unpack_TPM_BOUND_DATA(BYTE* ptr, TPM_BOUND_DATA* b, UINT32 payloadSize, UnpackPtr alloc) { ptr = unpack_TPM_VERSION(ptr, &b->ver); ptr = unpack_TPM_PAYLOAD_TYPE(ptr, &b->payload); return unpack_PTR(ptr, &b->payloadData, payloadSize, alloc); } +static inline BYTE* pack_TPM_STORED_DATA(BYTE* ptr, const TPM_STORED_DATA* d) { ptr = pack_TPM_VERSION(ptr, &d->ver); ptr = pack_UINT32(ptr, d->sealInfoSize); @@ -722,6 +786,7 @@ inline BYTE* pack_TPM_STORED_DATA(BYTE* ptr, const TPM_STORED_DATA* d) { return ptr; } +static inline int sizeof_TPM_STORED_DATA(const TPM_STORED_DATA* d) { int rv = sizeof_TPM_VERSION(&d->ver) + sizeof_UINT32(d->sealInfoSize); if (d->sealInfoSize) { @@ -732,6 +797,7 @@ inline int sizeof_TPM_STORED_DATA(const TPM_STORED_DATA* d) { return rv; } +static inline int unpack3_TPM_STORED_DATA(BYTE* ptr, UINT32* pos, UINT32 len, TPM_STORED_DATA* d, UnpackPtr alloc) { int rc = unpack3_TPM_VERSION(ptr, pos, len, &d->ver) || unpack3_UINT32(ptr, pos, len, &d->sealInfoSize); @@ -746,6 +812,7 @@ inline int unpack3_TPM_STORED_DATA(BYTE* ptr, UINT32* pos, UINT32 len, TPM_STORE return rc; } +static inline BYTE* pack_TPM_STORED_DATA12(BYTE* ptr, const TPM_STORED_DATA12* d) { ptr = pack_TPM_STRUCTURE_TAG(ptr, d->tag); ptr = pack_TPM_ENTITY_TYPE(ptr, d->et); @@ -758,6 +825,7 @@ inline BYTE* pack_TPM_STORED_DATA12(BYTE* ptr, const TPM_STORED_DATA12* d) { return ptr; } +static inline int sizeof_TPM_STORED_DATA12(const TPM_STORED_DATA12* d) { int rv = sizeof_TPM_STRUCTURE_TAG(&d->ver) + sizeof_TPM_ENTITY_TYPE(&d->et) + @@ -770,6 +838,7 @@ inline int sizeof_TPM_STORED_DATA12(const TPM_STORED_DATA12* d) { return rv; } +static inline int unpack3_TPM_STORED_DATA12(BYTE* ptr, UINT32* pos, UINT32 len, TPM_STORED_DATA12* d, UnpackPtr alloc) { int rc = unpack3_TPM_STRUCTURE_TAG(ptr, pos, len, &d->tag) || unpack3_TPM_ENTITY_TYPE(ptr, pos, len, &d->et) || @@ -786,6 +855,7 @@ inline int unpack3_TPM_STORED_DATA12(BYTE* ptr, UINT32* pos, UINT32 len, TPM_STO return rc; } +static inline BYTE* pack_TPM_AUTH_SESSION(BYTE* ptr, const TPM_AUTH_SESSION* auth) { ptr = pack_TPM_AUTH_HANDLE(ptr, auth->AuthHandle); ptr = pack_TPM_NONCE(ptr, &auth->NonceOdd); @@ -794,6 +864,7 @@ inline BYTE* pack_TPM_AUTH_SESSION(BYTE* ptr, const TPM_AUTH_SESSION* auth) { return ptr; } +static inline BYTE* unpack_TPM_AUTH_SESSION(BYTE* ptr, TPM_AUTH_SESSION* auth) { ptr = unpack_TPM_NONCE(ptr, &auth->NonceEven); ptr = unpack_BOOL(ptr, &auth->fContinueAuthSession); @@ -801,6 +872,7 @@ inline BYTE* unpack_TPM_AUTH_SESSION(BYTE* ptr, TPM_AUTH_SESSION* auth) { return ptr; } +static inline int unpack3_TPM_AUTH_SESSION(BYTE* ptr, UINT32* pos, UINT32 len, TPM_AUTH_SESSION* auth) { return unpack3_TPM_NONCE(ptr, pos, len, &auth->NonceEven) || unpack3_BOOL(ptr, pos, len, &auth->fContinueAuthSession) || @@ -808,6 +880,7 @@ inline int unpack3_TPM_AUTH_SESSION(BYTE* ptr, UINT32* pos, UINT32 len, TPM_AUTH } +static inline int sizeof_TPM_AUTH_SESSION(const TPM_AUTH_SESSION* auth) { int rv = 0; rv += sizeof_TPM_AUTH_HANDLE(auth->AuthHandle); @@ -817,6 +890,7 @@ inline int sizeof_TPM_AUTH_SESSION(const TPM_AUTH_SESSION* auth) { return rv; } +static inline BYTE* pack_TPM_RQU_HEADER(BYTE* ptr, TPM_TAG tag, UINT32 size, @@ -826,6 +900,7 @@ inline BYTE* pack_TPM_RQU_HEADER(BYTE* ptr, return pack_UINT32(ptr, ord); } +static inline BYTE* unpack_TPM_RQU_HEADER(BYTE* ptr, TPM_TAG* tag, UINT32* size, @@ -836,6 +911,7 @@ inline BYTE* unpack_TPM_RQU_HEADER(BYTE* ptr, return ptr; } +static inline int unpack3_TPM_RQU_HEADER(BYTE* ptr, UINT32* pos, UINT32 max, TPM_TAG* tag, UINT32* size, TPM_COMMAND_CODE* ord) { return diff --git a/stubdom/vtpmmgr/tcg.h b/stubdom/vtpmmgr/tcg.h index 813ce57a2d..423131dc25 100644 --- a/stubdom/vtpmmgr/tcg.h +++ b/stubdom/vtpmmgr/tcg.h @@ -461,6 +461,7 @@ typedef struct TPM_CAP_VERSION_INFO { BYTE* vendorSpecific; } TPM_CAP_VERSION_INFO; +static inline void free_TPM_CAP_VERSION_INFO(TPM_CAP_VERSION_INFO* v) { free(v->vendorSpecific); v->vendorSpecific = NULL; @@ -494,6 +495,7 @@ typedef struct TPM_SYMMETRIC_KEY { BYTE* data; } TPM_SYMMETRIC_KEY; +static inline void free_TPM_SYMMETRIC_KEY_PARMS(TPM_SYMMETRIC_KEY_PARMS* p) { free(p->IV); p->IV = NULL; @@ -510,6 +512,7 @@ typedef struct TPM_RSA_KEY_PARMS { #define TPM_RSA_KEY_PARMS_INIT { 0, 0, 0, NULL } +static inline void free_TPM_RSA_KEY_PARMS(TPM_RSA_KEY_PARMS* p) { free(p->exponent); p->exponent = NULL; @@ -528,6 +531,7 @@ typedef struct TPM_KEY_PARMS { #define TPM_KEY_PARMS_INIT { 0, 0, 0, 0 } +static inline void free_TPM_KEY_PARMS(TPM_KEY_PARMS* p) { if(p->parmSize) { switch(p->algorithmID) { @@ -550,6 +554,7 @@ typedef struct TPM_STORE_PUBKEY { #define TPM_STORE_PUBKEY_INIT { 0, NULL } +static inline void free_TPM_STORE_PUBKEY(TPM_STORE_PUBKEY* p) { free(p->key); p->key = NULL; @@ -562,6 +567,7 @@ typedef struct TPM_PUBKEY { #define TPM_PUBKEY_INIT { TPM_KEY_PARMS_INIT, TPM_STORE_PUBKEY_INIT } +static inline void free_TPM_PUBKEY(TPM_PUBKEY* k) { free_TPM_KEY_PARMS(&k->algorithmParms); free_TPM_STORE_PUBKEY(&k->pubKey); @@ -574,6 +580,7 @@ typedef struct TPM_PCR_SELECTION { #define TPM_PCR_SELECTION_INIT { 0, NULL } +static inline void free_TPM_PCR_SELECTION(TPM_PCR_SELECTION* p) { free(p->pcrSelect); p->pcrSelect = NULL; @@ -594,6 +601,7 @@ typedef struct TPM_PCR_INFO_LONG { #define TPM_PCR_INFO_LONG_INIT { 0, 0, 0, TPM_PCR_SELECTION_INIT, \ TPM_PCR_SELECTION_INIT } +static inline void free_TPM_PCR_INFO_LONG(TPM_PCR_INFO_LONG* p) { free_TPM_PCR_SELECTION(&p->creationPCRSelection); free_TPM_PCR_SELECTION(&p->releasePCRSelection); @@ -607,6 +615,7 @@ typedef struct TPM_PCR_INFO { #define TPM_PCR_INFO_INIT { TPM_PCR_SELECTION_INIT } +static inline void free_TPM_PCR_INFO(TPM_PCR_INFO* p) { free_TPM_PCR_SELECTION(&p->pcrSelection); } @@ -619,6 +628,7 @@ typedef struct TPM_PCR_COMPOSITE { #define TPM_PCR_COMPOSITE_INIT { TPM_PCR_SELECTION_INIT, 0, NULL } +static inline void free_TPM_PCR_COMPOSITE(TPM_PCR_COMPOSITE* p) { free_TPM_PCR_SELECTION(&p->select); free(p->pcrValue); @@ -643,6 +653,7 @@ typedef struct TPM_KEY { .pubKey = TPM_STORE_PUBKEY_INIT, \ .encDataSize = 0, .encData = NULL } +static inline void free_TPM_KEY(TPM_KEY* k) { if(k->PCRInfoSize) { free_TPM_PCR_INFO(&k->PCRInfo); @@ -660,6 +671,7 @@ typedef struct TPM_BOUND_DATA { #define TPM_BOUND_DATA_INIT { .payloadData = NULL } +static inline void free_TPM_BOUND_DATA(TPM_BOUND_DATA* d) { free(d->payloadData); d->payloadData = NULL; @@ -676,6 +688,7 @@ typedef struct TPM_STORED_DATA { #define TPM_STORED_DATA_INIT { .sealInfoSize = 0, sealInfo = TPM_PCR_INFO_INIT,\ .encDataSize = 0, .encData = NULL } +static inline void free_TPM_STORED_DATA(TPM_STORED_DATA* d) { if(d->sealInfoSize) { free_TPM_PCR_INFO(&d->sealInfo); @@ -696,6 +709,7 @@ typedef struct TPM_STORED_DATA12 { #define TPM_STORED_DATA12_INIT { .sealInfoLongSize = 0, \ sealInfoLong = TPM_PCR_INFO_INIT, .encDataSize = 0, .encData = NULL } +static inline void free_TPM_STORED_DATA12(TPM_STORED_DATA12* d) { if(d->sealInfoLongSize) { free_TPM_PCR_INFO_LONG(&d->sealInfoLong); diff --git a/stubdom/vtpmmgr/tpm2_marshal.h b/stubdom/vtpmmgr/tpm2_marshal.h index aaa44645a2..ba070ad38e 100644 --- a/stubdom/vtpmmgr/tpm2_marshal.h +++ b/stubdom/vtpmmgr/tpm2_marshal.h @@ -52,6 +52,7 @@ #define pack_TPM_BUFFER(ptr, buf, size) pack_BUFFER(ptr, buf, size) #define unpack_TPM_BUFFER(ptr, buf, size) unpack_BUFFER(ptr, buf, size) +static inline BYTE* pack_BYTE_ARRAY(BYTE* ptr, const BYTE* array, UINT32 size) { int i; @@ -60,21 +61,25 @@ inline BYTE* pack_BYTE_ARRAY(BYTE* ptr, const BYTE* array, UINT32 size) return ptr; } +static inline BYTE* pack_TPMA_SESSION(BYTE* ptr, const TPMA_SESSION *attr) { return pack_BYTE(ptr, (BYTE)(*attr)); } +static inline BYTE* unpack_TPMA_SESSION(BYTE* ptr, TPMA_SESSION *attr) { return unpack_BYTE(ptr, (BYTE *)attr); } +static inline BYTE* pack_TPMI_ALG_HASH(BYTE* ptr, const TPMI_ALG_HASH *hash) { return pack_UINT16(ptr, *hash); } +static inline BYTE* unpack_TPMI_ALG_HASH(BYTE *ptr, TPMI_ALG_HASH *hash) { return unpack_UINT16(ptr, hash); @@ -125,6 +130,7 @@ inline BYTE* unpack_TPMI_ALG_HASH(BYTE *ptr, TPMI_ALG_HASH *hash) #define pack_TPMI_RH_LOCKOUT(ptr, l) pack_TPM2_HANDLE(ptr, l) #define unpack_TPMI_RH_LOCKOUT(ptr, l) unpack_TPM2_HANDLE(ptr, l) +static inline BYTE* pack_TPM2B_DIGEST(BYTE* ptr, const TPM2B_DIGEST *digest) { ptr = pack_UINT16(ptr, digest->size); @@ -132,6 +138,7 @@ inline BYTE* pack_TPM2B_DIGEST(BYTE* ptr, const TPM2B_DIGEST *digest) return ptr; } +static inline BYTE* unpack_TPM2B_DIGEST(BYTE* ptr, TPM2B_DIGEST *digest) { ptr = unpack_UINT16(ptr, &digest->size); @@ -139,6 +146,7 @@ inline BYTE* unpack_TPM2B_DIGEST(BYTE* ptr, TPM2B_DIGEST *digest) return ptr; } +static inline BYTE* pack_TPMT_TK_CREATION(BYTE* ptr,const TPMT_TK_CREATION *ticket ) { ptr = pack_TPM_ST(ptr , &ticket->tag); @@ -147,6 +155,7 @@ inline BYTE* pack_TPMT_TK_CREATION(BYTE* ptr,const TPMT_TK_CREATION *ticket ) return ptr; } +static inline BYTE* unpack_TPMT_TK_CREATION(BYTE* ptr, TPMT_TK_CREATION *ticket ) { ptr = unpack_TPM_ST(ptr, &ticket->tag); @@ -155,6 +164,7 @@ inline BYTE* unpack_TPMT_TK_CREATION(BYTE* ptr, TPMT_TK_CREATION *ticket ) return ptr; } +static inline BYTE* pack_TPM2B_NAME(BYTE* ptr,const TPM2B_NAME *name ) { ptr = pack_UINT16(ptr, name->size); @@ -162,6 +172,7 @@ inline BYTE* pack_TPM2B_NAME(BYTE* ptr,const TPM2B_NAME *name ) return ptr; } +static inline BYTE* unpack_TPM2B_NAME(BYTE* ptr, TPM2B_NAME *name) { ptr = unpack_UINT16(ptr, &name->size); @@ -169,6 +180,7 @@ inline BYTE* unpack_TPM2B_NAME(BYTE* ptr, TPM2B_NAME *name) return ptr; } +static inline BYTE* pack_TPM2B_NONCE(BYTE* ptr, const TPM2B_NONCE *nonce) { return pack_TPM2B_DIGEST(ptr, (const TPM2B_DIGEST*)nonce); @@ -176,6 +188,7 @@ inline BYTE* pack_TPM2B_NONCE(BYTE* ptr, const TPM2B_NONCE *nonce) #define unpack_TPM2B_NONCE(ptr, nonce) unpack_TPM2B_DIGEST(ptr, (TPM2B_DIGEST*)nonce) +static inline BYTE* pack_TPM2B_AUTH(BYTE* ptr, const TPM2B_AUTH *auth) { return pack_TPM2B_DIGEST(ptr, (const TPM2B_DIGEST*)auth); @@ -183,6 +196,7 @@ inline BYTE* pack_TPM2B_AUTH(BYTE* ptr, const TPM2B_AUTH *auth) #define unpack_TPM2B_AUTH(ptr, auth) unpack_TPM2B_DIGEST(ptr, (TPM2B_DIGEST*)auth) +static inline BYTE* pack_TPM2B_DATA(BYTE* ptr, const TPM2B_DATA *data) { return pack_TPM2B_DIGEST(ptr, (const TPM2B_DIGEST*)data); @@ -190,6 +204,7 @@ inline BYTE* pack_TPM2B_DATA(BYTE* ptr, const TPM2B_DATA *data) #define unpack_TPM2B_DATA(ptr, data) unpack_TPM2B_DIGEST(ptr, (TPM2B_DIGEST*)data) +static inline BYTE* pack_TPM2B_SENSITIVE_DATA(BYTE* ptr, const TPM2B_SENSITIVE_DATA *data) { return pack_TPM2B_DIGEST(ptr, (const TPM2B_DIGEST*)data); @@ -197,6 +212,7 @@ inline BYTE* pack_TPM2B_SENSITIVE_DATA(BYTE* ptr, const TPM2B_SENSITIVE_DATA *da #define unpack_TPM2B_SENSITIVE_DATA(ptr, data) unpack_TPM2B_DIGEST(ptr, (TPM2B_DIGEST*)data) +static inline BYTE* pack_TPM2B_PUBLIC_KEY_RSA(BYTE* ptr, const TPM2B_PUBLIC_KEY_RSA *rsa) { return pack_TPM2B_DIGEST(ptr, (const TPM2B_DIGEST*)rsa); @@ -204,6 +220,7 @@ inline BYTE* pack_TPM2B_PUBLIC_KEY_RSA(BYTE* ptr, const TPM2B_PUBLIC_KEY_RSA *rs #define unpack_TPM2B_PUBLIC_KEY_RSA(ptr, rsa) unpack_TPM2B_DIGEST(ptr, (TPM2B_DIGEST*)rsa) +static inline BYTE* pack_TPM2B_PRIVATE(BYTE* ptr, const TPM2B_PRIVATE *Private) { ptr = pack_UINT16(ptr, Private->size); @@ -211,6 +228,7 @@ inline BYTE* pack_TPM2B_PRIVATE(BYTE* ptr, const TPM2B_PRIVATE *Private) return ptr; } +static inline BYTE* unpack_TPM2B_PRIVATE(BYTE* ptr, TPM2B_PRIVATE *Private) { ptr = unpack_UINT16(ptr, &Private->size); @@ -218,6 +236,7 @@ inline BYTE* unpack_TPM2B_PRIVATE(BYTE* ptr, TPM2B_PRIVATE *Private) return ptr; } +static inline BYTE* pack_TPMS_PCR_SELECTION_ARRAY(BYTE* ptr, const TPMS_PCR_SELECTION *sel, UINT32 count) { int i; @@ -229,6 +248,7 @@ inline BYTE* pack_TPMS_PCR_SELECTION_ARRAY(BYTE* ptr, const TPMS_PCR_SELECTION * return ptr; } +static inline BYTE* unpack_TPMS_PCR_SELECTION_ARRAY(BYTE* ptr, TPMS_PCR_SELECTION *sel, UINT32 count) { int i; @@ -240,6 +260,7 @@ inline BYTE* unpack_TPMS_PCR_SELECTION_ARRAY(BYTE* ptr, TPMS_PCR_SELECTION *sel, return ptr; } +static inline BYTE* pack_TPML_PCR_SELECTION(BYTE* ptr, const TPML_PCR_SELECTION *sel) { ptr = pack_UINT32(ptr, sel->count); @@ -247,6 +268,7 @@ inline BYTE* pack_TPML_PCR_SELECTION(BYTE* ptr, const TPML_PCR_SELECTION *sel) return ptr; } +static inline BYTE* unpack_TPML_PCR_SELECTION(BYTE* ptr, TPML_PCR_SELECTION *sel) { ptr = unpack_UINT32(ptr, &sel->count); @@ -254,6 +276,7 @@ inline BYTE* unpack_TPML_PCR_SELECTION(BYTE* ptr, TPML_PCR_SELECTION *sel) return ptr; } +static inline BYTE* unpack_TPML_DIGEST(BYTE* ptr,TPML_DIGEST *digest) { int i; @@ -265,6 +288,7 @@ inline BYTE* unpack_TPML_DIGEST(BYTE* ptr,TPML_DIGEST *digest) return ptr; } +static inline BYTE* pack_TPMS_CREATION_DATA(BYTE* ptr,const TPMS_CREATION_DATA *data) { ptr = pack_TPML_PCR_SELECTION(ptr, &data->pcrSelect); @@ -276,6 +300,7 @@ inline BYTE* pack_TPMS_CREATION_DATA(BYTE* ptr,const TPMS_CREATION_DATA *data) return ptr; } +static inline BYTE* unpack_TPMS_CREATION_DATA(BYTE* ptr, TPMS_CREATION_DATA *data) { ptr = unpack_TPML_PCR_SELECTION(ptr, &data->pcrSelect); @@ -288,6 +313,7 @@ inline BYTE* unpack_TPMS_CREATION_DATA(BYTE* ptr, TPMS_CREATION_DATA *data) return ptr; } +static inline BYTE* pack_TPM2B_CREATION_DATA(BYTE* ptr, const TPM2B_CREATION_DATA *data ) { ptr = pack_UINT16(ptr, data->size); @@ -295,6 +321,7 @@ inline BYTE* pack_TPM2B_CREATION_DATA(BYTE* ptr, const TPM2B_CREATION_DATA *data return ptr; } +static inline BYTE* unpack_TPM2B_CREATION_DATA(BYTE* ptr, TPM2B_CREATION_DATA * data) { ptr = unpack_UINT16(ptr, &data->size); @@ -302,6 +329,7 @@ inline BYTE* unpack_TPM2B_CREATION_DATA(BYTE* ptr, TPM2B_CREATION_DATA * data) return ptr; } +static inline BYTE* pack_TPMS_SENSITIVE_CREATE(BYTE* ptr, const TPMS_SENSITIVE_CREATE *create) { ptr = pack_TPM2B_AUTH(ptr, &create->userAuth); @@ -309,6 +337,7 @@ inline BYTE* pack_TPMS_SENSITIVE_CREATE(BYTE* ptr, const TPMS_SENSITIVE_CREATE * return ptr; } +static inline BYTE* pack_TPM2B_SENSITIVE_CREATE(BYTE* ptr, const TPM2B_SENSITIVE_CREATE *create) { BYTE* sizePtr = ptr; @@ -318,6 +347,7 @@ inline BYTE* pack_TPM2B_SENSITIVE_CREATE(BYTE* ptr, const TPM2B_SENSITIVE_CREATE return ptr; } +static inline BYTE* pack_TPMU_SYM_MODE(BYTE* ptr, const TPMU_SYM_MODE *p, const TPMI_ALG_SYM_OBJECT *sel) { @@ -336,6 +366,7 @@ inline BYTE* pack_TPMU_SYM_MODE(BYTE* ptr, const TPMU_SYM_MODE *p, } return ptr; } +static inline BYTE* unpack_TPMU_SYM_MODE(BYTE* ptr, TPMU_SYM_MODE *p, const TPMI_ALG_SYM_OBJECT *sel) { @@ -355,6 +386,7 @@ inline BYTE* unpack_TPMU_SYM_MODE(BYTE* ptr, TPMU_SYM_MODE *p, return ptr; } +static inline BYTE* pack_TPMU_SYM_KEY_BITS(BYTE* ptr, const TPMU_SYM_KEY_BITS *p, const TPMI_ALG_SYM_OBJECT *sel) { @@ -376,6 +408,7 @@ inline BYTE* pack_TPMU_SYM_KEY_BITS(BYTE* ptr, const TPMU_SYM_KEY_BITS *p, return ptr; } +static inline BYTE* unpack_TPMU_SYM_KEY_BITS(BYTE* ptr, TPMU_SYM_KEY_BITS *p, const TPMI_ALG_SYM_OBJECT *sel) { @@ -397,6 +430,7 @@ inline BYTE* unpack_TPMU_SYM_KEY_BITS(BYTE* ptr, TPMU_SYM_KEY_BITS *p, return ptr; } +static inline BYTE* pack_TPMT_SYM_DEF_OBJECT(BYTE* ptr, const TPMT_SYM_DEF_OBJECT *p) { ptr = pack_TPMI_ALG_SYM_OBJECT(ptr, &p->algorithm); @@ -405,6 +439,7 @@ inline BYTE* pack_TPMT_SYM_DEF_OBJECT(BYTE* ptr, const TPMT_SYM_DEF_OBJECT *p) return ptr; } +static inline BYTE* unpack_TPMT_SYM_DEF_OBJECT(BYTE *ptr, TPMT_SYM_DEF_OBJECT *p) { ptr = unpack_TPMI_ALG_SYM_OBJECT(ptr, &p->algorithm); @@ -416,6 +451,7 @@ inline BYTE* unpack_TPMT_SYM_DEF_OBJECT(BYTE *ptr, TPMT_SYM_DEF_OBJECT *p) #define pack_TPMS_SCHEME_OAEP(p, t) pack_TPMI_ALG_HASH(p, &((t)->hashAlg)) #define unpack_TPMS_SCHEME_OAEP(p, t) unpack_TPMI_ALG_HASH(p, &((t)->hashAlg)) +static inline BYTE* pack_TPMU_ASYM_SCHEME(BYTE *ptr, const TPMU_ASYM_SCHEME *p, const TPMI_ALG_RSA_SCHEME *s) { @@ -438,6 +474,7 @@ inline BYTE* pack_TPMU_ASYM_SCHEME(BYTE *ptr, const TPMU_ASYM_SCHEME *p, return ptr; } +static inline BYTE* unpack_TPMU_ASYM_SCHEME(BYTE *ptr, TPMU_ASYM_SCHEME *p, const TPMI_ALG_RSA_SCHEME *s) { @@ -462,6 +499,7 @@ inline BYTE* unpack_TPMU_ASYM_SCHEME(BYTE *ptr, TPMU_ASYM_SCHEME *p, return ptr; } +static inline BYTE* pack_TPMT_RSA_SCHEME(BYTE* ptr, const TPMT_RSA_SCHEME *p) { ptr = pack_TPMI_ALG_RSA_SCHEME(ptr, &p->scheme); @@ -469,6 +507,7 @@ inline BYTE* pack_TPMT_RSA_SCHEME(BYTE* ptr, const TPMT_RSA_SCHEME *p) return ptr; } +static inline BYTE* unpack_TPMT_RSA_SCHEME(BYTE* ptr, TPMT_RSA_SCHEME *p) { ptr = unpack_TPMI_ALG_RSA_SCHEME(ptr, &p->scheme); @@ -476,6 +515,7 @@ inline BYTE* unpack_TPMT_RSA_SCHEME(BYTE* ptr, TPMT_RSA_SCHEME *p) return ptr; } +static inline BYTE* pack_TPMT_RSA_DECRYPT(BYTE* ptr, const TPMT_RSA_DECRYPT *p) { ptr = pack_TPMI_ALG_RSA_SCHEME(ptr, &p->scheme); @@ -483,6 +523,7 @@ inline BYTE* pack_TPMT_RSA_DECRYPT(BYTE* ptr, const TPMT_RSA_DECRYPT *p) return ptr; } +static inline BYTE* pack_TPMS_RSA_PARMS(BYTE* ptr, const TPMS_RSA_PARMS *p) { ptr = pack_TPMT_SYM_DEF_OBJECT(ptr, &p->symmetric); @@ -492,6 +533,7 @@ inline BYTE* pack_TPMS_RSA_PARMS(BYTE* ptr, const TPMS_RSA_PARMS *p) return ptr; } +static inline BYTE* unpack_TPMS_RSA_PARMS(BYTE *ptr, TPMS_RSA_PARMS *p) { ptr = unpack_TPMT_SYM_DEF_OBJECT(ptr, &p->symmetric); @@ -501,6 +543,7 @@ inline BYTE* unpack_TPMS_RSA_PARMS(BYTE *ptr, TPMS_RSA_PARMS *p) return ptr; } +static inline BYTE* pack_TPMU_PUBLIC_PARMS(BYTE* ptr, const TPMU_PUBLIC_PARMS *param, const TPMI_ALG_PUBLIC *selector) { @@ -518,6 +561,7 @@ inline BYTE* pack_TPMU_PUBLIC_PARMS(BYTE* ptr, const TPMU_PUBLIC_PARMS *param, return NULL; } +static inline BYTE* unpack_TPMU_PUBLIC_PARMS(BYTE* ptr, TPMU_PUBLIC_PARMS *param, const TPMI_ALG_PUBLIC *selector) { @@ -535,18 +579,21 @@ inline BYTE* unpack_TPMU_PUBLIC_PARMS(BYTE* ptr, TPMU_PUBLIC_PARMS *param, return NULL; } +static inline BYTE* pack_TPMS_ECC_POINT(BYTE* ptr, const TPMS_ECC_POINT *point) { assert(false); return ptr; } +static inline BYTE* unpack_TPMS_ECC_POINT(BYTE* ptr, TPMS_ECC_POINT *point) { assert(false); return ptr; } +static inline BYTE* pack_TPMU_PUBLIC_ID(BYTE* ptr, const TPMU_PUBLIC_ID *id, const TPMI_ALG_PUBLIC *selector) { @@ -564,6 +611,7 @@ inline BYTE* pack_TPMU_PUBLIC_ID(BYTE* ptr, const TPMU_PUBLIC_ID *id, return NULL; } +static inline BYTE* unpack_TPMU_PUBLIC_ID(BYTE* ptr, TPMU_PUBLIC_ID *id, TPMI_ALG_PUBLIC *selector) { switch (*selector) { @@ -580,6 +628,7 @@ inline BYTE* unpack_TPMU_PUBLIC_ID(BYTE* ptr, TPMU_PUBLIC_ID *id, TPMI_ALG_PUBLI return NULL; } +static inline BYTE* pack_TPMT_PUBLIC(BYTE* ptr, const TPMT_PUBLIC *public) { ptr = pack_TPMI_ALG_PUBLIC(ptr, &public->type); @@ -591,6 +640,7 @@ inline BYTE* pack_TPMT_PUBLIC(BYTE* ptr, const TPMT_PUBLIC *public) return ptr; } +static inline BYTE* unpack_TPMT_PUBLIC(BYTE* ptr, TPMT_PUBLIC *public) { ptr = unpack_TPMI_ALG_PUBLIC(ptr, &public->type); @@ -602,6 +652,7 @@ inline BYTE* unpack_TPMT_PUBLIC(BYTE* ptr, TPMT_PUBLIC *public) return ptr; } +static inline BYTE* pack_TPM2B_PUBLIC(BYTE* ptr, const TPM2B_PUBLIC *public) { BYTE *sizePtr = ptr; @@ -611,6 +662,7 @@ inline BYTE* pack_TPM2B_PUBLIC(BYTE* ptr, const TPM2B_PUBLIC *public) return ptr; } +static inline BYTE* unpack_TPM2B_PUBLIC(BYTE* ptr, TPM2B_PUBLIC *public) { ptr = unpack_UINT16(ptr, &public->size); @@ -618,6 +670,7 @@ inline BYTE* unpack_TPM2B_PUBLIC(BYTE* ptr, TPM2B_PUBLIC *public) return ptr; } +static inline BYTE* pack_TPMS_PCR_SELECTION(BYTE* ptr, const TPMS_PCR_SELECTION *selection) { ptr = pack_TPMI_ALG_HASH(ptr, &selection->hash); @@ -626,6 +679,7 @@ inline BYTE* pack_TPMS_PCR_SELECTION(BYTE* ptr, const TPMS_PCR_SELECTION *select return ptr; } +static inline BYTE* pack_TPMS_PCR_SELECTION_Array(BYTE* ptr, const TPMS_PCR_SELECTION *selections, const UINT32 cnt) { @@ -635,6 +689,7 @@ inline BYTE* pack_TPMS_PCR_SELECTION_Array(BYTE* ptr, const TPMS_PCR_SELECTION * return ptr; } +static inline BYTE* pack_TPM_AuthArea(BYTE* ptr, const TPM_AuthArea *auth) { BYTE* sizePtr = ptr; @@ -647,6 +702,7 @@ inline BYTE* pack_TPM_AuthArea(BYTE* ptr, const TPM_AuthArea *auth) return ptr; } +static inline BYTE* unpack_TPM_AuthArea(BYTE* ptr, TPM_AuthArea *auth) { ptr = unpack_UINT32(ptr, &auth->size); @@ -657,6 +713,7 @@ inline BYTE* unpack_TPM_AuthArea(BYTE* ptr, TPM_AuthArea *auth) return ptr; } +static inline BYTE* pack_TPM2_RSA_KEY(BYTE* ptr, const TPM2_RSA_KEY *key) { ptr = pack_TPM2B_PRIVATE(ptr, &key->Private); @@ -664,6 +721,7 @@ inline BYTE* pack_TPM2_RSA_KEY(BYTE* ptr, const TPM2_RSA_KEY *key) return ptr; } +static inline BYTE* unpack_TPM2_RSA_KEY(BYTE* ptr, TPM2_RSA_KEY *key) { ptr = unpack_TPM2B_PRIVATE(ptr, &key->Private); diff --git a/stubdom/vtpmmgr/tpmrsa.h b/stubdom/vtpmmgr/tpmrsa.h index 08213bbb7a..65fd32a45c 100644 --- a/stubdom/vtpmmgr/tpmrsa.h +++ b/stubdom/vtpmmgr/tpmrsa.h @@ -62,6 +62,7 @@ TPM_RESULT tpmrsa_pub_encrypt_oaep( tpmrsa_context *ctx, unsigned char *output ); /* free tpmrsa key */ +static inline void tpmrsa_free( tpmrsa_context *ctx ) { mpi_free( &ctx->RN ); mpi_free( &ctx->E ); mpi_free( &ctx->N ); } _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |