]>
git.saurik.com Git - apple/libsecurity_codesigning.git/blob - lib/cdbuilder.h
01c0a6717d9e71df647ac5d146cf40af77f19b2b
2 * Copyright (c) 2006 Apple Computer, 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 // cdbuilder - constructor for CodeDirectories
30 #include "codedirectory.h"
34 namespace CodeSigning
{
38 // Builder can construct CodeDirectories from pieces:
40 // builder.variousSetters(withSuitableData);
41 // CodeDirectory *result = builder.build();
42 // Builder is not reusable.
44 class CodeDirectory::Builder
{
48 void executable(string path
, size_t pagesize
, size_t offset
, size_t length
);
49 void reopen(string path
, size_t offset
, size_t length
);
51 void special(size_t slot
, CFDataRef data
);
52 void identifier(const std::string
&code
) { mIdentifier
= code
; }
53 void flags(uint32_t f
) { mFlags
= f
; }
55 size_t size(); // calculate size
56 CodeDirectory
*build(); // build CodeDirectory and return it
59 Hash::SDigest mSpecial
[cdSlotCount
]; // special slot hashes
60 UnixPlusPlus::AutoFileDesc mExec
; // main executable file
61 size_t mExecOffset
; // starting offset in mExec
62 size_t mExecLength
; // total bytes of file to sign
63 size_t mPageSize
; // page size of executable (bytes)
64 uint32_t mFlags
; // CodeDirectory flags
65 std::string mIdentifier
; // canonical identifier
67 size_t mSpecialSlots
; // highest special slot set
68 size_t mCodeSlots
; // number of code pages (slots)
70 CodeDirectory
*mDir
; // what we're building