2 * Copyright (c) 2002 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.
21 #ifndef _SECURITY_KEYITEM_H_
22 #define _SECURITY_KEYITEM_H_
24 #include <Security/Item.h>
25 #include <Security/SecKeyPriv.h>
30 namespace KeychainCore
33 class KeyItem
: public ItemImpl
37 // db item contstructor
38 KeyItem(const Keychain
&keychain
, const PrimaryKey
&primaryKey
, const CssmClient::DbUniqueRecord
&uniqueId
);
40 // PrimaryKey item contstructor
41 KeyItem(const Keychain
&keychain
, const PrimaryKey
&primaryKey
);
43 KeyItem(KeyItem
&keyItem
);
47 virtual void update();
48 virtual Item
copyTo(const Keychain
&keychain
);
49 virtual void didModify();
51 CssmClient::SSDbUniqueRecord
ssDbUniqueRecord();
52 const CssmKey
&cssmKey();
54 const AccessCredentials
*getCredentials(
55 CSSM_ACL_AUTHORIZATION_TAG operation
,
56 SecCredentialType credentialType
);
58 static void createPair(
60 CSSM_ALGORITHMS algorithm
,
62 CSSM_CC_HANDLE contextHandle
,
63 CSSM_KEYUSE publicKeyUsage
,
65 CSSM_KEYUSE privateKeyUsage
,
66 uint32 privateKeyAttr
,
67 RefPointer
<Access
> initialAccess
,
68 RefPointer
<KeyItem
> &outPublicKey
,
69 RefPointer
<KeyItem
> &outPrivateKey
);
71 static void importPair(
73 const CSSM_KEY
&publicCssmKey
,
74 const CSSM_KEY
&privateCssmKey
,
75 RefPointer
<Access
> initialAccess
,
76 RefPointer
<KeyItem
> &outPublicKey
,
77 RefPointer
<KeyItem
> &outPrivateKey
);
80 virtual PrimaryKey
add(Keychain
&keychain
);
85 } // end namespace KeychainCore
87 } // end namespace Security
89 #endif // !_SECURITY_KEYITEM_H_