xref: /netbsd-src/external/gpl3/binutils.old/dist/include/mach-o/codesign.h (revision e992f068c547fd6e84b3f104dc2340adcc955732)
175fd0b74Schristos /* Mach-O support for BFD.
2*e992f068Schristos    Copyright (C) 2011-2022 Free Software Foundation, Inc.
375fd0b74Schristos 
475fd0b74Schristos    This file is part of BFD, the Binary File Descriptor library.
575fd0b74Schristos 
675fd0b74Schristos    This program is free software; you can redistribute it and/or modify
775fd0b74Schristos    it under the terms of the GNU General Public License as published by
875fd0b74Schristos    the Free Software Foundation; either version 3 of the License, or
975fd0b74Schristos    (at your option) any later version.
1075fd0b74Schristos 
1175fd0b74Schristos    This program is distributed in the hope that it will be useful,
1275fd0b74Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1375fd0b74Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1475fd0b74Schristos    GNU General Public License for more details.
1575fd0b74Schristos 
1675fd0b74Schristos    You should have received a copy of the GNU General Public License
1775fd0b74Schristos    along with this program; if not, write to the Free Software
1875fd0b74Schristos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
1975fd0b74Schristos    MA 02110-1301, USA.  */
2075fd0b74Schristos 
2175fd0b74Schristos #ifndef _MACH_O_CODESIGN_H
2275fd0b74Schristos #define _MACH_O_CODESIGN_H
2375fd0b74Schristos 
2475fd0b74Schristos /* Codesign blob magics.  */
2575fd0b74Schristos 
2675fd0b74Schristos /* Superblob containing all the components.  */
2775fd0b74Schristos #define BFD_MACH_O_CS_MAGIC_EMBEDDED_SIGNATURE 0xfade0cc0
2875fd0b74Schristos 
2975fd0b74Schristos /* Individual code requirement.  */
3075fd0b74Schristos #define BFD_MACH_O_CS_MAGIC_REQUIREMENT 0xfade0c00
3175fd0b74Schristos 
3275fd0b74Schristos /* Collection of code requirements, indexed by type.  */
3375fd0b74Schristos #define BFD_MACH_O_CS_MAGIC_REQUIREMENTS 0xfade0c01
3475fd0b74Schristos 
3575fd0b74Schristos /* Directory.  */
3675fd0b74Schristos #define BFD_MACH_O_CS_MAGIC_CODEDIRECTORY 0xfade0c02
3775fd0b74Schristos 
3875fd0b74Schristos /* Entitlements blob.  */
3975fd0b74Schristos #define BFD_MACH_O_CS_MAGIC_EMBEDDED_ENTITLEMENTS 0xfade7171
4075fd0b74Schristos 
4175fd0b74Schristos /* Blob container.  */
4275fd0b74Schristos #define BFD_MACH_O_CS_MAGIC_BLOB_WRAPPER 0xfade0b01
4375fd0b74Schristos 
4475fd0b74Schristos struct mach_o_codesign_codedirectory_external_v1
4575fd0b74Schristos {
4675fd0b74Schristos   /* All the fields are in network byte order (big endian).  */
4775fd0b74Schristos   unsigned char version[4];
4875fd0b74Schristos   unsigned char flags[4];
4975fd0b74Schristos   unsigned char hash_offset[4];
5075fd0b74Schristos   unsigned char ident_offset[4];
5175fd0b74Schristos   unsigned char nbr_special_slots[4];
5275fd0b74Schristos   unsigned char nbr_code_slots[4];
5375fd0b74Schristos   unsigned char code_limit[4];
5475fd0b74Schristos   unsigned char hash_size[1];
5575fd0b74Schristos   unsigned char hash_type[1];
5675fd0b74Schristos   unsigned char spare1[1];
5775fd0b74Schristos   unsigned char page_size[1];
5875fd0b74Schristos   unsigned char spare2[4];
5975fd0b74Schristos };
6075fd0b74Schristos 
6175fd0b74Schristos struct mach_o_codesign_codedirectory_v1
6275fd0b74Schristos {
6375fd0b74Schristos   unsigned int version;
6475fd0b74Schristos   unsigned int flags;
6575fd0b74Schristos   unsigned int hash_offset;
6675fd0b74Schristos   unsigned int ident_offset;
6775fd0b74Schristos   unsigned int nbr_special_slots;
6875fd0b74Schristos   unsigned int nbr_code_slots;
6975fd0b74Schristos   unsigned int code_limit;
7075fd0b74Schristos   unsigned char hash_size;
7175fd0b74Schristos   unsigned char hash_type;
7275fd0b74Schristos   unsigned char spare1;
7375fd0b74Schristos   unsigned char page_size;
7475fd0b74Schristos   unsigned int spare2;
7575fd0b74Schristos };
7675fd0b74Schristos 
7775fd0b74Schristos /* Value for hash_type.  */
7875fd0b74Schristos #define BFD_MACH_O_CS_NO_HASH 0
7975fd0b74Schristos #define BFD_MACH_O_CS_HASH_SHA1 1
8075fd0b74Schristos #define BFD_MACH_O_CS_HASH_SHA256 2
8175fd0b74Schristos #define BFD_MACH_O_CS_HASH_PRESTANDARD_SKEIN_160x256 32 /* Skein, 160 bits */
8275fd0b74Schristos #define BFD_MACH_O_CS_HASH_PRESTANDARD_SKEIN_256x512 33 /* Skein, 256 bits */
8375fd0b74Schristos 
8475fd0b74Schristos #endif /* _MACH_O_CODESIGN_H */
85