]> git.saurik.com Git - apple/securityd.git/blob - src/tokendatabase.h
6f8ccba0ec47bc28e1101c594831a0f7b183e3a9
[apple/securityd.git] / src / tokendatabase.h
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 // A TokenDatabase is a software storage container,
31 // implemented in cooperation by the AppleCSLDP CDSA plugin and this daemon.
32 //
33 #ifndef _H_TOKENDATABASE
34 #define _H_TOKENDATABASE
35
36 #include "database.h"
37
38 class TokenDatabase;
39 class TokenDbCommon;
40 class TokenKey;
41
42
43 //
44 // TokenDatabase DbCommons
45 //
46 class TokenDbCommon : public DbCommon {
47 public:
48 TokenDbCommon(Session &ssn);
49 public:
50
51 };
52
53
54 //
55 // A Database object represents an Apple CSP/DL open database (DL/DB) object.
56 // It maintains its protected semantic state (including keys) and provides controlled
57 // access.
58 //
59 class TokenDatabase : public Database {
60 friend class TokenDbCommon;
61 public:
62 TokenDatabase(Process &proc);
63
64 TokenDbCommon &common() const;
65
66 const char *dbName() const;
67
68 public:
69 CSSM_KEY_SIZE queryKeySize(Key &key);
70
71 // service calls
72 void generateSignature(const Context &context, Key &key, CSSM_ALGORITHMS signOnlyAlgorithm,
73 const CssmData &data, CssmData &signature);
74 void verifySignature(const Context &context, Key &key, CSSM_ALGORITHMS verifyOnlyAlgorithm,
75 const CssmData &data, const CssmData &signature);
76 void generateMac(const Context &context, Key &key,
77 const CssmData &data, CssmData &mac);
78 void verifyMac(const Context &context, Key &key,
79 const CssmData &data, const CssmData &mac);
80
81 void encrypt(const Context &context, Key &key, const CssmData &clear, CssmData &cipher);
82 void decrypt(const Context &context, Key &key, const CssmData &cipher, CssmData &clear);
83
84 void generateKey(const Context &context,
85 const AccessCredentials *cred, const AclEntryPrototype *owner,
86 uint32 usage, uint32 attrs, RefPointer<Key> &newKey);
87 void generateKey(const Context &context,
88 const AccessCredentials *cred, const AclEntryPrototype *owner,
89 uint32 pubUsage, uint32 pubAttrs, uint32 privUsage, uint32 privAttrs,
90 RefPointer<Key> &publicKey, RefPointer<Key> &privateKey);
91 RefPointer<Key> deriveKey(const Context &context, Key *key,
92 const AccessCredentials *cred, const AclEntryPrototype *owner,
93 CssmData *param, uint32 usage, uint32 attrs);
94
95 void wrapKey(const Context &context, Key *key,
96 Key &keyToBeWrapped, const AccessCredentials *cred,
97 const CssmData &descriptiveData, CssmKey &wrappedKey);
98 RefPointer<Key> unwrapKey(const Context &context, Key *key,
99 const AccessCredentials *cred, const AclEntryPrototype *owner,
100 uint32 usage, uint32 attrs, const CssmKey wrappedKey,
101 Key *publicKey, CssmData *descriptiveData);
102
103 uint32 getOutputSize(const Context &context, Key &key, uint32 inputSize, bool encrypt = true);
104
105 public:
106 // encoding/decoding databases
107 void authenticate(const AccessCredentials *cred);
108 };
109
110
111 #endif //_H_TOKENDATABASE