2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
28 // tokendatabase - software database container implementation.
30 // A TokenDatabase is a software storage container,
31 // implemented in cooperation by the AppleCSLDP CDSA plugin and this daemon.
33 #ifndef _H_TOKENDATABASE
34 #define _H_TOKENDATABASE
44 // TokenDatabase DbCommons
46 class TokenDbCommon
: public DbCommon
{
48 TokenDbCommon(Session
&ssn
);
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
59 class TokenDatabase
: public Database
{
60 friend class TokenDbCommon
;
62 TokenDatabase(Process
&proc
);
64 TokenDbCommon
&common() const;
66 const char *dbName() const;
69 CSSM_KEY_SIZE
queryKeySize(Key
&key
);
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
);
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
);
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
);
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
);
103 uint32
getOutputSize(const Context
&context
, Key
&key
, uint32 inputSize
, bool encrypt
= true);
106 // encoding/decoding databases
107 void authenticate(const AccessCredentials
*cred
);
111 #endif //_H_TOKENDATABASE