]> git.saurik.com Git - apple/security.git/blob - securityd/src/acl_keychain.h
Security-59754.80.3.tar.gz
[apple/security.git] / securityd / src / acl_keychain.h
1 /*
2 * Copyright (c) 2000-2004,2006-2007,2009 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 //
26 // acl_keychain - a subject type for the protected-path
27 // keychain prompt interaction model.
28 //
29 #ifndef _ACL_KEYCHAIN
30 #define _ACL_KEYCHAIN
31
32 #include <security_cdsa_utilities/cssmacl.h>
33 #include <string>
34
35
36 //
37 // This is the actual subject implementation class
38 //
39 class KeychainPromptAclSubject : public SimpleAclSubject {
40 static const Version pumaVersion = 0; // 10.0, 10.1 -> default selector (not stored)
41 static const Version jaguarVersion = 1; // 10.2 et al -> first version selector
42 static const Version currentVersion = jaguarVersion; // what we write today
43 public:
44 bool validates(const AclValidationContext &ctx) const;
45 bool validates(const AclValidationContext &baseCtx, const TypedList &sample) const;
46 bool validateExplicitly(const AclValidationContext &baseCtx, void (^always)()) const;
47 CssmList toList(Allocator &alloc) const;
48 bool hasAuthorizedForSystemKeychain() const;
49
50 KeychainPromptAclSubject(string description, const CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR &selector);
51
52 void exportBlob(Writer::Counter &pub, Writer::Counter &priv);
53 void exportBlob(Writer &pub, Writer &priv);
54
55 uint32_t selectorFlags() const { return selector.flags; }
56 bool selectorFlag(uint32_t flag) const { return selectorFlags() & flag; }
57
58 IFDUMP(void debugDump() const);
59
60 static uint32_t getPromptAttempts();
61 void addPromptAttempt(); // Use this only if you're going to call validateExplicitly out of the normal call hierarchy
62
63 public:
64 class Maker : public AclSubject::Maker {
65 friend class KeychainPromptAclSubject;
66 public:
67 Maker(uint32_t mode)
68 : AclSubject::Maker(CSSM_ACL_SUBJECT_TYPE_KEYCHAIN_PROMPT) { defaultMode = mode; }
69 KeychainPromptAclSubject *make(const TypedList &list) const;
70 KeychainPromptAclSubject *make(Version version, Reader &pub, Reader &priv) const;
71
72 private:
73 static uint32_t defaultMode;
74 };
75
76 private:
77 static uint32_t promptsValidated;
78
79 CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR selector; // selector structure
80 string description; // description blob (string)
81
82 private:
83 static CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR defaultSelector;
84 };
85
86
87 #endif //_ACL_KEYCHAIN