]> git.saurik.com Git - apple/libsecurity_codesigning.git/blame_incremental - lib/csgeneric.h
libsecurity_codesigning-55032.tar.gz
[apple/libsecurity_codesigning.git] / lib / csgeneric.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2006 Apple Computer, 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// csgeneric - generic Code representative
26//
27#ifndef _H_CSGENERIC
28#define _H_CSGENERIC
29
30#include "Code.h"
31#include <Security/SecCodeHost.h>
32#include <security_utilities/utilities.h>
33#include <security_utilities/mach++.h>
34
35namespace Security {
36namespace CodeSigning {
37
38
39//
40// A SecCode that represents "generic" code.
41// Generic code is, well, generic. It doesn't have any real resources that define it,
42// and so it's defined, de facto, by its host. The Code Signing subsystem has no special
43// knowledge as to its nature, and so it just asks the host about everything. The asking
44// is done via the cshosting Mach RPC protocol, which can be implemented by hosts in whichever
45// way they find reasonable. This code doesn't care, as long as someone is answering.
46//
47// It is all right to subclass GenericCode to inherit access to the cshosting protocol.
48//
49class GenericCode : public SecCode {
50public:
51 GenericCode(SecCode *host, SecGuestRef guestRef = kSecNoGuest);
52
53 SecCode *locateGuest(CFDictionaryRef attributes);
54 SecStaticCode *identifyGuest(SecCode *guest, CFDataRef *cdhash);
55 SecCodeStatus getGuestStatus(SecCode *guest);
56 void changeGuestStatus(SecCode *guest, SecCodeStatusOperation operation, CFDictionaryRef arguments);
57
58 SecGuestRef guestRef() const { return mGuestRef; }
59
60protected:
61 MachPlusPlus::Port hostingPort();
62 virtual mach_port_t getHostingPort();
63
64private:
65 void identifyGuest(SecGuestRef guest, char *path, CFDataRef &cdhash, CFDictionaryRef &attributes);
66
67private:
68 MachPlusPlus::Port mHostingPort; // cached hosting port for this Code
69 SecGuestRef mGuestRef; // guest reference
70};
71
72
73//
74// We don't need a GenericCode variant of SecStaticCode
75//
76typedef SecStaticCode GenericStaticCode;
77
78
79} // end namespace CodeSigning
80} // end namespace Security
81
82#endif // !_H_CSGENERIC