#include <kern/cs_blobs.h>
kern/cs_blobs.h
macroCS_FORCED_LV
#define CS_FORCED_LV 0x00000010
Library Validation required by Hardened System Policy
macroCS_INVALID_ALLOWED
#define CS_INVALID_ALLOWED 0x00000020
(macOS Only) Page invalidation allowed by task port policy
macroCS_ENTITLEMENTS_VALIDATED
#define CS_ENTITLEMENTS_VALIDATED 0x00004000
code signature permits restricted entitlements
macroCS_NVRAM_UNRESTRICTED
#define CS_NVRAM_UNRESTRICTED 0x00008000
has com.apple.rootless.restricted-nvram-variables.heritable entitlement
macroCS_ALLOWED_MACHO
#define CS_ALLOWED_MACHO (CS_ADHOC | CS_HARD | CS_KILL | CS_CHECK_EXPIRATION | CS_RESTRICT | CS_ENFORCEMENT | CS_REQUIRE_LV | CS_RUNTIME | CS_LINKER_SIGNED)
macroCS_EXEC_SET_ENFORCEMENT
#define CS_EXEC_SET_ENFORCEMENT 0x00400000
set CS_ENFORCEMENT on any exec'ed process
macroCS_EXEC_INHERIT_SIP
#define CS_EXEC_INHERIT_SIP 0x00800000
set CS_INSTALLER on any exec'ed process
macroCS_NO_UNTRUSTED_HELPERS
#define CS_NO_UNTRUSTED_HELPERS 0x02000000
kernel did not load a non-platform-binary dyld or Rosetta runtime
macroCS_PLATFORM_PATH
#define CS_PLATFORM_PATH 0x08000000
platform binary by the fact of path (osx only)
macroCS_DEBUGGED
#define CS_DEBUGGED 0x10000000
process is currently or has previously been debugged and allowed to run with invalid pages
macroCS_DEV_CODE
#define CS_DEV_CODE 0x40000000
code is dev signed, cannot be loaded into prod signed code (will go away with rdar://problem/28322552)
macroCS_DATAVAULT_CONTROLLER
#define CS_DATAVAULT_CONTROLLER 0x80000000
has Data Vault controller entitlement
macroCS_ENTITLEMENT_FLAGS
#define CS_ENTITLEMENT_FLAGS (CS_GET_TASK_ALLOW | CS_INSTALLER | CS_DATAVAULT_CONTROLLER | CS_NVRAM_UNRESTRICTED)
macroCS_EXECSEG_ALLOW_UNSIGNED
#define CS_EXECSEG_ALLOW_UNSIGNED 0x10
allow unsigned pages (for debugging)
macroCS_EXECSEG_CAN_LOAD_CDHASH
#define CS_EXECSEG_CAN_LOAD_CDHASH 0x100
can bless cdhash for execution
enum(anonymous)
Magic numbers used by Code Signing
| CSMAGIC_REQUIREMENT | 4208856064 | single Requirement blob |
| CSMAGIC_REQUIREMENTS | 4208856065 | Requirements vector (internal requirements) |
| CSMAGIC_CODEDIRECTORY | 4208856066 | CodeDirectory blob |
| CSMAGIC_EMBEDDED_SIGNATURE | 4208856256 | embedded form of signature data |
| CSMAGIC_EMBEDDED_SIGNATURE_OLD | 4208855810 | XXX |
| CSMAGIC_EMBEDDED_ENTITLEMENTS | 4208882033 | embedded entitlements |
| CSMAGIC_EMBEDDED_DER_ENTITLEMENTS | 4208882034 | embedded DER encoded entitlements |
| CSMAGIC_DETACHED_SIGNATURE | 4208856257 | multi-arch collection of embedded signatures |
| CSMAGIC_BLOBWRAPPER | 4208855809 | CMS Signature, among other things |
| CSMAGIC_EMBEDDED_LAUNCH_CONSTRAINT | 4208886145 | Light weight code requirement |
| CS_SUPPORTSSCATTER | 131328 | |
| CS_SUPPORTSTEAMID | 131584 | |
| CS_SUPPORTSCODELIMIT64 | 131840 | |
| CS_SUPPORTSEXECSEG | 132096 | |
| CS_SUPPORTSRUNTIME | 132352 | |
| CS_SUPPORTSLINKAGE | 132608 | |
| CSSLOT_CODEDIRECTORY | 0 | slot index for CodeDirectory |
| CSSLOT_INFOSLOT | 1 | |
| CSSLOT_REQUIREMENTS | 2 | |
| CSSLOT_RESOURCEDIR | 3 | |
| CSSLOT_APPLICATION | 4 | |
| CSSLOT_ENTITLEMENTS | 5 | |
| CSSLOT_DER_ENTITLEMENTS | 7 | |
| CSSLOT_LAUNCH_CONSTRAINT_SELF | 8 | |
| CSSLOT_LAUNCH_CONSTRAINT_PARENT | 9 | |
| CSSLOT_LAUNCH_CONSTRAINT_RESPONSIBLE | 10 | |
| CSSLOT_LIBRARY_CONSTRAINT | 11 | |
| CSSLOT_ALTERNATE_CODEDIRECTORIES | 4096 | first alternate CodeDirectory, if any |
| CSSLOT_ALTERNATE_CODEDIRECTORY_MAX | 5 | max number of alternate CD slots |
| CSSLOT_ALTERNATE_CODEDIRECTORY_LIMIT | 4101 | one past the last |
| CSSLOT_SIGNATURESLOT | 65536 | CMS Signature |
| CSSLOT_IDENTIFICATIONSLOT | 65537 | |
| CSSLOT_TICKETSLOT | 65538 | |
| CSTYPE_INDEX_REQUIREMENTS | 2 | compat with amfi |
| CSTYPE_INDEX_ENTITLEMENTS | 5 | compat with amfi |
| CS_HASHTYPE_SHA1 | 1 | |
| CS_HASHTYPE_SHA256 | 2 | |
| CS_HASHTYPE_SHA256_TRUNCATED | 3 | |
| CS_HASHTYPE_SHA384 | 4 | |
| CS_SHA1_LEN | 20 | |
| CS_SHA256_LEN | 32 | |
| CS_SHA256_TRUNCATED_LEN | 20 | |
| CS_CDHASH_LEN | 20 | always - larger hashes are truncated |
| CS_HASH_MAX_SIZE | 48 | max size of the hash we'll support |
| CS_SIGNER_TYPE_UNKNOWN | 0 | Currently only to support Legacy VPN plugins, and Mac App Store but intended to replace all the various platform code, dev code etc. bits. |
| CS_SIGNER_TYPE_LEGACYVPN | 5 | |
| CS_SIGNER_TYPE_MAC_APP_STORE | 6 | |
| CS_SUPPL_SIGNER_TYPE_UNKNOWN | 0 | |
| CS_SUPPL_SIGNER_TYPE_TRUSTCACHE | 7 | |
| CS_SUPPL_SIGNER_TYPE_LOCAL | 8 | |
| CS_SIGNER_TYPE_OOPJIT | 9 | |
| CS_VALIDATION_CATEGORY_INVALID | 0 | Validation categories used for trusted launch environment |
| CS_VALIDATION_CATEGORY_PLATFORM | 1 | |
| CS_VALIDATION_CATEGORY_TESTFLIGHT | 2 | |
| CS_VALIDATION_CATEGORY_DEVELOPMENT | 3 | |
| CS_VALIDATION_CATEGORY_APP_STORE | 4 | |
| CS_VALIDATION_CATEGORY_ENTERPRISE | 5 | |
| CS_VALIDATION_CATEGORY_DEVELOPER_ID | 6 | |
| CS_VALIDATION_CATEGORY_LOCAL_SIGNING | 7 | |
| CS_VALIDATION_CATEGORY_ROSETTA | 8 | |
| CS_VALIDATION_CATEGORY_OOPJIT | 9 | |
| CS_VALIDATION_CATEGORY_NONE | 10 |
enum(anonymous)
The set of application types we support for linkage signatures
| CS_LINKAGE_APPLICATION_INVALID | 0 | |
| CS_LINKAGE_APPLICATION_ROSETTA | 1 | |
| CS_LINKAGE_APPLICATION_XOJIT | 2 | XOJIT has been renamed to OOP-JIT |
| CS_LINKAGE_APPLICATION_OOPJIT | 2 |
enum(anonymous)
The set of application sub-types we support for linkage signatures
| CS_LINKAGE_APPLICATION_ROSETTA_AOT | 0 | For backwards compatibility with older signatures, the AOT sub-type is kept as 0. |
| CS_LINKAGE_APPLICATION_XOJIT_PREVIEWS | 1 | OOP-JIT sub-types -- XOJIT type kept for external dependencies |
| CS_LINKAGE_APPLICATION_OOPJIT_INVALID | 0 | |
| CS_LINKAGE_APPLICATION_OOPJIT_PREVIEWS | 1 | |
| CS_LINKAGE_APPLICATION_OOPJIT_MLCOMPILER | 2 | |
| CS_LINKAGE_APPLICATION_OOPJIT_TOTAL | 3 |
variableoop_jit_conversion
Integer to string conversion of OOP-JIT types
static const char *oop_jit_conversion[CS_LINKAGE_APPLICATION_OOPJIT_TOTAL] = { [CS_LINKAGE_APPLICATION_OOPJIT_INVALID] = NULL, [CS_LINKAGE_APPLICATION_OOPJIT_PREVIEWS] = "previews", [CS_LINKAGE_APPLICATION_OOPJIT_MLCOMPILER] = "ml-compiler", }
macroKERNEL_HAVE_CS_CODEDIRECTORY
#define KERNEL_HAVE_CS_CODEDIRECTORY 1
macroKERNEL_CS_CODEDIRECTORY_HAVE_PLATFORM
#define KERNEL_CS_CODEDIRECTORY_HAVE_PLATFORM 1
struct__CodeDirectory
C form of a CodeDirectory.
| uint32_t | magic | magic number (CSMAGIC_CODEDIRECTORY) |
| uint32_t | length | total length of CodeDirectory blob |
| uint32_t | version | compatibility version |
| uint32_t | flags | setup and mode flags |
| uint32_t | hashOffset | offset of hash slot element at index zero |
| uint32_t | identOffset | offset of identifier string |
| uint32_t | nSpecialSlots | number of special hash slots |
| uint32_t | nCodeSlots | number of ordinary (code) hash slots |
| uint32_t | codeLimit | limit to main image signature range |
| uint8_t | hashSize | size of each hash in bytes |
| uint8_t | hashType | type of hash (cdHashType* constants) |
| uint8_t | platform | platform identifier; zero if not platform binary |
| uint8_t | pageSize | log2(page size in bytes); 0 => infinite |
| uint32_t | spare2 | unused (must be zero) |
| char[0] | end_earliest | |
| uint32_t | scatterOffset | Version 0x20100 offset of optional scatter vector |
| char[0] | end_withScatter | |
| uint32_t | teamOffset | Version 0x20200 offset of optional team identifier |
| char[0] | end_withTeam | |
| uint32_t | spare3 | Version 0x20300 unused (must be zero) |
| uint64_t | codeLimit64 | limit to main image signature range, 64 bits |
| char[0] | end_withCodeLimit64 | |
| uint64_t | execSegBase | Version 0x20400 offset of executable segment |
| uint64_t | execSegLimit | limit of executable segment |
| uint64_t | execSegFlags | executable segment flags |
| char[0] | end_withExecSeg | |
| uint32_t | runtime | Version 0x20500 |
| uint32_t | preEncryptOffset | |
| char[0] | end_withPreEncryptOffset | |
| uint8_t | linkageHashType | Version 0x20600 |
| uint8_t | linkageApplicationType | |
| uint16_t | linkageApplicationSubType | |
| uint32_t | linkageOffset | |
| uint32_t | linkageSize | |
| char[0] | end_withLinkage |
typedefCS_CodeDirectory
typedef struct __CodeDirectory CS_CodeDirectory;
struct__BlobIndex
| uint32_t | type | type of entry |
| uint32_t | offset | offset of entry |
typedefCS_BlobIndex
typedef struct __BlobIndex CS_BlobIndex;
struct__SC_SuperBlob
| uint32_t | magic | magic number |
| uint32_t | length | total length of SuperBlob |
| uint32_t | count | number of index entries following |
| CS_BlobIndex[] | index | (count) entries |
typedefCS_SuperBlob
typedef struct __SC_SuperBlob CS_SuperBlob;
macroKERNEL_HAVE_CS_GENERICBLOB
#define KERNEL_HAVE_CS_GENERICBLOB 1
struct__SC_GenericBlob
| uint32_t | magic | magic number |
| uint32_t | length | total length of blob |
| char[] | data |
typedefCS_GenericBlob
typedef struct __SC_GenericBlob CS_GenericBlob;
struct__SC_Scatter
| uint32_t | count | number of pages; zero for sentinel (only) |
| uint32_t | base | first page number |
| uint64_t | targetOffset | offset in target |
| uint64_t | spare | reserved |
typedefSC_Scatter
typedef struct __SC_Scatter SC_Scatter;
enumcs_launch_type_t
Defined launch types
| CS_LAUNCH_TYPE_NONE | 0 | |
| CS_LAUNCH_TYPE_SYSTEM_SERVICE | 1 | |
| CS_LAUNCH_TYPE_SYSDIAGNOSE | 2 | |
| CS_LAUNCH_TYPE_APPLICATION | 3 |
typedefcs_launch_type_t
typedef enum cs_launch_type_t cs_launch_type_t;
structlaunch_constraint_data
| cs_launch_type_t | launch_type |
typedeflaunch_constraint_data_t
typedef struct launch_constraint_data* launch_constraint_data_t
struct_csops_cdhash
Ideally, this definition should live within sys/codesign.h, but adding it there
causes an issue with compiling certain Swift projects due to some ambigious macro
definition error on CD_CDHASH_LEN. Thus, we keep it here.
For more information: rdar://145187726.
| uint8_t[20] | hash | |
| uint8_t | type |
typedefcsops_cdhash_t
typedef struct _csops_cdhash csops_cdhash_t;