xref: /netbsd-src/external/gpl3/binutils/dist/include/mach-o/codesign.h (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1883529b6Schristos /* Mach-O support for BFD.
2*cb63e24eSchristos    Copyright (C) 2011-2024 Free Software Foundation, Inc.
3883529b6Schristos 
4883529b6Schristos    This file is part of BFD, the Binary File Descriptor library.
5883529b6Schristos 
6883529b6Schristos    This program is free software; you can redistribute it and/or modify
7883529b6Schristos    it under the terms of the GNU General Public License as published by
8883529b6Schristos    the Free Software Foundation; either version 3 of the License, or
9883529b6Schristos    (at your option) any later version.
10883529b6Schristos 
11883529b6Schristos    This program is distributed in the hope that it will be useful,
12883529b6Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
13883529b6Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14883529b6Schristos    GNU General Public License for more details.
15883529b6Schristos 
16883529b6Schristos    You should have received a copy of the GNU General Public License
17883529b6Schristos    along with this program; if not, write to the Free Software
18883529b6Schristos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19883529b6Schristos    MA 02110-1301, USA.  */
20883529b6Schristos 
21883529b6Schristos #ifndef _MACH_O_CODESIGN_H
22883529b6Schristos #define _MACH_O_CODESIGN_H
23883529b6Schristos 
24883529b6Schristos /* Codesign blob magics.  */
25883529b6Schristos 
26883529b6Schristos /* Superblob containing all the components.  */
27883529b6Schristos #define BFD_MACH_O_CS_MAGIC_EMBEDDED_SIGNATURE 0xfade0cc0
28883529b6Schristos 
29883529b6Schristos /* Individual code requirement.  */
30883529b6Schristos #define BFD_MACH_O_CS_MAGIC_REQUIREMENT 0xfade0c00
31883529b6Schristos 
32883529b6Schristos /* Collection of code requirements, indexed by type.  */
33883529b6Schristos #define BFD_MACH_O_CS_MAGIC_REQUIREMENTS 0xfade0c01
34883529b6Schristos 
35883529b6Schristos /* Directory.  */
36883529b6Schristos #define BFD_MACH_O_CS_MAGIC_CODEDIRECTORY 0xfade0c02
37883529b6Schristos 
38883529b6Schristos /* Entitlements blob.  */
39883529b6Schristos #define BFD_MACH_O_CS_MAGIC_EMBEDDED_ENTITLEMENTS 0xfade7171
40883529b6Schristos 
41883529b6Schristos /* Blob container.  */
42883529b6Schristos #define BFD_MACH_O_CS_MAGIC_BLOB_WRAPPER 0xfade0b01
43883529b6Schristos 
44883529b6Schristos struct mach_o_codesign_codedirectory_external_v1
45883529b6Schristos {
46883529b6Schristos   /* All the fields are in network byte order (big endian).  */
47883529b6Schristos   unsigned char version[4];
48883529b6Schristos   unsigned char flags[4];
49883529b6Schristos   unsigned char hash_offset[4];
50883529b6Schristos   unsigned char ident_offset[4];
51883529b6Schristos   unsigned char nbr_special_slots[4];
52883529b6Schristos   unsigned char nbr_code_slots[4];
53883529b6Schristos   unsigned char code_limit[4];
54883529b6Schristos   unsigned char hash_size[1];
55883529b6Schristos   unsigned char hash_type[1];
56883529b6Schristos   unsigned char spare1[1];
57883529b6Schristos   unsigned char page_size[1];
58883529b6Schristos   unsigned char spare2[4];
59883529b6Schristos };
60883529b6Schristos 
61883529b6Schristos struct mach_o_codesign_codedirectory_v1
62883529b6Schristos {
63883529b6Schristos   unsigned int version;
64883529b6Schristos   unsigned int flags;
65883529b6Schristos   unsigned int hash_offset;
66883529b6Schristos   unsigned int ident_offset;
67883529b6Schristos   unsigned int nbr_special_slots;
68883529b6Schristos   unsigned int nbr_code_slots;
69883529b6Schristos   unsigned int code_limit;
70883529b6Schristos   unsigned char hash_size;
71883529b6Schristos   unsigned char hash_type;
72883529b6Schristos   unsigned char spare1;
73883529b6Schristos   unsigned char page_size;
74883529b6Schristos   unsigned int spare2;
75883529b6Schristos };
76883529b6Schristos 
77883529b6Schristos /* Value for hash_type.  */
78883529b6Schristos #define BFD_MACH_O_CS_NO_HASH 0
79883529b6Schristos #define BFD_MACH_O_CS_HASH_SHA1 1
80883529b6Schristos #define BFD_MACH_O_CS_HASH_SHA256 2
81883529b6Schristos #define BFD_MACH_O_CS_HASH_PRESTANDARD_SKEIN_160x256 32 /* Skein, 160 bits */
82883529b6Schristos #define BFD_MACH_O_CS_HASH_PRESTANDARD_SKEIN_256x512 33 /* Skein, 256 bits */
83883529b6Schristos 
84883529b6Schristos #endif /* _MACH_O_CODESIGN_H */
85