2  * Copyright (c) 2004,2011,2014 Apple Inc. All Rights Reserved. 
   4  * @APPLE_LICENSE_HEADER_START@ 
   6  * This file contains Original Code and/or Modifications of Original Code 
   7  * as defined in and that are subject to the Apple Public Source License 
   8  * Version 2.0 (the 'License'). You may not use this file except in 
   9  * compliance with the License. Please obtain a copy of the License at 
  10  * http://www.opensource.apple.com/apsl/ and read it before using this 
  13  * The Original Code and all software distributed under the License are 
  14  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  15  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  16  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
  17  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  18  * Please see the License for the specific language governing rights and 
  19  * limitations under the License. 
  21  * @APPLE_LICENSE_HEADER_END@ 
  26 // SDFactory -- The factory for Security Server context objects 
  28 #include "SDFactory.h" 
  30 #include "SDContext.h" 
  34 // SDFactory -- The factory for Security Server context objects 
  36 bool SDFactory::setup(SDCSPSession 
&session
, CSPFullPluginSession::CSPContext 
* &cspCtx
, 
  37                                           const Context 
&context
, bool encoding
) 
  40                 return false;   // not ours or already set 
  42         switch (context
.type()) 
  44         case CSSM_ALGCLASS_SIGNATURE
: 
  45                 cspCtx 
= new SDSignatureContext(session
); 
  47         case CSSM_ALGCLASS_MAC
: 
  48                 cspCtx 
= new SDMACContext(session
); 
  50         case CSSM_ALGCLASS_DIGEST
: 
  51                 cspCtx 
= new SDDigestContext(session
); 
  53         case CSSM_ALGCLASS_SYMMETRIC
: 
  54         case CSSM_ALGCLASS_ASYMMETRIC
: 
  55                 cspCtx 
= new SDCryptContext(session
); // @@@ Could also be wrap/unwrap 
  57         case CSSM_ALGCLASS_RANDOMGEN
: 
  58                 cspCtx 
= new SDRandomContext(session
); // @@@ Should go. 
  65         /* FIXME - qualify by ALGCLASS as well to avoid MAC */ 
  66         switch (context
.algorithm()) { 
  68                 cspCtx 
= new MD5Context(session
); 
  71                 cspCtx 
= new SHA1Context(session
); 
  77         CssmError::throwMe(CSSM_ERRCODE_INTERNAL_ERROR
);        // won't support re-definition 
  78     switch (context
.algorithm()) { 
  79         case CSSM_ALGID_ROTTY_ROT_16
: 
  80             ctx 
= new SDContext(16); 
  82         case CSSM_ALGID_ROTTY_ROT_37
: 
  83             ctx 
= new SDContext(37);