]> git.saurik.com Git - apple/security.git/blob - Keychain/KeyItem.h
553a56a964719ee4e8698973443ddfc7eb46b89c
[apple/security.git] / Keychain / KeyItem.h
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 //
19 // KeyItem.h
20 //
21 #ifndef _SECURITY_KEYITEM_H_
22 #define _SECURITY_KEYITEM_H_
23
24 #include <Security/Item.h>
25 #include <Security/SecKeyPriv.h>
26
27 namespace Security
28 {
29
30 namespace KeychainCore
31 {
32
33 class KeyItem : public ItemImpl
34 {
35 NOCOPY(KeyItem)
36 public:
37 // db item contstructor
38 KeyItem(const Keychain &keychain, const PrimaryKey &primaryKey, const CssmClient::DbUniqueRecord &uniqueId);
39
40 // PrimaryKey item contstructor
41 KeyItem(const Keychain &keychain, const PrimaryKey &primaryKey);
42
43 KeyItem(KeyItem &keyItem);
44
45 virtual ~KeyItem();
46
47 virtual void update();
48 virtual Item copyTo(const Keychain &keychain);
49 virtual void didModify();
50
51 CssmClient::SSDbUniqueRecord ssDbUniqueRecord();
52 const CssmKey &cssmKey();
53
54 const AccessCredentials *getCredentials(
55 CSSM_ACL_AUTHORIZATION_TAG operation,
56 SecCredentialType credentialType);
57
58 static void createPair(
59 Keychain keychain,
60 CSSM_ALGORITHMS algorithm,
61 uint32 keySizeInBits,
62 CSSM_CC_HANDLE contextHandle,
63 CSSM_KEYUSE publicKeyUsage,
64 uint32 publicKeyAttr,
65 CSSM_KEYUSE privateKeyUsage,
66 uint32 privateKeyAttr,
67 RefPointer<Access> initialAccess,
68 RefPointer<KeyItem> &outPublicKey,
69 RefPointer<KeyItem> &outPrivateKey);
70
71 static void importPair(
72 Keychain keychain,
73 const CSSM_KEY &publicCssmKey,
74 const CSSM_KEY &privateCssmKey,
75 RefPointer<Access> initialAccess,
76 RefPointer<KeyItem> &outPublicKey,
77 RefPointer<KeyItem> &outPrivateKey);
78
79 protected:
80 virtual PrimaryKey add(Keychain &keychain);
81 private:
82 CssmKey *mKey;
83 };
84
85 } // end namespace KeychainCore
86
87 } // end namespace Security
88
89 #endif // !_SECURITY_KEYITEM_H_