]> git.saurik.com Git - apple/libsecurity_codesigning.git/blob - lib/filediskrep.h
e84b455baf28d5aa697de5d4f9485d6718f1641f
[apple/libsecurity_codesigning.git] / lib / filediskrep.h
1 /*
2 * Copyright (c) 2006-2007 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 //
25 // filediskrep - single-file executable disk representation
26 //
27 #ifndef _H_FILEDISKREP
28 #define _H_FILEDISKREP
29
30 #include "singlediskrep.h"
31 #include "machorep.h"
32 #include <security_utilities/cfutilities.h>
33
34 namespace Security {
35 namespace CodeSigning {
36
37
38 //
39 // A FileDiskRep represents a single code file on disk. We assume nothing about
40 // the format or contents of the file and impose no structure on it, other than
41 // assuming that all relevant code is contained in the file's data bytes.
42 // By default, we seal the entire file data as a single page.
43 //
44 // This is the ultimate fallback disk format. It is used if no other pattern
45 // applies. As such it is important that we do not introduce any assumptions
46 // here. Know that you do not know what any of the file means.
47 //
48 // FileDiskrep stores components in extended file attributes, one attribute
49 // per component. Note that this imposes size limitations on component size
50 // that may well be prohibitive in some applications.
51 //
52 // This DiskRep does not support resource sealing.
53 //
54 class FileDiskRep : public SingleDiskRep {
55 public:
56 FileDiskRep(const char *path);
57
58 CFDataRef component(CodeDirectory::SpecialSlot slot);
59 const Requirements *defaultRequirements(const Architecture *arch);
60 std::string format();
61
62 public:
63 DiskRep::Writer *writer();
64 class Writer;
65 friend class Writer;
66
67 protected:
68 CFDataRef getAttribute(const char *name);
69 static std::string attrName(const char *name);
70 };
71
72
73 //
74 // The write side of a FileDiskRep
75 //
76 class FileDiskRep::Writer : public SingleDiskRep::Writer {
77 friend class FileDiskRep;
78 public:
79 void component(CodeDirectory::SpecialSlot slot, CFDataRef data);
80 bool preferredStore();
81
82 protected:
83 Writer(FileDiskRep *r) : SingleDiskRep::Writer(r, writerLastResort) { }
84 RefPointer<FileDiskRep> rep;
85 };
86
87
88 } // end namespace CodeSigning
89 } // end namespace Security
90
91 #endif // !_H_FILEDISKREP