2 * Copyright (c) 2004 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 // localdatabase - locally implemented database using internal CSP cryptography
30 // A LocalDatabase manages keys with a locally resident AppleCSP.
31 // This is an abstract class useful for subclassing.
33 #ifndef _H_LOCALDATABASE
34 #define _H_LOCALDATABASE
42 // A Database object represents an Apple CSP/DL open database (DL/DB) object.
43 // It maintains its protected semantic state (including keys) and provides controlled
46 class LocalDatabase
: public Database
{
48 LocalDatabase(Process
&proc
);
51 //void releaseKey(Key &key);
52 CSSM_KEY_SIZE
queryKeySize(Key
&key
);
55 void generateSignature(const Context
&context
, Key
&key
, CSSM_ALGORITHMS signOnlyAlgorithm
,
56 const CssmData
&data
, CssmData
&signature
);
57 void verifySignature(const Context
&context
, Key
&key
, CSSM_ALGORITHMS verifyOnlyAlgorithm
,
58 const CssmData
&data
, const CssmData
&signature
);
59 void generateMac(const Context
&context
, Key
&key
,
60 const CssmData
&data
, CssmData
&mac
);
61 void verifyMac(const Context
&context
, Key
&key
,
62 const CssmData
&data
, const CssmData
&mac
);
64 void encrypt(const Context
&context
, Key
&key
, const CssmData
&clear
, CssmData
&cipher
);
65 void decrypt(const Context
&context
, Key
&key
, const CssmData
&cipher
, CssmData
&clear
);
67 void generateKey(const Context
&context
,
68 const AccessCredentials
*cred
, const AclEntryPrototype
*owner
,
69 uint32 usage
, uint32 attrs
, RefPointer
<Key
> &newKey
);
70 void generateKey(const Context
&context
,
71 const AccessCredentials
*cred
, const AclEntryPrototype
*owner
,
72 uint32 pubUsage
, uint32 pubAttrs
, uint32 privUsage
, uint32 privAttrs
,
73 RefPointer
<Key
> &publicKey
, RefPointer
<Key
> &privateKey
);
74 RefPointer
<Key
> deriveKey(const Context
&context
, Key
*key
,
75 const AccessCredentials
*cred
, const AclEntryPrototype
*owner
,
76 CssmData
*param
, uint32 usage
, uint32 attrs
);
78 void wrapKey(const Context
&context
, Key
*key
,
79 Key
&keyToBeWrapped
, const AccessCredentials
*cred
,
80 const CssmData
&descriptiveData
, CssmKey
&wrappedKey
);
81 RefPointer
<Key
> unwrapKey(const Context
&context
, Key
*key
,
82 const AccessCredentials
*cred
, const AclEntryPrototype
*owner
,
83 uint32 usage
, uint32 attrs
, const CssmKey wrappedKey
,
84 Key
*publicKey
, CssmData
*descriptiveData
);
86 uint32
getOutputSize(const Context
&context
, Key
&key
, uint32 inputSize
, bool encrypt
= true);
89 virtual RefPointer
<Key
> makeKey(const CssmKey
&newKey
, uint32 moreAttributes
,
90 const AclEntryPrototype
*owner
) = 0;
93 // encoding/decoding databases
94 void authenticate(const AccessCredentials
*cred
);
97 #endif //_H_LOCALDATABASE