1 // 2 // Runtime.h 3 // CoreEntitlements 4 // 5 // 6 7 #pragma once 8 9 #ifndef _CE_INDIRECT 10 #error "Please include <CoreEntitlements/CoreEntitlements.h> instead of this file" 11 #endif 12 13 #include <stdint.h> 14 #include <stddef.h> 15 #include "stdbool.h" 16 #define MAX_KEY_SIZE 240 17 #define CE_MAX_KEY_SIZE 240 18 19 #ifndef __result_use_check 20 #define __result_use_check; 21 #endif 22 23 #define CE_RUNTIME_VERSION 1 24 25 /*! 26 * @struct CEBuffer 27 * Represents a sized chunk of DER data 28 * Strings and blobs used and returned by CoreEntitlements always use CEBuffer 29 * 30 * @note 31 * If a DER string is returned to you via a CEBuffer, you cannot assume it is null-terminated. 32 */ 33 typedef struct { 34 const uint8_t* data; 35 size_t length; 36 } CEBuffer; 37 38 /*! 39 * @struct CEStaticBuffer 40 * Represents a sized chunk of data that is stored inline 41 */ 42 typedef struct { 43 uint8_t data[CE_MAX_KEY_SIZE]; 44 size_t length; 45 } CEStaticBuffer; 46 47 48 /*! 49 * @typedef CERuntimeMalloc 50 * Function prototype that the CERuntime may ues to allocate data (e.g.. malloc) 51 */ 52 typedef void* (*CERuntimeMalloc)(const CERuntime_t rt, size_t size) __result_use_check; 53 /*! 54 * @typedef CERuntimeFree 55 * Function prototype that the CERuntime may ues to free allocated data (e.g. free) 56 */ 57 typedef void (*CERuntimeFree)(const CERuntime_t rt, void* address); 58 /*! 59 * @typedef CERuntimeLog 60 * Function prototype that the CERuntime may use to log helpful information (e.g. printf) 61 */ 62 typedef void (*CERuntimeLog)(const CERuntime_t rt, const char* fmt, ...) __printflike(2, 3); 63 /*! 64 * @typedef CERuntimeAbort 65 * Function prototype that the CERuntime will use if it encounters a condition which may compromise the integrity of the system (e.g. abort, panic) 66 */ 67 typedef void (*CERuntimeAbort)(const CERuntime_t rt, const char* fmt, ...) __printflike(2, 3) __attribute__((noreturn)); 68 /*! 69 * @typedef CERuntimeInternalStatus 70 * Function prototype that the CERuntime may use to query AppleInternal status 71 */ 72 typedef bool (*CERuntimeInternalStatus)(const CERuntime_t rt); 73 74 /*! 75 * @struct CERuntime 76 * This structure represents the interface that CoreEntitlements uses to communicate with the outside world. 77 * The presense or absence of function pointers in this structure may degrade certain functionality. 78 * 79 * @note 80 * The only prototype that MUST be implemented is CERuntimeAbort abort. 81 */ 82 struct CERuntime { 83 const uint64_t version; 84 const CERuntimeMalloc alloc; 85 const CERuntimeFree free; 86 const CERuntimeLog log; 87 const CERuntimeAbort abort; 88 const CERuntimeInternalStatus internalStatus; 89 } ; 90