]> git.saurik.com Git - apple/securityd.git/blob - src/tokendatabase.cpp
653898b59e3a67746a9ccbe6c6c4df965241e801
[apple/securityd.git] / src / tokendatabase.cpp
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26
27 //
28 // tokendatabase - software database container implementation.
29 //
30 #include "tokendatabase.h"
31 #include "process.h"
32 #include "key.h"
33
34
35 class TokenKey : public Key {
36 public:
37 };
38
39
40 //
41 // Construct a TokenDatabase
42 //
43 TokenDatabase::TokenDatabase(Process &proc)
44 : Database(proc)
45 {
46 proc.addReference(*this);
47 }
48
49
50 //
51 // Basic Database virtual implementations
52 //
53 TokenDbCommon &TokenDatabase::common() const
54 {
55 return parent<TokenDbCommon>();
56 }
57
58 const char *TokenDatabase::dbName() const
59 {
60 return "<<whatever>>";
61 }
62
63
64 static inline TokenKey &myKey(Key &key)
65 {
66 return safer_cast<TokenKey &>(key);
67 }
68
69
70
71
72 //
73 // Key inquiries
74 //
75 CSSM_KEY_SIZE TokenDatabase::queryKeySize(Key &key)
76 {
77 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
78 }
79
80
81 //
82 // Signatures and MACs
83 //
84 void TokenDatabase::generateSignature(const Context &context, Key &key,
85 CSSM_ALGORITHMS signOnlyAlgorithm, const CssmData &data, CssmData &signature)
86 {
87 key.validate(CSSM_ACL_AUTHORIZATION_SIGN, context);
88 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
89 }
90
91 void TokenDatabase::verifySignature(const Context &context, Key &key,
92 CSSM_ALGORITHMS verifyOnlyAlgorithm, const CssmData &data, const CssmData &signature)
93 {
94 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
95 }
96
97 void TokenDatabase::generateMac(const Context &context, Key &key,
98 const CssmData &data, CssmData &mac)
99 {
100 key.validate(CSSM_ACL_AUTHORIZATION_MAC, context);
101 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
102 }
103
104 void TokenDatabase::verifyMac(const Context &context, Key &key,
105 const CssmData &data, const CssmData &mac)
106 {
107 key.validate(CSSM_ACL_AUTHORIZATION_MAC, context);
108 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
109 }
110
111
112 //
113 // Encryption/decryption
114 //
115 void TokenDatabase::encrypt(const Context &context, Key &key,
116 const CssmData &clear, CssmData &cipher)
117 {
118 key.validate(CSSM_ACL_AUTHORIZATION_ENCRYPT, context);
119 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
120 }
121
122 void TokenDatabase::decrypt(const Context &context, Key &key,
123 const CssmData &cipher, CssmData &clear)
124 {
125 key.validate(CSSM_ACL_AUTHORIZATION_DECRYPT, context);
126 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
127 }
128
129
130 //
131 // Key generation and derivation.
132 // Currently, we consider symmetric key generation to be fast, but
133 // asymmetric key generation to be (potentially) slow.
134 //
135 void TokenDatabase::generateKey(const Context &context,
136 const AccessCredentials *cred, const AclEntryPrototype *owner,
137 uint32 usage, uint32 attrs, RefPointer<Key> &newKey)
138 {
139 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
140 }
141
142 void TokenDatabase::generateKey(const Context &context,
143 const AccessCredentials *cred, const AclEntryPrototype *owner,
144 uint32 pubUsage, uint32 pubAttrs, uint32 privUsage, uint32 privAttrs,
145 RefPointer<Key> &publicKey, RefPointer<Key> &privateKey)
146 {
147 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
148 }
149
150 RefPointer<Key> TokenDatabase::deriveKey(const Context &context, Key *baseKey,
151 const AccessCredentials *cred, const AclEntryPrototype *owner,
152 CssmData *param, uint32 usage, uint32 attrs)
153 {
154 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
155 }
156
157
158 //
159 // Key wrapping and unwrapping.
160 // Note that the key argument (the key in the context) is optional because of the special
161 // case of "cleartext" (null algorithm) wrapping for import/export.
162 //
163
164 void TokenDatabase::wrapKey(const Context &context, Key *key,
165 Key &keyToBeWrapped, const AccessCredentials *cred,
166 const CssmData &descriptiveData, CssmKey &wrappedKey)
167 {
168 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
169 }
170
171 RefPointer<Key> TokenDatabase::unwrapKey(const Context &context, Key *key,
172 const AccessCredentials *cred, const AclEntryPrototype *owner,
173 uint32 usage, uint32 attrs, const CssmKey wrappedKey,
174 Key *publicKey, CssmData *descriptiveData)
175 {
176 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
177 }
178
179
180 //
181 // Miscellaneous CSSM functions
182 //
183 uint32 TokenDatabase::getOutputSize(const Context &context, Key &key, uint32 inputSize, bool encrypt)
184 {
185 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
186 }
187
188
189 //
190 // (Re-)Authenticate the database. This changes the stored credentials.
191 //
192 void TokenDatabase::authenticate(const AccessCredentials *cred)
193 {
194 CssmError::throwMe(CSSM_ERRCODE_FUNCTION_NOT_IMPLEMENTED);
195 }