]>
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/cspclient.h>
29 #include <CoreFoundation/CFBundle.h>
31 #ifdef _CPP_OSXSIGNING
43 // A Signable with OS X support calls added
45 class OSXCode
: public Signable
{
47 // encoding and decoding as a UTF-8 string
48 virtual string
encode() const = 0;
49 static OSXCode
*decode(const char *extForm
);
52 // creating OSXCode objects
53 static OSXCode
*main();
54 static OSXCode
*at(const char *path
);
57 // produce the best approximation of a path that, when handed to at(),
58 // will yield an OSXCode that's the most like this one
59 virtual string
canonicalPath() const = 0;
62 OSXCode() { } // nonpublic
63 static void scanFile(const char *pathname
, Signer::State
&state
); // scan an entire file
64 static string
getPath(CFURLRef url
);
69 // A simple executable tool.
71 class ExecutableTool
: public OSXCode
{
73 ExecutableTool(const char *path
) : mPath(path
) { }
74 string
encode() const;
76 string
path() const { return mPath
; }
77 string
canonicalPath() const;
80 void scanContents(Signer::State
&state
) const;
83 string mPath
; // UTF8 pathname to executable
90 class GenericBundle
: public OSXCode
{
92 GenericBundle(const char *path
);
95 string
encode() const;
97 string
canonicalPath() const;
98 string
path() const { return mPath
; }
99 string
executablePath() const { return getPath(CFBundleCopyExecutableURL(mBundle
)); }
101 virtual void *lookupSymbol(const char *name
);
104 void scanContents(Signer::State
&state
) const;
107 string mPath
; // UTF8 path to bundle directory
108 CFBundleRef mBundle
; // CF-style bundle object
111 class ApplicationBundle
: public GenericBundle
{
113 ApplicationBundle(const char *pathname
) : GenericBundle(pathname
) { }
116 class LoadableBundle
: public GenericBundle
{
118 LoadableBundle(const char *pathname
) : GenericBundle(pathname
) { }
120 virtual bool isLoaded() const;
122 virtual void unload();
126 } // end namespace CodeSigning
128 } // end namespace Security
130 #ifdef _CPP_OSXSIGNING