]>
git.saurik.com Git - apple/security.git/blob - SecurityServer/dbcrypto.h
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
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
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.
20 // dbcrypto - cryptographic core for database and key blob cryptography
25 #include "securityserver.h"
26 #include <Security/cspclient.h>
27 #include <Security/keyclient.h>
31 // A DatabaseCryptoCore object encapsulates the secret state of a database.
32 // It provides for encoding and decoding of database blobs and key blobs,
33 // and holds all state related to the database secrets.
35 class DatabaseCryptoCore
{
38 virtual ~DatabaseCryptoCore();
40 bool isValid() const { return mIsValid
; }
42 void generateNewSecrets();
44 DbBlob
*encodeCore(const DbBlob
&blobTemplate
, const CssmData
&passphrase
,
45 const CssmData
&publicAcl
, const CssmData
&privateAcl
) const;
46 void decodeCore(DbBlob
*blob
, const CssmData
&passphrase
,
47 void **privateAclBlob
= NULL
);
49 KeyBlob
*encodeKeyCore(const CssmKey
&key
,
50 const CssmData
&publicAcl
, const CssmData
&privateAcl
) const;
51 void decodeKeyCore(KeyBlob
*blob
,
52 CssmKey
&key
, void * &pubAcl
, void * &privAcl
) const;
54 static const uint32 managedAttributes
= KeyBlob::managedAttributes
;
57 bool mIsValid
; // master secrets are valid
59 CssmClient::Key encryptionKey
; // master encryption key
60 CssmClient::Key signingKey
; // master signing key
62 CssmClient::Key
deriveDbCryptoKey(const CssmData
&passphrase
, const CssmData
&salt
) const;
63 CssmClient::Key
makeRawKey(void *data
, size_t length
,
64 CSSM_ALGORITHMS algid
, CSSM_KEYUSE usage
);