Import from 1.9a8 tarball
[mozilla-nss.git] / security / nss / lib / ckfw / builtins / btoken.c
blob77554fbb1366f7b34af43c8104c37acdb8127125
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Original Code is the Netscape security libraries.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1994-2000
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
35 * ***** END LICENSE BLOCK ***** */
37 #ifdef DEBUG
38 static const char CVS_ID[] = "@(#) $RCSfile: btoken.c,v $ $Revision: 1.3 $ $Date: 2005/01/20 02:25:46 $";
39 #endif /* DEBUG */
41 #include "builtins.h"
44 * builtins/token.c
46 * This file implements the NSSCKMDToken object for the
47 * "builtin objects" cryptoki module.
50 static NSSUTF8 *
51 builtins_mdToken_GetLabel
53 NSSCKMDToken *mdToken,
54 NSSCKFWToken *fwToken,
55 NSSCKMDInstance *mdInstance,
56 NSSCKFWInstance *fwInstance,
57 CK_RV *pError
60 return (NSSUTF8 *)nss_builtins_TokenLabel;
63 static NSSUTF8 *
64 builtins_mdToken_GetManufacturerID
66 NSSCKMDToken *mdToken,
67 NSSCKFWToken *fwToken,
68 NSSCKMDInstance *mdInstance,
69 NSSCKFWInstance *fwInstance,
70 CK_RV *pError
73 return (NSSUTF8 *)nss_builtins_ManufacturerID;
76 static NSSUTF8 *
77 builtins_mdToken_GetModel
79 NSSCKMDToken *mdToken,
80 NSSCKFWToken *fwToken,
81 NSSCKMDInstance *mdInstance,
82 NSSCKFWInstance *fwInstance,
83 CK_RV *pError
86 return (NSSUTF8 *)nss_builtins_TokenModel;
89 static NSSUTF8 *
90 builtins_mdToken_GetSerialNumber
92 NSSCKMDToken *mdToken,
93 NSSCKFWToken *fwToken,
94 NSSCKMDInstance *mdInstance,
95 NSSCKFWInstance *fwInstance,
96 CK_RV *pError
99 return (NSSUTF8 *)nss_builtins_TokenSerialNumber;
102 static CK_BBOOL
103 builtins_mdToken_GetIsWriteProtected
105 NSSCKMDToken *mdToken,
106 NSSCKFWToken *fwToken,
107 NSSCKMDInstance *mdInstance,
108 NSSCKFWInstance *fwInstance
111 return CK_TRUE;
114 static CK_VERSION
115 builtins_mdToken_GetHardwareVersion
117 NSSCKMDToken *mdToken,
118 NSSCKFWToken *fwToken,
119 NSSCKMDInstance *mdInstance,
120 NSSCKFWInstance *fwInstance
123 return nss_builtins_HardwareVersion;
126 static CK_VERSION
127 builtins_mdToken_GetFirmwareVersion
129 NSSCKMDToken *mdToken,
130 NSSCKFWToken *fwToken,
131 NSSCKMDInstance *mdInstance,
132 NSSCKFWInstance *fwInstance
135 return nss_builtins_FirmwareVersion;
138 static NSSCKMDSession *
139 builtins_mdToken_OpenSession
141 NSSCKMDToken *mdToken,
142 NSSCKFWToken *fwToken,
143 NSSCKMDInstance *mdInstance,
144 NSSCKFWInstance *fwInstance,
145 NSSCKFWSession *fwSession,
146 CK_BBOOL rw,
147 CK_RV *pError
150 return nss_builtins_CreateSession(fwSession, pError);
153 NSS_IMPLEMENT_DATA const NSSCKMDToken
154 nss_builtins_mdToken = {
155 (void *)NULL, /* etc */
156 NULL, /* Setup */
157 NULL, /* Invalidate */
158 NULL, /* InitToken -- default errs */
159 builtins_mdToken_GetLabel,
160 builtins_mdToken_GetManufacturerID,
161 builtins_mdToken_GetModel,
162 builtins_mdToken_GetSerialNumber,
163 NULL, /* GetHasRNG -- default is false */
164 builtins_mdToken_GetIsWriteProtected,
165 NULL, /* GetLoginRequired -- default is false */
166 NULL, /* GetUserPinInitialized -- default is false */
167 NULL, /* GetRestoreKeyNotNeeded -- irrelevant */
168 NULL, /* GetHasClockOnToken -- default is false */
169 NULL, /* GetHasProtectedAuthenticationPath -- default is false */
170 NULL, /* GetSupportsDualCryptoOperations -- default is false */
171 NULL, /* GetMaxSessionCount -- default is CK_UNAVAILABLE_INFORMATION */
172 NULL, /* GetMaxRwSessionCount -- default is CK_UNAVAILABLE_INFORMATION */
173 NULL, /* GetMaxPinLen -- irrelevant */
174 NULL, /* GetMinPinLen -- irrelevant */
175 NULL, /* GetTotalPublicMemory -- default is CK_UNAVAILABLE_INFORMATION */
176 NULL, /* GetFreePublicMemory -- default is CK_UNAVAILABLE_INFORMATION */
177 NULL, /* GetTotalPrivateMemory -- default is CK_UNAVAILABLE_INFORMATION */
178 NULL, /* GetFreePrivateMemory -- default is CK_UNAVAILABLE_INFORMATION */
179 builtins_mdToken_GetHardwareVersion,
180 builtins_mdToken_GetFirmwareVersion,
181 NULL, /* GetUTCTime -- no clock */
182 builtins_mdToken_OpenSession,
183 NULL, /* GetMechanismCount -- default is zero */
184 NULL, /* GetMechanismTypes -- irrelevant */
185 NULL, /* GetMechanism -- irrelevant */
186 (void *)NULL /* null terminator */