]>
git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_client/keyclient.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.
22 #ifndef _H_CDSA_CLIENT_KEYCLIENT
23 #define _H_CDSA_CLIENT_KEYCLIENT 1
25 #include <Security/aclclient.h>
26 #include <Security/cspclient.h>
37 class KeyImpl
: public ObjectImpl
, public AclClient
, public CssmKey
40 KeyImpl(const CSP
&csp
);
41 KeyImpl(const CSP
&csp
, CSSM_KEY
&key
);
42 KeyImpl(const CSP
&csp
, const CSSM_DATA
&keyData
);
45 CSP
csp() const { return parent
<CSP
>(); }
46 void deleteKey(const CSSM_ACCESS_CREDENTIALS
*cred
);
49 void getAcl(const char *selectionTag
, AutoAclEntryInfoList
&aclInfos
) const;
50 void changeAcl(const CSSM_ACCESS_CREDENTIALS
*accessCred
,
51 const CSSM_ACL_EDIT
&aclEdit
);
53 // Acl owner manipulation
54 void getOwner(AutoAclOwnerPrototype
&owner
) const;
55 void changeOwner(const CSSM_ACCESS_CREDENTIALS
*accessCred
,
56 const CSSM_ACL_OWNER_PROTOTYPE
&newOwner
);
58 // Call this after completing the CSSM API call after having called Key::makeNewKey()
65 class Key
: public Object
69 explicit Key(Impl
*impl
) : Object(impl
) {}
71 Key() : Object(NULL
) {}
72 Key(const CSP
&csp
, CSSM_KEY
&key
) : Object(new Impl(csp
, key
)) {}
73 Key(const CSP
&csp
, CSSM_DATA
&keyData
) : Object(new Impl(csp
, keyData
)) {}
75 // Creates an inactive key, client must call activate() after this.
76 Key(const CSP
&csp
) : Object(new Impl(csp
)) {}
78 Impl
*operator ->() const { return (*this) ? &impl
<Impl
>() : NULL
; }
79 Impl
&operator *() const { return impl
<Impl
>(); }
81 // Conversion operators to CssmKey baseclass.
82 operator const CssmKey
* () const { return (*this) ? &(**this) : NULL
; }
83 operator const CssmKey
& () const { return **this; }
85 // Creates an inactive key, client must call activate() after this.
86 CssmKey
*makeNewKey(const CSP
&csp
) { (*this) = Key(csp
); return &(**this); }
94 const CssmData
*label
;
97 KeySpec(uint32 u
, uint32 a
) : usage(u
), attributes(a
), label(NULL
) { }
98 KeySpec(uint32 u
, uint32 a
, const CssmData
&l
) : usage(u
), attributes(a
), label(&l
) { }
101 } // end namespace CssmClient
103 } // end namespace Security
106 #endif // _H_CDSA_CLIENT_KEYCLIENT