1 #ifndef libTrustCache_RawTypes_h 2 #define libTrustCache_RawTypes_h 3 4 #include <sys/cdefs.h> 5 __BEGIN_DECLS 6 7 #include <stdint.h> 8 #include <corecrypto/ccsha1.h> 9 10 /* 11 * CDHashes in the trust cache are always truncated to the length of a SHA1 hash. 12 */ 13 #define kTCEntryHashSize CCSHA1_OUTPUT_SIZE 14 15 /* UUIDs are always 16 bytes */ 16 #define kUUIDSize 16 17 18 /* Versions supported by the library */ 19 enum { 20 kTCVersion0 = 0x0, 21 kTCVersion1 = 0x1, 22 kTCVersion2 = 0x2, 23 24 kTCVersionTotal, 25 }; 26 27 /* Flags for the trust cache look ups */ 28 enum { 29 kTCFlagAMFID = 0x01, 30 kTCFlagANEModel = 0x02, 31 }; 32 33 typedef struct _TrustCacheModuleBase { 34 /* The version for this trust cache module */ 35 uint32_t version; 36 } __attribute__((packed)) TrustCacheModuleBase_t; 37 38 #pragma mark Trust Cache Version 0 39 40 typedef uint8_t TrustCacheEntry0_t[kTCEntryHashSize]; 41 42 typedef struct _TrustCacheModule0 { 43 /* Must be 0 */ 44 uint32_t version; 45 46 /* ID which uniquely identifies the trust cache */ 47 uint8_t uuid[kUUIDSize]; 48 49 /* The number of entries present in the trust cache */ 50 uint32_t numEntries; 51 52 /* Dynamic data containing all the entries */ 53 TrustCacheEntry0_t entries[0]; 54 } __attribute__((packed)) TrustCacheModule0_t; 55 56 #pragma mark Trust Cache Version 1 57 58 typedef struct _TrustCacheEntry1 { 59 uint8_t CDHash[kTCEntryHashSize]; 60 uint8_t hashType; 61 uint8_t flags; 62 } __attribute__((packed)) TrustCacheEntry1_t; 63 64 typedef struct _TrustCacheModule1 { 65 /* Must be 1 */ 66 uint32_t version; 67 68 /* ID which uniquely identifies the trust cache */ 69 uint8_t uuid[kUUIDSize]; 70 71 /* The number of entries present in the trust cache */ 72 uint32_t numEntries; 73 74 /* Dynamic data containing all the entries */ 75 TrustCacheEntry1_t entries[0]; 76 } __attribute__((packed)) TrustCacheModule1_t; 77 78 #pragma mark Trust Cache Version 2 79 80 typedef struct _TrustCacheEntry2 { 81 uint8_t CDHash[kTCEntryHashSize]; 82 uint8_t hashType; 83 uint8_t flags; 84 uint8_t constraintCategory; 85 uint8_t reserved0; 86 } __attribute__((packed)) TrustCacheEntry2_t; 87 88 typedef struct _TrustCacheModule2 { 89 /* Must be 2 */ 90 uint32_t version; 91 92 /* ID which uniquely identifies the trust cache */ 93 uint8_t uuid[kUUIDSize]; 94 95 /* The number of entries present in the trust cache */ 96 uint32_t numEntries; 97 98 /* Dynamic data containing all the entries */ 99 TrustCacheEntry2_t entries[0]; 100 } __attribute__((packed)) TrustCacheModule2_t; 101 102 __END_DECLS 103 #endif /* libTrustCache_RawTypes_h */ 104