]> git.saurik.com Git - apple/dyld.git/blob - dyld3/CodeSigningTypes.h
dyld-832.7.1.tar.gz
[apple/dyld.git] / dyld3 / CodeSigningTypes.h
1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 *
3 * Copyright (c) 2015 Apple Inc. All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25 #ifndef _CODE_SIGNING_TYPES_
26 #define _CODE_SIGNING_TYPES_
27
28 #include <stdint.h>
29 #include <stddef.h>
30
31
32 //
33 // Magic numbers used by Code Signing
34 //
35 enum {
36 CSMAGIC_REQUIREMENT = 0xfade0c00, // single Requirement blob
37 CSMAGIC_REQUIREMENTS = 0xfade0c01, // Requirements vector (internal requirements)
38 CSMAGIC_CODEDIRECTORY = 0xfade0c02, // CodeDirectory blob
39 CSMAGIC_EMBEDDED_SIGNATURE = 0xfade0cc0, // embedded form of signature data
40 CSMAGIC_DETACHED_SIGNATURE = 0xfade0cc1, // multi-arch collection of embedded signatures
41 CSMAGIC_BLOBWRAPPER = 0xfade0b01, // used for the cms blob
42 };
43
44 enum {
45 CS_PAGE_SIZE_4K = 4096,
46 CS_PAGE_SIZE_16K = 16384,
47
48 CS_HASHTYPE_SHA1 = 1,
49 CS_HASHTYPE_SHA256 = 2,
50 CS_HASHTYPE_SHA256_TRUNCATED = 3,
51 CS_HASHTYPE_SHA384 = 4,
52
53 CS_HASH_SIZE_SHA1 = 20,
54 CS_HASH_SIZE_SHA256 = 32,
55 CS_HASH_SIZE_SHA256_TRUNCATED = 20,
56
57 CSSLOT_CODEDIRECTORY = 0,
58 CSSLOT_INFOSLOT = 1,
59 CSSLOT_REQUIREMENTS = 2,
60 CSSLOT_RESOURCEDIR = 3,
61 CSSLOT_APPLICATION = 4,
62 CSSLOT_ENTITLEMENTS = 5,
63 CSSLOT_ALTERNATE_CODEDIRECTORIES = 0x1000,
64 CSSLOT_ALTERNATE_CODEDIRECTORY_MAX = 5,
65 CSSLOT_ALTERNATE_CODEDIRECTORY_LIMIT =
66 CSSLOT_ALTERNATE_CODEDIRECTORIES + CSSLOT_ALTERNATE_CODEDIRECTORY_MAX,
67 CSSLOT_CMS_SIGNATURE = 0x10000,
68
69 kSecCodeSignatureAdhoc = 2
70 };
71
72 enum {
73 CS_REQUIRE_LV = 0x0002000 // require library validation
74 };
75
76 //
77 // Structure of a SuperBlob
78 //
79 struct CS_BlobIndex {
80 uint32_t type; // type of entry
81 uint32_t offset; // offset of entry
82 };
83
84 struct CS_SuperBlob {
85 uint32_t magic; // magic number
86 uint32_t length; // total length of SuperBlob
87 uint32_t count; // number of index entries following
88 CS_BlobIndex index[]; // (count) entries
89 // followed by Blobs in no particular order as indicated by offsets in index
90 };
91
92 //
93 // C form of a CodeDirectory.
94 //
95 struct CS_CodeDirectory {
96 uint32_t magic; // magic number (CSMAGIC_CODEDIRECTORY) */
97 uint32_t length; // total length of CodeDirectory blob
98 uint32_t version; // compatibility version
99 uint32_t flags; // setup and mode flags
100 uint32_t hashOffset; // offset of hash slot element at index zero
101 uint32_t identOffset; // offset of identifier string
102 uint32_t nSpecialSlots; // number of special hash slots
103 uint32_t nCodeSlots; // number of ordinary (code) hash slots
104 uint32_t codeLimit; // limit to main image signature range
105 uint8_t hashSize; // size of each hash in bytes
106 uint8_t hashType; // type of hash (cdHashType* constants)
107 uint8_t platform; // platform identifier; zero if not platform binary
108 uint8_t pageSize; // log2(page size in bytes); 0 => infinite
109 uint32_t spare2; // unused (must be zero)
110
111 char end_earliest[0];
112
113 /* Version 0x20100 */
114 uint32_t scatterOffset; /* offset of optional scatter vector */
115 char end_withScatter[0];
116
117 /* Version 0x20200 */
118 uint32_t teamOffset; /* offset of optional team identifier */
119 char end_withTeam[0];
120
121 /* Version 0x20300 */
122 uint32_t spare3; /* unused (must be zero) */
123 uint64_t codeLimit64; /* limit to main image signature range, 64 bits */
124 char end_withCodeLimit64[0];
125
126 /* Version 0x20400 */
127 uint64_t execSegBase; /* offset of executable segment */
128 uint64_t execSegLimit; /* limit of executable segment */
129 uint64_t execSegFlags; /* exec segment flags */
130 char end_withExecSeg[0];
131
132 /* followed by dynamic content as located by offset fields above */
133 };
134
135 struct CS_Blob {
136 uint32_t magic; // magic number
137 uint32_t length; // total length of blob
138 };
139
140 struct CS_RequirementsBlob {
141 uint32_t magic; // magic number
142 uint32_t length; // total length of blob
143 uint32_t data; // zero for dyld shared cache
144 };
145
146
147 struct CS_Scatter {
148 uint32_t count; // number of pages; zero for sentinel (only)
149 uint32_t base; // first page number
150 uint64_t targetOffset; // byte offset in target
151 uint64_t spare; // reserved (must be zero)
152 };
153
154
155 #endif // _CODE_SIGNING_TYPES_
156
157
158