]> git.saurik.com Git - apple/security.git/blame - cdsa/cdsa_utilities/osxsigning.h
Security-54.1.9.tar.gz
[apple/security.git] / cdsa / cdsa_utilities / osxsigning.h
CommitLineData
bac41a7b
A
1/*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
19//
20// osxsigning - MacOS X's standard signable objects.
21//
22#ifndef _OSXSIGNING
23#define _OSXSIGNING
24
25#include <Security/codesigning.h>
29654253 26#include <Security/refcount.h>
bac41a7b
A
27#include <Security/cspclient.h>
28#include <limits.h>
29#include <string>
30#include <CoreFoundation/CFBundle.h>
31
32#ifdef _CPP_OSXSIGNING
33#pragma export on
34#endif
35
36
29654253
A
37namespace Security {
38namespace CodeSigning {
bac41a7b 39
bac41a7b
A
40
41//
42// A Signable with OS X support calls added
43//
29654253 44class OSXCode : public RefCount, public Signable {
bac41a7b
A
45public:
46 // encoding and decoding as a UTF-8 string
47 virtual string encode() const = 0;
48 static OSXCode *decode(const char *extForm);
49
50public:
51 // creating OSXCode objects
52 static OSXCode *main();
53 static OSXCode *at(const char *path);
54
55public:
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;
59
60protected:
61 OSXCode() { } // nonpublic
62 static void scanFile(const char *pathname, Signer::State &state); // scan an entire file
63 static string getPath(CFURLRef url);
64};
65
66
67//
68// A simple executable tool.
69//
70class ExecutableTool : public OSXCode {
71public:
72 ExecutableTool(const char *path) : mPath(path) { }
73 string encode() const;
74
75 string path() const { return mPath; }
76 string canonicalPath() const;
77
78protected:
79 void scanContents(Signer::State &state) const;
80
81private:
82 string mPath; // UTF8 pathname to executable
83};
84
85
86//
87// A generic bundle
88//
89class GenericBundle : public OSXCode {
90public:
91 GenericBundle(const char *path);
92 ~GenericBundle();
93
94 string encode() const;
95
96 string canonicalPath() const;
97 string path() const { return mPath; }
98 string executablePath() const { return getPath(CFBundleCopyExecutableURL(mBundle)); }
99
100 virtual void *lookupSymbol(const char *name);
101
102protected:
103 void scanContents(Signer::State &state) const;
104
105protected:
106 string mPath; // UTF8 path to bundle directory
107 CFBundleRef mBundle; // CF-style bundle object
108};
109
110class ApplicationBundle : public GenericBundle {
111public:
112 ApplicationBundle(const char *pathname) : GenericBundle(pathname) { }
113};
114
115class LoadableBundle : public GenericBundle {
116public:
117 LoadableBundle(const char *pathname) : GenericBundle(pathname) { }
118
119 virtual bool isLoaded() const;
120 virtual void load();
121 virtual void unload();
122};
123
124
125} // end namespace CodeSigning
126
127} // end namespace Security
128
129#ifdef _CPP_OSXSIGNING
130#pragma export off
131#endif
132
133
134#endif //_OSXSIGNING