]> git.saurik.com Git - apple/libsecurity_codesigning.git/blob - lib/detachedrep.h
libsecurity_codesigning-55032.tar.gz
[apple/libsecurity_codesigning.git] / lib / detachedrep.h
1 /*
2 * Copyright (c) 2006-2008 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 // detachedrep - prefix diskrep representing a detached signature stored in a file
26 //
27 #ifndef _H_DETACHEDREP
28 #define _H_DETACHEDREP
29
30 #include "diskrep.h"
31 #include "sigblob.h"
32
33 namespace Security {
34 namespace CodeSigning {
35
36
37 //
38 // We use a DetachedRep to interpose (filter) the genuine DiskRep representing
39 // the code on disk, *if* a detached signature was set on this object. In this
40 // situation, mRep will point to a (2 element) chain of DiskReps.
41 //
42 // This is a neat way of dealing with the (unusual) detached-signature case
43 // without disturbing things unduly. Consider DetachedDiskRep to be closely
44 // married to SecStaticCode; it's unlikely to work right if you use it elsewhere.
45 //
46 // Note that there's no *writing* code here. Writing detached signatures is handled
47 // specially in the signing code.
48 //
49 class DetachedRep : public FilterRep {
50 public:
51 DetachedRep(CFDataRef sig, DiskRep *orig, const std::string &source); // SuperBlob of all architectures
52 DetachedRep(CFDataRef sig, CFDataRef gsig, DiskRep *orig, const std::string &source); // one architecture + globals
53
54 CFDataRef component(CodeDirectory::SpecialSlot slot);
55
56 const std::string &source() const { return mSource; }
57
58 private:
59 CFRef<CFDataRef> mSig, mGSig;
60 const EmbeddedSignatureBlob *mArch; // current architecture; points into mSignature
61 const EmbeddedSignatureBlob *mGlobal; // shared elements; points into mSignature
62 std::string mSource; // source description (readable)
63 };
64
65
66 } // end namespace CodeSigning
67 } // end namespace Security
68
69 #endif // !_H_DETACHEDREP