| 1 |
|
| 2 |
|
| 3 |
#ifndef TCG_TSS_INTERNAL_H_ |
| 4 |
#define TCG_TSS_INTERNAL_H_ |
| 5 |
|
| 6 |
#include <stdint.h> |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
#define kTpmRequestHeaderLength 10 |
| 13 |
#define kTpmResponseHeaderLength 10 |
| 14 |
#define kTpmReadInfoLength 12 |
| 15 |
#define kEncAuthLength 20 |
| 16 |
#define kPcrDigestLength 20 |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
__attribute__((unused)) |
| 24 |
static inline void to_tpm_uint32(uint8_t *buffer, uint32_t x) |
| 25 |
{ |
| 26 |
buffer[0] = (uint8_t)(x >> 24); |
| 27 |
buffer[1] = (uint8_t)((x >> 16) & 0xff); |
| 28 |
buffer[2] = (uint8_t)((x >> 8) & 0xff); |
| 29 |
buffer[3] = (uint8_t)(x & 0xff); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
__attribute__((unused)) |
| 36 |
static inline void from_tpm_uint32(const uint8_t *buffer, uint32_t *x) |
| 37 |
{ |
| 38 |
*x = ((buffer[0] << 24) | |
| 39 |
(buffer[1] << 16) | |
| 40 |
(buffer[2] << 8) | |
| 41 |
buffer[3]); |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
__attribute__((unused)) |
| 48 |
static inline void to_tpm_uint16(uint8_t *buffer, uint16_t x) |
| 49 |
{ |
| 50 |
buffer[0] = (uint8_t)(x >> 8); |
| 51 |
buffer[1] = (uint8_t)(x & 0xff); |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
__attribute__((unused)) |
| 58 |
static inline void from_tpm_uint16(const uint8_t *buffer, uint16_t *x) |
| 59 |
{ |
| 60 |
*x = (buffer[0] << 8) | buffer[1]; |
| 61 |
} |
| 62 |
|
| 63 |
#endif |