]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_codesigning/lib/machorep.h
2 * Copyright (c) 2006,2011,2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 // machorep - DiskRep mix-in for handling Mach-O main executables
30 #include "singlediskrep.h"
32 #include <security_utilities/unix++.h>
33 #include <security_utilities/macho++.h>
36 namespace CodeSigning
{
40 // MachORep is a DiskRep class that supports code signatures
41 // directly embedded in Mach-O binary files.
43 // It does not have write support (for writing signatures);
44 // writing multi-architecture binaries is complicated enough
45 // that it's driven directly from the signing code, with no
46 // abstractions to get in the way.
48 class MachORep
: public SingleDiskRep
, public EditableDiskRep
{
50 MachORep(const char *path
, const Context
*ctx
= NULL
);
53 CFDataRef
component(CodeDirectory::SpecialSlot slot
);
54 RawComponentMap
createRawComponents();
55 CFDataRef
identification();
56 Universal
*mainExecutableImage();
57 void prepareForSigning(SigningContext
&context
);
59 size_t signingLimit();
60 size_t execSegBase(const Architecture
*arch
);
61 size_t execSegLimit(const Architecture
*arch
);
63 CFDictionaryRef
diskRepInformation();
65 std::string
recommendedIdentifier(const SigningContext
&ctx
);
66 const Requirements
*defaultRequirements(const Architecture
*arch
, const SigningContext
&ctx
);
67 size_t pageSize(const SigningContext
&ctx
);
69 void strictValidate(const CodeDirectory
* cd
, const ToleratedErrors
& tolerated
, SecCSFlags flags
);
71 void flush(); // flush cache
73 static bool candidate(UnixPlusPlus::FileDesc
&fd
);
76 static CFDataRef
identificationFor(MachO
*macho
);
79 DiskRep::Writer
*writer();
84 CFDataRef
embeddedComponent(CodeDirectory::SpecialSlot slot
);
85 CFDataRef
infoPlist();
86 Requirement
*libraryRequirements(const Architecture
*arch
, const SigningContext
&ctx
);
89 static bool needsExecSeg(const MachO
& macho
);
90 EmbeddedSignatureBlob
*signingData();
92 Universal
*mExecutable
; // cached Mach-O/Universal reference to mainExecutablePath()
93 mutable EmbeddedSignatureBlob
*mSigningData
; // cached signing data from current architecture
98 // The write side of a MachORep.
99 // This is purposely dysfunctional; Mach-O signatures are written
100 // by code in signerutils, not by DiskRep::Writers.
102 class MachORep::Writer
: public SingleDiskRep::Writer
{
103 friend class FileDiskRep
;
105 Writer(MachORep
*r
) : SingleDiskRep::Writer(r
, writerNoGlobal
) { }
106 void component(CodeDirectory::SpecialSlot slot
, CFDataRef data
);
110 } // end namespace CodeSigning
111 } // end namespace Security
113 #endif // !_H_MACHOREP