]>
git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_utilities/osxsigning.h
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // osxsigning - MacOS X's standard signable objects.
25 #include <Security/codesigning.h>
26 #include <Security/refcount.h>
27 #include <Security/cspclient.h>
30 #include <CoreFoundation/CFBundle.h>
32 #ifdef _CPP_OSXSIGNING
38 namespace CodeSigning
{
42 // A Signable with OS X support calls added
44 class OSXCode
: public RefCount
, public Signable
{
46 // encoding and decoding as a UTF-8 string
47 virtual string
encode() const = 0;
48 static OSXCode
*decode(const char *extForm
);
51 // creating OSXCode objects
52 static OSXCode
*main();
53 static OSXCode
*at(const char *path
);
56 // produce the best approximation of a path that, when handed to at(),
57 // will yield an OSXCode that's the most like this one
58 virtual string
canonicalPath() const = 0;
61 OSXCode() { } // nonpublic
62 static void scanFile(const char *pathname
, Signer::State
&state
); // scan an entire file
63 static string
getPath(CFURLRef url
);
68 // A simple executable tool.
70 class ExecutableTool
: public OSXCode
{
72 ExecutableTool(const char *path
) : mPath(path
) { }
73 string
encode() const;
75 string
path() const { return mPath
; }
76 string
canonicalPath() const;
79 void scanContents(Signer::State
&state
) const;
82 string mPath
; // UTF8 pathname to executable
89 class GenericBundle
: public OSXCode
{
91 GenericBundle(const char *path
);
94 string
encode() const;
96 string
canonicalPath() const;
97 string
path() const { return mPath
; }
98 string
executablePath() const { return getPath(CFBundleCopyExecutableURL(mBundle
)); }
100 virtual void *lookupSymbol(const char *name
);
103 void scanContents(Signer::State
&state
) const;
106 string mPath
; // UTF8 path to bundle directory
107 CFBundleRef mBundle
; // CF-style bundle object
110 class ApplicationBundle
: public GenericBundle
{
112 ApplicationBundle(const char *pathname
) : GenericBundle(pathname
) { }
115 class LoadableBundle
: public GenericBundle
{
117 LoadableBundle(const char *pathname
) : GenericBundle(pathname
) { }
119 virtual bool isLoaded() const;
121 virtual void unload();
125 } // end namespace CodeSigning
127 } // end namespace Security
129 #ifdef _CPP_OSXSIGNING