Commit | Line | Data |
---|---|---|
29654253 A |
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> | |
5a719ac8 | 25 | #include <Security/SecKeyPriv.h> |
29654253 A |
26 | |
27 | namespace Security | |
28 | { | |
29 | ||
30 | namespace KeychainCore | |
31 | { | |
32 | ||
33 | class KeyItem : public ItemImpl | |
34 | { | |
35 | NOCOPY(KeyItem) | |
36 | public: | |
df0e469f A |
37 | SECCFFUNCTIONS(KeyItem, SecKeyRef, errSecInvalidItemRef) |
38 | ||
29654253 A |
39 | // db item contstructor |
40 | KeyItem(const Keychain &keychain, const PrimaryKey &primaryKey, const CssmClient::DbUniqueRecord &uniqueId); | |
41 | ||
42 | // PrimaryKey item contstructor | |
43 | KeyItem(const Keychain &keychain, const PrimaryKey &primaryKey); | |
44 | ||
45 | KeyItem(KeyItem &keyItem); | |
46 | ||
df0e469f A |
47 | KeyItem(const CssmClient::Key &key); |
48 | ||
49 | virtual ~KeyItem() throw(); | |
29654253 A |
50 | |
51 | virtual void update(); | |
df0e469f | 52 | virtual Item copyTo(const Keychain &keychain, Access *newAccess = NULL); |
29654253 A |
53 | virtual void didModify(); |
54 | ||
55 | CssmClient::SSDbUniqueRecord ssDbUniqueRecord(); | |
df0e469f A |
56 | CssmClient::Key &key(); |
57 | CssmClient::CSP csp(); | |
58 | ||
59 | const CSSM_X509_ALGORITHM_IDENTIFIER& algorithmIdentifier(); | |
60 | unsigned int strengthInBits(const CSSM_X509_ALGORITHM_IDENTIFIER *algid); | |
29654253 | 61 | |
5a719ac8 A |
62 | const AccessCredentials *getCredentials( |
63 | CSSM_ACL_AUTHORIZATION_TAG operation, | |
64 | SecCredentialType credentialType); | |
65 | ||
66 | static void createPair( | |
67 | Keychain keychain, | |
68 | CSSM_ALGORITHMS algorithm, | |
69 | uint32 keySizeInBits, | |
70 | CSSM_CC_HANDLE contextHandle, | |
71 | CSSM_KEYUSE publicKeyUsage, | |
72 | uint32 publicKeyAttr, | |
73 | CSSM_KEYUSE privateKeyUsage, | |
74 | uint32 privateKeyAttr, | |
df0e469f A |
75 | SecPointer<Access> initialAccess, |
76 | SecPointer<KeyItem> &outPublicKey, | |
77 | SecPointer<KeyItem> &outPrivateKey); | |
5a719ac8 A |
78 | |
79 | static void importPair( | |
80 | Keychain keychain, | |
81 | const CSSM_KEY &publicCssmKey, | |
82 | const CSSM_KEY &privateCssmKey, | |
df0e469f A |
83 | SecPointer<Access> initialAccess, |
84 | SecPointer<KeyItem> &outPublicKey, | |
85 | SecPointer<KeyItem> &outPrivateKey); | |
86 | ||
87 | static KeyItem *generate( | |
88 | Keychain keychain, | |
89 | CSSM_ALGORITHMS algorithm, | |
90 | uint32 keySizeInBits, | |
91 | CSSM_CC_HANDLE contextHandle, | |
92 | CSSM_KEYUSE keyUsage, | |
93 | uint32 keyAttr, | |
94 | SecPointer<Access> initialAccess); | |
5a719ac8 | 95 | |
29654253 A |
96 | protected: |
97 | virtual PrimaryKey add(Keychain &keychain); | |
98 | private: | |
df0e469f A |
99 | CssmClient::Key mKey; |
100 | const CSSM_X509_ALGORITHM_IDENTIFIER *algid; | |
29654253 A |
101 | }; |
102 | ||
103 | } // end namespace KeychainCore | |
104 | ||
105 | } // end namespace Security | |
106 | ||
107 | #endif // !_SECURITY_KEYITEM_H_ |