Back to index

lightning-sunbird  0.9+nobinonly
cinst.c
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00019  * the Initial Developer. All Rights Reserved.
00020  * Portions created by Red Hat, Inc, are Copyright (C) 2005
00021  *
00022  * Contributor(s):
00023  *   Bob Relyea (rrelyea@redhat.com)
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 #ifdef DEBUG
00039 static const char CVS_ID[] = "@(#) $RCSfile: cinst.c,v $ $Revision: 1.2 $ $Date: 2005/11/15 00:13:58 $";
00040 #endif /* DEBUG */
00041 
00042 #include "ckcapi.h"
00043 
00044 /*
00045  * ckcapi/cinstance.c
00046  *
00047  * This file implements the NSSCKMDInstance object for the 
00048  * "capi" cryptoki module.
00049  */
00050 
00051 /*
00052  * NSSCKMDInstance methods
00053  */
00054 
00055 static CK_ULONG
00056 ckcapi_mdInstance_GetNSlots
00057 (
00058   NSSCKMDInstance *mdInstance,
00059   NSSCKFWInstance *fwInstance,
00060   CK_RV *pError
00061 )
00062 {
00063   return (CK_ULONG)1;
00064 }
00065 
00066 static CK_VERSION
00067 ckcapi_mdInstance_GetCryptokiVersion
00068 (
00069   NSSCKMDInstance *mdInstance,
00070   NSSCKFWInstance *fwInstance
00071 )
00072 {
00073   return nss_ckcapi_CryptokiVersion;
00074 }
00075 
00076 static NSSUTF8 *
00077 ckcapi_mdInstance_GetManufacturerID
00078 (
00079   NSSCKMDInstance *mdInstance,
00080   NSSCKFWInstance *fwInstance,
00081   CK_RV *pError
00082 )
00083 {
00084   return (NSSUTF8 *)nss_ckcapi_ManufacturerID;
00085 }
00086 
00087 static NSSUTF8 *
00088 ckcapi_mdInstance_GetLibraryDescription
00089 (
00090   NSSCKMDInstance *mdInstance,
00091   NSSCKFWInstance *fwInstance,
00092   CK_RV *pError
00093 )
00094 {
00095   return (NSSUTF8 *)nss_ckcapi_LibraryDescription;
00096 }
00097 
00098 static CK_VERSION
00099 ckcapi_mdInstance_GetLibraryVersion
00100 (
00101   NSSCKMDInstance *mdInstance,
00102   NSSCKFWInstance *fwInstance
00103 )
00104 {
00105   return nss_ckcapi_LibraryVersion;
00106 }
00107 
00108 static CK_RV
00109 ckcapi_mdInstance_GetSlots
00110 (
00111   NSSCKMDInstance *mdInstance,
00112   NSSCKFWInstance *fwInstance,
00113   NSSCKMDSlot *slots[]
00114 )
00115 {
00116   slots[0] = (NSSCKMDSlot *)&nss_ckcapi_mdSlot;
00117   return CKR_OK;
00118 }
00119 
00120 static CK_BBOOL
00121 ckcapi_mdInstance_ModuleHandlesSessionObjects
00122 (
00123   NSSCKMDInstance *mdInstance,
00124   NSSCKFWInstance *fwInstance
00125 )
00126 {
00127   /* we don't want to allow any session object creation, at least
00128    * until we can investigate whether or not we can use those objects
00129    */
00130   return CK_TRUE;
00131 }
00132 
00133 NSS_IMPLEMENT_DATA const NSSCKMDInstance
00134 nss_ckcapi_mdInstance = {
00135   (void *)NULL, /* etc */
00136   NULL, /* Initialize */
00137   NULL, /* Finalize */
00138   ckcapi_mdInstance_GetNSlots,
00139   ckcapi_mdInstance_GetCryptokiVersion,
00140   ckcapi_mdInstance_GetManufacturerID,
00141   ckcapi_mdInstance_GetLibraryDescription,
00142   ckcapi_mdInstance_GetLibraryVersion,
00143   ckcapi_mdInstance_ModuleHandlesSessionObjects, 
00144   /*NULL, /* HandleSessionObjects */
00145   ckcapi_mdInstance_GetSlots,
00146   NULL, /* WaitForSlotEvent */
00147   (void *)NULL /* null terminator */
00148 };