]> git.saurik.com Git - apple/security.git/blob - Keychain/SecPolicy.cpp
e4e6627ac5b290efbee88447da96aebd0da3d5b4
[apple/security.git] / Keychain / SecPolicy.cpp
1 /*
2 * Copyright (c) 2002 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 #include <Security/SecPolicy.h>
19 #include <Security/SecPolicyPriv.h>
20 #include <Security/Policies.h>
21 #include "SecBridge.h"
22
23
24 //
25 // CF boilerplate
26 //
27 CFTypeID
28 SecPolicyGetTypeID(void)
29 {
30 BEGIN_SECAPI
31 return gTypes().Policy.typeID;
32 END_SECAPI1(_kCFRuntimeNotATypeID)
33 }
34
35
36 //
37 // Sec API bridge functions
38 //
39 OSStatus
40 SecPolicyGetOID(SecPolicyRef policyRef, CSSM_OID* oid)
41 {
42 BEGIN_SECAPI
43 Required(oid) = Policy::required(policyRef)->oid();
44 END_SECAPI
45 }
46
47
48 OSStatus
49 SecPolicyGetValue(SecPolicyRef policyRef, CSSM_DATA* value)
50 {
51 BEGIN_SECAPI
52 Required(value) = Policy::required(policyRef)->value();
53 END_SECAPI
54 }
55
56 OSStatus
57 SecPolicySetValue(SecPolicyRef policyRef, const CSSM_DATA *value)
58 {
59 BEGIN_SECAPI
60 Policy::required(policyRef)->value() = value ? (*value) : CssmData();
61 END_SECAPI
62 }
63
64
65 OSStatus
66 SecPolicyGetTPHandle(SecPolicyRef policyRef, CSSM_TP_HANDLE* tpHandle)
67 {
68 BEGIN_SECAPI
69 Required(tpHandle) = Policy::required(policyRef)->tp()->handle();
70 END_SECAPI
71 }