1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
3 * Copyright (c) 2015 Apple Inc. All rights reserved.
5 * @APPLE_LICENSE_HEADER_START@
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
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.
22 * @APPLE_LICENSE_HEADER_END@
25 #ifndef _CODE_SIGNING_TYPES_
26 #define _CODE_SIGNING_TYPES_
33 // Magic numbers used by Code Signing
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
48 CS_HASHTYPE_SHA256
= 2,
49 CS_HASHTYPE_SHA256_TRUNCATED
= 3,
51 CS_HASH_SIZE_SHA1
= 20,
52 CS_HASH_SIZE_SHA256
= 32,
53 CS_HASH_SIZE_SHA256_TRUNCATED
= 20,
55 CSSLOT_CODEDIRECTORY
= 0,
57 CSSLOT_REQUIREMENTS
= 2,
58 CSSLOT_RESOURCEDIR
= 3,
59 CSSLOT_APPLICATION
= 4,
60 CSSLOT_ENTITLEMENTS
= 5,
61 CSSLOT_CMS_SIGNATURE
= 0x10000,
63 kSecCodeSignatureAdhoc
= 2
69 // Structure of a SuperBlob
72 uint32_t type
; // type of entry
73 uint32_t offset
; // offset of entry
77 uint32_t magic
; // magic number
78 uint32_t length
; // total length of SuperBlob
79 uint32_t count
; // number of index entries following
80 CS_BlobIndex index
[]; // (count) entries
81 // followed by Blobs in no particular order as indicated by offsets in index
85 // C form of a CodeDirectory.
87 struct CS_CodeDirectory
{
88 uint32_t magic
; // magic number (CSMAGIC_CODEDIRECTORY) */
89 uint32_t length
; // total length of CodeDirectory blob
90 uint32_t version
; // compatibility version
91 uint32_t flags
; // setup and mode flags
92 uint32_t hashOffset
; // offset of hash slot element at index zero
93 uint32_t identOffset
; // offset of identifier string
94 uint32_t nSpecialSlots
; // number of special hash slots
95 uint32_t nCodeSlots
; // number of ordinary (code) hash slots
96 uint32_t codeLimit
; // limit to main image signature range
97 uint8_t hashSize
; // size of each hash in bytes
98 uint8_t hashType
; // type of hash (cdHashType* constants)
99 uint8_t platform
; // platform identifier; zero if not platform binary
100 uint8_t pageSize
; // log2(page size in bytes); 0 => infinite
101 uint32_t spare2
; // unused (must be zero)
102 // Version 0x20100 or later
103 uint32_t scatterOffset
; // offset of optional scatter vector
104 // followed by dynamic content as located by offset fields above
108 uint32_t magic
; // magic number
109 uint32_t length
; // total length of blob
112 struct CS_RequirementsBlob
{
113 uint32_t magic
; // magic number
114 uint32_t length
; // total length of blob
115 uint32_t data
; // zero for dyld shared cache
120 uint32_t count
; // number of pages; zero for sentinel (only)
121 uint32_t base
; // first page number
122 uint64_t targetOffset
; // byte offset in target
123 uint64_t spare
; // reserved (must be zero)
127 #endif // _CODE_SIGNING_TYPES_