]>
git.saurik.com Git - apple/libsecurity_codesigning.git/blob - lib/cfmdiskrep.h
23d3a8ad0a2b51ad2ec9cbcd6cb92b3e01043247
2 * Copyright (c) 2007 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 // cfmdiskrep - single-file CFM (PEF) executable disk representation
30 #include "singlediskrep.h"
32 #include "signerutils.h"
33 #include <security_utilities/unix++.h>
34 #include <security_utilities/cfutilities.h>
37 namespace CodeSigning
{
41 // A CFMDiskRep represents a single code file on disk containing a CFM (PEF)
42 // binary. It is considered self-contained, and does not depend on any other
43 // files in the system (even if it may be part of a larger bundle etc.)
45 // CFM is considered a legacy format that is not generated by Apple, but still
46 // supported for backward compatibility. This DiskRep supports writing signing
47 // data into the executable, using a simple back-of-file frame. It does not
48 // support embedded Info.plists or any other fancy stuff.
50 // This DiskRep does not support resource sealing.
52 class CFMDiskRep
: public SingleDiskRep
{
54 CFMDiskRep(const char *path
);
57 CFDataRef
component(CodeDirectory::SpecialSlot slot
);
58 const Requirements
*defaultRequirements(const Architecture
*arch
);
60 size_t signingLimit();
64 static bool candidate(UnixPlusPlus::FileDesc
&fd
); // could this reasonably be a CFM code?
68 // Signing sticks this structure at the very end of the file
71 Endian
<uint32_t> magic
; // EmbeddedSignatureBlob::magic()
72 Endian
<uint32_t> offset
; // file absolute offset of EmbeddedSignatureBlob
76 DiskRep::Writer
*writer();
81 void readSigningData(); // read and cache signing data
84 bool mTriedRead
; // tried to get signing data
85 size_t mSigningOffset
; // where we found the signing data
86 EmbeddedSignatureBlob
*mSigningData
; // cached signing data
91 // The write side of a FileDiskRep
93 class CFMDiskRep::Writer
: public DiskRep::Writer
, private EmbeddedSignatureBlob::Maker
{
94 friend class CFMDiskRep
;
96 Writer(CFMDiskRep
*r
) : rep(r
), mSigningData(NULL
) { }
99 void component(CodeDirectory::SpecialSlot slot
, CFDataRef data
);
100 virtual void flush();
103 RefPointer
<CFMDiskRep
> rep
;
104 EmbeddedSignatureBlob
*mSigningData
;
108 } // end namespace CodeSigning
109 } // end namespace Security
111 #endif // !_H_CFMDISKREP