]> git.saurik.com Git - apple/security.git/blob - AppleCSPDL/SSCSPDLSession.cpp
d9061641de92a8463ad1c43ebaacc9697f7b4b11
[apple/security.git] / AppleCSPDL / SSCSPDLSession.cpp
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
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
8 * using this file.
9 *
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.
16 */
17
18
19 //
20 // SSCSPDLSession.cpp - Security Server CSP/DL session.
21 //
22 #include "SSCSPDLSession.h"
23
24 #include "CSPDLPlugin.h"
25 #include "SSKey.h"
26
27 using namespace SecurityServer;
28
29 //
30 // SSCSPDLSession -- Security Server CSP session
31 //
32 SSCSPDLSession::SSCSPDLSession()
33 {
34 }
35
36
37 //
38 // Reference Key management
39 //
40 void
41 SSCSPDLSession::makeReferenceKey(SSCSPSession &session, KeyHandle inKeyHandle,
42 CssmKey &outKey, SSDatabase &inSSDatabase,
43 uint32 inKeyAttr, const CssmData *inKeyLabel)
44 {
45 new SSKey(session, inKeyHandle, outKey, inSSDatabase, inKeyAttr,
46 inKeyLabel);
47 }
48
49 SSKey &
50 SSCSPDLSession::lookupKey(const CssmKey &inKey)
51 {
52 /* for now we only allow ref keys */
53 if(inKey.blobType() != CSSM_KEYBLOB_REFERENCE) {
54 CssmError::throwMe(CSSMERR_CSP_INVALID_KEY);
55 }
56
57 /* fetch key (this is just mapping the value in inKey.KeyData to an SSKey) */
58 SSKey &theKey = find<SSKey>(inKey);
59
60 #ifdef someday
61 /*
62 * Make sure caller hasn't changed any crucial header fields.
63 * Some fields were changed by makeReferenceKey, so make a local copy....
64 */
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....;
68
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);
73 }
74 #endif
75 return theKey;
76 }