Back to index

lightning-sunbird  0.9+nobinonly
btoken.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  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #ifdef DEBUG
00038 static const char CVS_ID[] = "@(#) $RCSfile: btoken.c,v $ $Revision: 1.3.28.1 $ $Date: 2008/01/24 21:16:51 $";
00039 #endif /* DEBUG */
00040 
00041 #include "builtins.h"
00042 
00043 /*
00044  * builtins/token.c
00045  *
00046  * This file implements the NSSCKMDToken object for the
00047  * "builtin objects" cryptoki module.
00048  */
00049 
00050 static NSSUTF8 *
00051 builtins_mdToken_GetLabel
00052 (
00053   NSSCKMDToken *mdToken,
00054   NSSCKFWToken *fwToken,
00055   NSSCKMDInstance *mdInstance,
00056   NSSCKFWInstance *fwInstance,
00057   CK_RV *pError
00058 )
00059 {
00060   return (NSSUTF8 *)nss_builtins_TokenLabel;
00061 }
00062 
00063 static NSSUTF8 *
00064 builtins_mdToken_GetManufacturerID
00065 (
00066   NSSCKMDToken *mdToken,
00067   NSSCKFWToken *fwToken,
00068   NSSCKMDInstance *mdInstance,
00069   NSSCKFWInstance *fwInstance,
00070   CK_RV *pError
00071 )
00072 {
00073   return (NSSUTF8 *)nss_builtins_ManufacturerID;
00074 }
00075 
00076 static NSSUTF8 *
00077 builtins_mdToken_GetModel
00078 (
00079   NSSCKMDToken *mdToken,
00080   NSSCKFWToken *fwToken,
00081   NSSCKMDInstance *mdInstance,
00082   NSSCKFWInstance *fwInstance,
00083   CK_RV *pError
00084 )
00085 {
00086   return (NSSUTF8 *)nss_builtins_TokenModel;
00087 }
00088 
00089 static NSSUTF8 *
00090 builtins_mdToken_GetSerialNumber
00091 (
00092   NSSCKMDToken *mdToken,
00093   NSSCKFWToken *fwToken,
00094   NSSCKMDInstance *mdInstance,
00095   NSSCKFWInstance *fwInstance,
00096   CK_RV *pError
00097 )
00098 {
00099   return (NSSUTF8 *)nss_builtins_TokenSerialNumber;
00100 }
00101 
00102 static CK_BBOOL
00103 builtins_mdToken_GetIsWriteProtected
00104 (
00105   NSSCKMDToken *mdToken,
00106   NSSCKFWToken *fwToken,
00107   NSSCKMDInstance *mdInstance,
00108   NSSCKFWInstance *fwInstance
00109 )
00110 {
00111   return CK_TRUE;
00112 }
00113 
00114 static CK_VERSION
00115 builtins_mdToken_GetHardwareVersion
00116 (
00117   NSSCKMDToken *mdToken,
00118   NSSCKFWToken *fwToken,
00119   NSSCKMDInstance *mdInstance,
00120   NSSCKFWInstance *fwInstance
00121 )
00122 {
00123   return nss_builtins_HardwareVersion;
00124 }
00125 
00126 static CK_VERSION
00127 builtins_mdToken_GetFirmwareVersion
00128 (
00129   NSSCKMDToken *mdToken,
00130   NSSCKFWToken *fwToken,
00131   NSSCKMDInstance *mdInstance,
00132   NSSCKFWInstance *fwInstance
00133 )
00134 {
00135   return nss_builtins_FirmwareVersion;
00136 }
00137 
00138 static NSSCKMDSession *
00139 builtins_mdToken_OpenSession
00140 (
00141   NSSCKMDToken *mdToken,
00142   NSSCKFWToken *fwToken,
00143   NSSCKMDInstance *mdInstance,
00144   NSSCKFWInstance *fwInstance,
00145   NSSCKFWSession *fwSession,
00146   CK_BBOOL rw,
00147   CK_RV *pError
00148 )
00149 {
00150   return nss_builtins_CreateSession(fwSession, pError);
00151 }
00152 
00153 const NSSCKMDToken
00154 nss_builtins_mdToken = {
00155   (void *)NULL, /* etc */
00156   NULL, /* Setup */
00157   NULL, /* Invalidate */
00158   NULL, /* InitToken -- default errs */
00159   builtins_mdToken_GetLabel,
00160   builtins_mdToken_GetManufacturerID,
00161   builtins_mdToken_GetModel,
00162   builtins_mdToken_GetSerialNumber,
00163   NULL, /* GetHasRNG -- default is false */
00164   builtins_mdToken_GetIsWriteProtected,
00165   NULL, /* GetLoginRequired -- default is false */
00166   NULL, /* GetUserPinInitialized -- default is false */
00167   NULL, /* GetRestoreKeyNotNeeded -- irrelevant */
00168   NULL, /* GetHasClockOnToken -- default is false */
00169   NULL, /* GetHasProtectedAuthenticationPath -- default is false */
00170   NULL, /* GetSupportsDualCryptoOperations -- default is false */
00171   NULL, /* GetMaxSessionCount -- default is CK_UNAVAILABLE_INFORMATION */
00172   NULL, /* GetMaxRwSessionCount -- default is CK_UNAVAILABLE_INFORMATION */
00173   NULL, /* GetMaxPinLen -- irrelevant */
00174   NULL, /* GetMinPinLen -- irrelevant */
00175   NULL, /* GetTotalPublicMemory -- default is CK_UNAVAILABLE_INFORMATION */
00176   NULL, /* GetFreePublicMemory -- default is CK_UNAVAILABLE_INFORMATION */
00177   NULL, /* GetTotalPrivateMemory -- default is CK_UNAVAILABLE_INFORMATION */
00178   NULL, /* GetFreePrivateMemory -- default is CK_UNAVAILABLE_INFORMATION */
00179   builtins_mdToken_GetHardwareVersion,
00180   builtins_mdToken_GetFirmwareVersion,
00181   NULL, /* GetUTCTime -- no clock */
00182   builtins_mdToken_OpenSession,
00183   NULL, /* GetMechanismCount -- default is zero */
00184   NULL, /* GetMechanismTypes -- irrelevant */
00185   NULL, /* GetMechanism -- irrelevant */
00186   (void *)NULL /* null terminator */
00187 };