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 // SSCSPDLSession.cpp - Security Server CSP/DL session.
22 #include "SSCSPDLSession.h"
24 #include "CSPDLPlugin.h"
27 using namespace SecurityServer
;
30 // SSCSPDLSession -- Security Server CSP session
32 SSCSPDLSession::SSCSPDLSession()
38 // Reference Key management
41 SSCSPDLSession::makeReferenceKey(SSCSPSession
&session
, KeyHandle inKeyHandle
,
42 CssmKey
&outKey
, SSDatabase
&inSSDatabase
,
43 uint32 inKeyAttr
, const CssmData
*inKeyLabel
)
45 new SSKey(session
, inKeyHandle
, outKey
, inSSDatabase
, inKeyAttr
,
50 SSCSPDLSession::lookupKey(const CssmKey
&inKey
)
52 /* for now we only allow ref keys */
53 if(inKey
.blobType() != CSSM_KEYBLOB_REFERENCE
) {
54 CssmError::throwMe(CSSMERR_CSP_INVALID_KEY
);
57 /* fetch key (this is just mapping the value in inKey.KeyData to an SSKey) */
58 SSKey
&theKey
= find
<SSKey
>(inKey
);
62 * Make sure caller hasn't changed any crucial header fields.
63 * Some fields were changed by makeReferenceKey, so make a local copy....
65 CSSM_KEYHEADER localHdr
= cssmKey
.KeyHeader
;
66 get binKey
-like thing from SSKey
, maybe SSKey should keep a copy of
67 hdr
...but that
's' not supersecure
....;
69 localHdr
.BlobType
= binKey
->mKeyHeader
.BlobType
;
70 localHdr
.Format
= binKey
->mKeyHeader
.Format
;
71 if(memcmp(&localHdr
, &binKey
->mKeyHeader
, sizeof(CSSM_KEYHEADER
))) {
72 CssmError::throwMe(CSSMERR_CSP_INVALID_KEY_REFERENCE
);