]>
git.saurik.com Git - apple/security.git/blob - libsecurity_codesigning/lib/cfmdiskrep.h
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 size_t signingLimit();
62 const Requirements
*defaultRequirements(const Architecture
*arch
, const SigningContext
&ctx
);
63 size_t pageSize(const SigningContext
&ctx
);
65 static bool candidate(UnixPlusPlus::FileDesc
&fd
); // could this reasonably be a CFM code?
69 // Signing sticks this structure at the very end of the file
72 Endian
<uint32_t> magic
; // EmbeddedSignatureBlob::magic()
73 Endian
<uint32_t> offset
; // file absolute offset of EmbeddedSignatureBlob
77 DiskRep::Writer
*writer();
82 void readSigningData(); // read and cache signing data
85 bool mTriedRead
; // tried to get signing data
86 size_t mSigningOffset
; // where we found the signing data
87 EmbeddedSignatureBlob
*mSigningData
; // cached signing data
92 // The write side of a FileDiskRep
94 class CFMDiskRep::Writer
: public DiskRep::Writer
, private EmbeddedSignatureBlob::Maker
{
95 friend class CFMDiskRep
;
97 Writer(CFMDiskRep
*r
) : rep(r
), mSigningData(NULL
) { }
100 void component(CodeDirectory::SpecialSlot slot
, CFDataRef data
);
101 virtual void flush();
104 RefPointer
<CFMDiskRep
> rep
;
105 EmbeddedSignatureBlob
*mSigningData
;
109 } // end namespace CodeSigning
110 } // end namespace Security
112 #endif // !_H_CFMDISKREP