~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/security/nss/lib/softoken/fipstokn.c

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * The contents of this file are subject to the Mozilla Public
 
3
 * License Version 1.1 (the "License"); you may not use this file
 
4
 * except in compliance with the License. You may obtain a copy of
 
5
 * the License at http://www.mozilla.org/MPL/
 
6
 * 
 
7
 * Software distributed under the License is distributed on an "AS
 
8
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
9
 * implied. See the License for the specific language governing
 
10
 * rights and limitations under the License.
 
11
 * 
 
12
 * The Original Code is the Netscape security libraries.
 
13
 * 
 
14
 * The Initial Developer of the Original Code is Netscape
 
15
 * Communications Corporation.  Portions created by Netscape are 
 
16
 * Copyright (C) 1994-2000 Netscape Communications Corporation.  All
 
17
 * Rights Reserved.
 
18
 * 
 
19
 * Contributor(s):
 
20
 * 
 
21
 * Alternatively, the contents of this file may be used under the
 
22
 * terms of the GNU General Public License Version 2 or later (the
 
23
 * "GPL"), in which case the provisions of the GPL are applicable 
 
24
 * instead of those above.  If you wish to allow use of your 
 
25
 * version of this file only under the terms of the GPL and not to
 
26
 * allow others to use your version of this file under the MPL,
 
27
 * indicate your decision by deleting the provisions above and
 
28
 * replace them with the notice and other provisions required by
 
29
 * the GPL.  If you do not delete the provisions above, a recipient
 
30
 * may use your version of this file under either the MPL or the
 
31
 * GPL.
 
32
 */
 
33
/*
 
34
 * This file implements PKCS 11 on top of our existing security modules
 
35
 *
 
36
 * For more information about PKCS 11 See PKCS 11 Token Inteface Standard.
 
37
 *   This implementation has two slots:
 
38
 *      slot 1 is our generic crypto support. It does not require login
 
39
 *   (unless you've enabled FIPS). It supports Public Key ops, and all they
 
40
 *   bulk ciphers and hashes. It can also support Private Key ops for imported
 
41
 *   Private keys. It does not have any token storage.
 
42
 *      slot 2 is our private key support. It requires a login before use. It
 
43
 *   can store Private Keys and Certs as token objects. Currently only private
 
44
 *   keys and their associated Certificates are saved on the token.
 
45
 *
 
46
 *   In this implementation, session objects are only visible to the session
 
47
 *   that created or generated them.
 
48
 */
 
49
#include "seccomon.h"
 
50
#include "softoken.h"
 
51
#include "lowkeyi.h"
 
52
#include "pcert.h"
 
53
#include "pkcs11.h"
 
54
#include "pkcs11i.h"
 
55
 
 
56
 
 
57
/*
 
58
 * ******************** Password Utilities *******************************
 
59
 */
 
60
static PRBool isLoggedIn = PR_FALSE;
 
61
static PRBool fatalError = PR_FALSE;
 
62
 
 
63
/* Fips required checks before any useful crypto graphic services */
 
64
static CK_RV pk11_fipsCheck(void) {
 
65
    if (isLoggedIn != PR_TRUE) 
 
66
        return CKR_USER_NOT_LOGGED_IN;
 
67
    if (fatalError) 
 
68
        return CKR_DEVICE_ERROR;
 
69
    return CKR_OK;
 
70
}
 
71
 
 
72
 
 
73
#define PK11_FIPSCHECK() \
 
74
    CK_RV rv; \
 
75
    if ((rv = pk11_fipsCheck()) != CKR_OK) return rv;
 
76
 
 
77
#define PK11_FIPSFATALCHECK() \
 
78
    if (fatalError) return CKR_DEVICE_ERROR;
 
79
 
 
80
 
 
81
/* grab an attribute out of a raw template */
 
82
void *
 
83
fc_getAttribute(CK_ATTRIBUTE_PTR pTemplate, 
 
84
                                CK_ULONG ulCount, CK_ATTRIBUTE_TYPE type)
 
85
{
 
86
    int i;
 
87
 
 
88
    for (i=0; i < (int) ulCount; i++) {
 
89
        if (pTemplate[i].type == type) {
 
90
            return pTemplate[i].pValue;
 
91
        }
 
92
    }
 
93
    return NULL;
 
94
}
 
95
 
 
96
 
 
97
#define __PASTE(x,y)    x##y
 
98
 
 
99
/* ------------- forward declare all the NSC_ functions ------------- */
 
100
#undef CK_NEED_ARG_LIST
 
101
#undef CK_PKCS11_FUNCTION_INFO
 
102
 
 
103
#define CK_PKCS11_FUNCTION_INFO(name) CK_RV __PASTE(NS,name)
 
104
#define CK_NEED_ARG_LIST 1
 
105
 
 
106
#include "pkcs11f.h"
 
107
 
 
108
/* ------------- forward declare all the FIPS functions ------------- */
 
109
#undef CK_NEED_ARG_LIST
 
110
#undef CK_PKCS11_FUNCTION_INFO
 
111
 
 
112
#define CK_PKCS11_FUNCTION_INFO(name) CK_RV __PASTE(F,name)
 
113
#define CK_NEED_ARG_LIST 1
 
114
 
 
115
#include "pkcs11f.h"
 
116
 
 
117
/* ------------- build the CK_CRYPTO_TABLE ------------------------- */
 
118
static CK_FUNCTION_LIST pk11_fipsTable = {
 
119
    { 1, 10 },
 
120
 
 
121
#undef CK_NEED_ARG_LIST
 
122
#undef CK_PKCS11_FUNCTION_INFO
 
123
 
 
124
#define CK_PKCS11_FUNCTION_INFO(name) __PASTE(F,name),
 
125
 
 
126
 
 
127
#include "pkcs11f.h"
 
128
 
 
129
};
 
130
 
 
131
#undef CK_NEED_ARG_LIST
 
132
#undef CK_PKCS11_FUNCTION_INFO
 
133
 
 
134
 
 
135
#undef __PASTE
 
136
 
 
137
static CK_RV
 
138
fips_login_if_key_object(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject)
 
139
{
 
140
    CK_RV rv;
 
141
    CK_OBJECT_CLASS objClass;
 
142
    CK_ATTRIBUTE class; 
 
143
    class.type = CKA_CLASS;
 
144
    class.pValue = &objClass;
 
145
    class.ulValueLen = sizeof(objClass);
 
146
    rv = NSC_GetAttributeValue(hSession, hObject, &class, 1);
 
147
    if (rv == CKR_OK) {
 
148
        if ((objClass == CKO_PRIVATE_KEY) || (objClass == CKO_SECRET_KEY)) {
 
149
            rv = pk11_fipsCheck();
 
150
        }
 
151
    }
 
152
    return rv;
 
153
}
 
154
 
 
155
 
 
156
/**********************************************************************
 
157
 *
 
158
 *     Start of PKCS 11 functions 
 
159
 *
 
160
 **********************************************************************/
 
161
/* return the function list */
 
162
CK_RV FC_GetFunctionList(CK_FUNCTION_LIST_PTR *pFunctionList) {
 
163
    *pFunctionList = &pk11_fipsTable;
 
164
    return CKR_OK;
 
165
}
 
166
 
 
167
/* sigh global so pkcs11 can read it */
 
168
PRBool nsf_init = PR_FALSE;
 
169
 
 
170
/* FC_Initialize initializes the PKCS #11 library. */
 
171
CK_RV FC_Initialize(CK_VOID_PTR pReserved) {
 
172
    CK_RV crv;
 
173
 
 
174
    if (nsf_init) {
 
175
        return CKR_CRYPTOKI_ALREADY_INITIALIZED;
 
176
    }
 
177
 
 
178
    crv = nsc_CommonInitialize(pReserved, PR_TRUE);
 
179
 
 
180
    /* not an 'else' rv can be set by either PK11_LowInit or PK11_SlotInit*/
 
181
    if (crv != CKR_OK) {
 
182
        fatalError = PR_TRUE;
 
183
        return crv;
 
184
    }
 
185
 
 
186
    fatalError = PR_FALSE; /* any error has been reset */
 
187
 
 
188
    crv = pk11_fipsPowerUpSelfTest();
 
189
    if (crv != CKR_OK) {
 
190
        nsc_CommonFinalize(NULL, PR_TRUE);
 
191
        fatalError = PR_TRUE;
 
192
        return crv;
 
193
    }
 
194
    nsf_init = PR_TRUE;
 
195
 
 
196
    return CKR_OK;
 
197
}
 
198
 
 
199
/*FC_Finalize indicates that an application is done with the PKCS #11 library.*/
 
200
CK_RV FC_Finalize (CK_VOID_PTR pReserved) {
 
201
   CK_RV crv;
 
202
   if (!nsf_init) {
 
203
      return CKR_OK;
 
204
   }
 
205
   crv = nsc_CommonFinalize (pReserved, PR_TRUE);
 
206
   nsf_init = (PRBool) !(crv == CKR_OK);
 
207
   return crv;
 
208
}
 
209
 
 
210
 
 
211
/* FC_GetInfo returns general information about PKCS #11. */
 
212
CK_RV  FC_GetInfo(CK_INFO_PTR pInfo) {
 
213
    return NSC_GetInfo(pInfo);
 
214
}
 
215
 
 
216
/* FC_GetSlotList obtains a list of slots in the system. */
 
217
CK_RV FC_GetSlotList(CK_BBOOL tokenPresent,
 
218
                        CK_SLOT_ID_PTR pSlotList, CK_ULONG_PTR pulCount) {
 
219
    return nsc_CommonGetSlotList(tokenPresent,pSlotList,pulCount,
 
220
                                                         NSC_FIPS_MODULE);
 
221
}
 
222
        
 
223
/* FC_GetSlotInfo obtains information about a particular slot in the system. */
 
224
CK_RV FC_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo) {
 
225
 
 
226
    CK_RV crv;
 
227
 
 
228
    crv = NSC_GetSlotInfo(slotID,pInfo);
 
229
    if (crv != CKR_OK) {
 
230
        return crv;
 
231
    }
 
232
 
 
233
    return CKR_OK;
 
234
}
 
235
 
 
236
 
 
237
/*FC_GetTokenInfo obtains information about a particular token in the system.*/
 
238
 CK_RV FC_GetTokenInfo(CK_SLOT_ID slotID,CK_TOKEN_INFO_PTR pInfo) {
 
239
    CK_RV crv;
 
240
 
 
241
    crv = NSC_GetTokenInfo(slotID,pInfo);
 
242
    pInfo->flags |= CKF_RNG | CKF_LOGIN_REQUIRED;
 
243
    return crv;
 
244
 
 
245
}
 
246
 
 
247
 
 
248
 
 
249
/*FC_GetMechanismList obtains a list of mechanism types supported by a token.*/
 
250
 CK_RV FC_GetMechanismList(CK_SLOT_ID slotID,
 
251
        CK_MECHANISM_TYPE_PTR pMechanismList, CK_ULONG_PTR pusCount) {
 
252
    PK11_FIPSFATALCHECK();
 
253
    if (slotID == FIPS_SLOT_ID) slotID = NETSCAPE_SLOT_ID;
 
254
    /* FIPS Slot supports all functions */
 
255
    return NSC_GetMechanismList(slotID,pMechanismList,pusCount);
 
256
}
 
257
 
 
258
 
 
259
/* FC_GetMechanismInfo obtains information about a particular mechanism 
 
260
 * possibly supported by a token. */
 
261
 CK_RV FC_GetMechanismInfo(CK_SLOT_ID slotID, CK_MECHANISM_TYPE type,
 
262
                                        CK_MECHANISM_INFO_PTR pInfo) {
 
263
    PK11_FIPSFATALCHECK();
 
264
    if (slotID == FIPS_SLOT_ID) slotID = NETSCAPE_SLOT_ID;
 
265
    /* FIPS Slot supports all functions */
 
266
    return NSC_GetMechanismInfo(slotID,type,pInfo);
 
267
}
 
268
 
 
269
 
 
270
/* FC_InitToken initializes a token. */
 
271
 CK_RV FC_InitToken(CK_SLOT_ID slotID,CK_CHAR_PTR pPin,
 
272
                                CK_ULONG usPinLen,CK_CHAR_PTR pLabel) {
 
273
    return CKR_HOST_MEMORY; /*is this the right function for not implemented*/
 
274
}
 
275
 
 
276
 
 
277
/* FC_InitPIN initializes the normal user's PIN. */
 
278
 CK_RV FC_InitPIN(CK_SESSION_HANDLE hSession,
 
279
                                        CK_CHAR_PTR pPin, CK_ULONG ulPinLen) {
 
280
    return NSC_InitPIN(hSession,pPin,ulPinLen);
 
281
}
 
282
 
 
283
 
 
284
/* FC_SetPIN modifies the PIN of user that is currently logged in. */
 
285
/* NOTE: This is only valid for the PRIVATE_KEY_SLOT */
 
286
 CK_RV FC_SetPIN(CK_SESSION_HANDLE hSession, CK_CHAR_PTR pOldPin,
 
287
    CK_ULONG usOldLen, CK_CHAR_PTR pNewPin, CK_ULONG usNewLen) {
 
288
    CK_RV rv;
 
289
    if ((rv = pk11_fipsCheck()) != CKR_OK) return rv;
 
290
    return NSC_SetPIN(hSession,pOldPin,usOldLen,pNewPin,usNewLen);
 
291
}
 
292
 
 
293
/* FC_OpenSession opens a session between an application and a token. */
 
294
 CK_RV FC_OpenSession(CK_SLOT_ID slotID, CK_FLAGS flags,
 
295
   CK_VOID_PTR pApplication,CK_NOTIFY Notify,CK_SESSION_HANDLE_PTR phSession) {
 
296
    PK11_FIPSFATALCHECK();
 
297
    return NSC_OpenSession(slotID,flags,pApplication,Notify,phSession);
 
298
}
 
299
 
 
300
 
 
301
/* FC_CloseSession closes a session between an application and a token. */
 
302
 CK_RV FC_CloseSession(CK_SESSION_HANDLE hSession) {
 
303
    return NSC_CloseSession(hSession);
 
304
}
 
305
 
 
306
 
 
307
/* FC_CloseAllSessions closes all sessions with a token. */
 
308
 CK_RV FC_CloseAllSessions (CK_SLOT_ID slotID) {
 
309
    return NSC_CloseAllSessions (slotID);
 
310
}
 
311
 
 
312
 
 
313
/* FC_GetSessionInfo obtains information about the session. */
 
314
 CK_RV FC_GetSessionInfo(CK_SESSION_HANDLE hSession,
 
315
                                                CK_SESSION_INFO_PTR pInfo) {
 
316
    CK_RV rv;
 
317
    PK11_FIPSFATALCHECK();
 
318
 
 
319
    rv = NSC_GetSessionInfo(hSession,pInfo);
 
320
    if (rv == CKR_OK) {
 
321
        if ((isLoggedIn) && (pInfo->state == CKS_RO_PUBLIC_SESSION)) {
 
322
                pInfo->state = CKS_RO_USER_FUNCTIONS;
 
323
        }
 
324
        if ((isLoggedIn) && (pInfo->state == CKS_RW_PUBLIC_SESSION)) {
 
325
                pInfo->state = CKS_RW_USER_FUNCTIONS;
 
326
        }
 
327
    }
 
328
    return rv;
 
329
}
 
330
 
 
331
/* FC_Login logs a user into a token. */
 
332
 CK_RV FC_Login(CK_SESSION_HANDLE hSession, CK_USER_TYPE userType,
 
333
                                    CK_CHAR_PTR pPin, CK_ULONG usPinLen) {
 
334
    CK_RV rv;
 
335
    PK11_FIPSFATALCHECK();
 
336
    rv = NSC_Login(hSession,userType,pPin,usPinLen);
 
337
    if (rv == CKR_OK)
 
338
        isLoggedIn = PR_TRUE;
 
339
    else if (rv == CKR_USER_ALREADY_LOGGED_IN)
 
340
    {
 
341
        isLoggedIn = PR_TRUE;
 
342
 
 
343
        /* Provide FIPS PUB 140-1 power-up self-tests on demand. */
 
344
        rv = pk11_fipsPowerUpSelfTest();
 
345
        if (rv == CKR_OK)
 
346
                return CKR_USER_ALREADY_LOGGED_IN;
 
347
        else
 
348
                fatalError = PR_TRUE;
 
349
    }
 
350
    return rv;
 
351
}
 
352
 
 
353
/* FC_Logout logs a user out from a token. */
 
354
 CK_RV FC_Logout(CK_SESSION_HANDLE hSession) {
 
355
    PK11_FIPSCHECK();
 
356
 
 
357
    rv = NSC_Logout(hSession);
 
358
    isLoggedIn = PR_FALSE;
 
359
    return rv;
 
360
}
 
361
 
 
362
 
 
363
/* FC_CreateObject creates a new object. */
 
364
 CK_RV FC_CreateObject(CK_SESSION_HANDLE hSession,
 
365
                CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, 
 
366
                                        CK_OBJECT_HANDLE_PTR phObject) {
 
367
    CK_OBJECT_CLASS * classptr;
 
368
    PK11_FIPSCHECK();
 
369
    classptr = (CK_OBJECT_CLASS *)fc_getAttribute(pTemplate,ulCount,CKA_CLASS);
 
370
    if (classptr == NULL) return CKR_TEMPLATE_INCOMPLETE;
 
371
 
 
372
    /* FIPS can't create keys from raw key material */
 
373
    if ((*classptr == CKO_SECRET_KEY) || (*classptr == CKO_PRIVATE_KEY)) {
 
374
        return CKR_ATTRIBUTE_VALUE_INVALID;
 
375
    }
 
376
    return NSC_CreateObject(hSession,pTemplate,ulCount,phObject);
 
377
}
 
378
 
 
379
 
 
380
 
 
381
 
 
382
 
 
383
/* FC_CopyObject copies an object, creating a new object for the copy. */
 
384
 CK_RV FC_CopyObject(CK_SESSION_HANDLE hSession,
 
385
       CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount,
 
386
                                        CK_OBJECT_HANDLE_PTR phNewObject) {
 
387
    CK_RV rv;
 
388
    PK11_FIPSFATALCHECK();
 
389
    rv = fips_login_if_key_object(hSession, hObject);
 
390
    if (rv != CKR_OK) {
 
391
        return rv;
 
392
    }
 
393
    return NSC_CopyObject(hSession,hObject,pTemplate,usCount,phNewObject);
 
394
}
 
395
 
 
396
 
 
397
/* FC_DestroyObject destroys an object. */
 
398
 CK_RV FC_DestroyObject(CK_SESSION_HANDLE hSession,
 
399
                                                CK_OBJECT_HANDLE hObject) {
 
400
    CK_RV rv;
 
401
    PK11_FIPSFATALCHECK();
 
402
    rv = fips_login_if_key_object(hSession, hObject);
 
403
    if (rv != CKR_OK) {
 
404
        return rv;
 
405
    }
 
406
    return NSC_DestroyObject(hSession,hObject);
 
407
}
 
408
 
 
409
 
 
410
/* FC_GetObjectSize gets the size of an object in bytes. */
 
411
 CK_RV FC_GetObjectSize(CK_SESSION_HANDLE hSession,
 
412
                        CK_OBJECT_HANDLE hObject, CK_ULONG_PTR pusSize) {
 
413
    CK_RV rv;
 
414
    PK11_FIPSFATALCHECK();
 
415
    rv = fips_login_if_key_object(hSession, hObject);
 
416
    if (rv != CKR_OK) {
 
417
        return rv;
 
418
    }
 
419
    return NSC_GetObjectSize(hSession, hObject, pusSize);
 
420
}
 
421
 
 
422
 
 
423
/* FC_GetAttributeValue obtains the value of one or more object attributes. */
 
424
 CK_RV FC_GetAttributeValue(CK_SESSION_HANDLE hSession,
 
425
 CK_OBJECT_HANDLE hObject,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG usCount) {
 
426
    CK_RV rv;
 
427
    PK11_FIPSFATALCHECK();
 
428
    rv = fips_login_if_key_object(hSession, hObject);
 
429
    if (rv != CKR_OK) {
 
430
        return rv;
 
431
    }
 
432
    return NSC_GetAttributeValue(hSession,hObject,pTemplate,usCount);
 
433
}
 
434
 
 
435
 
 
436
/* FC_SetAttributeValue modifies the value of one or more object attributes */
 
437
 CK_RV FC_SetAttributeValue (CK_SESSION_HANDLE hSession,
 
438
 CK_OBJECT_HANDLE hObject,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG usCount) {
 
439
    CK_RV rv;
 
440
    PK11_FIPSFATALCHECK();
 
441
    rv = fips_login_if_key_object(hSession, hObject);
 
442
    if (rv != CKR_OK) {
 
443
        return rv;
 
444
    }
 
445
    return NSC_SetAttributeValue(hSession,hObject,pTemplate,usCount);
 
446
}
 
447
 
 
448
 
 
449
 
 
450
/* FC_FindObjectsInit initializes a search for token and session objects 
 
451
 * that match a template. */
 
452
 CK_RV FC_FindObjectsInit(CK_SESSION_HANDLE hSession,
 
453
                        CK_ATTRIBUTE_PTR pTemplate,CK_ULONG usCount) {
 
454
    /* let publically readable object be found */
 
455
    int i;
 
456
    CK_RV rv;
 
457
    PRBool needLogin = PR_FALSE;
 
458
 
 
459
    PK11_FIPSFATALCHECK();
 
460
 
 
461
    for (i=0; i < usCount; i++) {
 
462
        CK_OBJECT_CLASS class;
 
463
        if (pTemplate[i].type != CKA_CLASS) {
 
464
            continue;
 
465
        }
 
466
        if (pTemplate[i].ulValueLen != sizeof(CK_OBJECT_CLASS)) {
 
467
            continue;
 
468
        }
 
469
        if (pTemplate[i].pValue == NULL) {
 
470
            continue;
 
471
        }
 
472
        class = *(CK_OBJECT_CLASS *)pTemplate[i].pValue;
 
473
        if ((class == CKO_PRIVATE_KEY) || (class == CKO_SECRET_KEY)) {
 
474
            needLogin = PR_TRUE;
 
475
            break;
 
476
        }
 
477
    }
 
478
    if (needLogin) {
 
479
        if ((rv = pk11_fipsCheck()) != CKR_OK) return rv;
 
480
    }
 
481
    return NSC_FindObjectsInit(hSession,pTemplate,usCount);
 
482
}
 
483
 
 
484
 
 
485
/* FC_FindObjects continues a search for token and session objects 
 
486
 * that match a template, obtaining additional object handles. */
 
487
 CK_RV FC_FindObjects(CK_SESSION_HANDLE hSession,
 
488
    CK_OBJECT_HANDLE_PTR phObject,CK_ULONG usMaxObjectCount,
 
489
                                        CK_ULONG_PTR pusObjectCount) {
 
490
    /* let publically readable object be found */
 
491
    PK11_FIPSFATALCHECK();
 
492
    return NSC_FindObjects(hSession,phObject,usMaxObjectCount,
 
493
                                                        pusObjectCount);
 
494
}
 
495
 
 
496
 
 
497
/*
 
498
 ************** Crypto Functions:     Encrypt ************************
 
499
 */
 
500
 
 
501
/* FC_EncryptInit initializes an encryption operation. */
 
502
 CK_RV FC_EncryptInit(CK_SESSION_HANDLE hSession,
 
503
                 CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) {
 
504
    PK11_FIPSCHECK();
 
505
    return NSC_EncryptInit(hSession,pMechanism,hKey);
 
506
}
 
507
 
 
508
/* FC_Encrypt encrypts single-part data. */
 
509
 CK_RV FC_Encrypt (CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData,
 
510
                CK_ULONG usDataLen, CK_BYTE_PTR pEncryptedData,
 
511
                                         CK_ULONG_PTR pusEncryptedDataLen) {
 
512
    PK11_FIPSCHECK();
 
513
    return NSC_Encrypt(hSession,pData,usDataLen,pEncryptedData,
 
514
                                                        pusEncryptedDataLen);
 
515
}
 
516
 
 
517
 
 
518
/* FC_EncryptUpdate continues a multiple-part encryption operation. */
 
519
 CK_RV FC_EncryptUpdate(CK_SESSION_HANDLE hSession,
 
520
    CK_BYTE_PTR pPart, CK_ULONG usPartLen, CK_BYTE_PTR pEncryptedPart,  
 
521
                                        CK_ULONG_PTR pusEncryptedPartLen) {
 
522
    PK11_FIPSCHECK();
 
523
    return NSC_EncryptUpdate(hSession,pPart,usPartLen,pEncryptedPart,
 
524
                                                pusEncryptedPartLen);
 
525
}
 
526
 
 
527
 
 
528
/* FC_EncryptFinal finishes a multiple-part encryption operation. */
 
529
 CK_RV FC_EncryptFinal(CK_SESSION_HANDLE hSession,
 
530
    CK_BYTE_PTR pLastEncryptedPart, CK_ULONG_PTR pusLastEncryptedPartLen) {
 
531
 
 
532
    PK11_FIPSCHECK();
 
533
    return NSC_EncryptFinal(hSession,pLastEncryptedPart,
 
534
                                                pusLastEncryptedPartLen);
 
535
}
 
536
 
 
537
/*
 
538
 ************** Crypto Functions:     Decrypt ************************
 
539
 */
 
540
 
 
541
 
 
542
/* FC_DecryptInit initializes a decryption operation. */
 
543
 CK_RV FC_DecryptInit( CK_SESSION_HANDLE hSession,
 
544
                         CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) {
 
545
    PK11_FIPSCHECK();
 
546
    return NSC_DecryptInit(hSession,pMechanism,hKey);
 
547
}
 
548
 
 
549
/* FC_Decrypt decrypts encrypted data in a single part. */
 
550
 CK_RV FC_Decrypt(CK_SESSION_HANDLE hSession,
 
551
    CK_BYTE_PTR pEncryptedData,CK_ULONG usEncryptedDataLen,CK_BYTE_PTR pData,
 
552
                                                CK_ULONG_PTR pusDataLen) {
 
553
    PK11_FIPSCHECK();
 
554
    return NSC_Decrypt(hSession,pEncryptedData,usEncryptedDataLen,pData,
 
555
                                                                pusDataLen);
 
556
}
 
557
 
 
558
 
 
559
/* FC_DecryptUpdate continues a multiple-part decryption operation. */
 
560
 CK_RV FC_DecryptUpdate(CK_SESSION_HANDLE hSession,
 
561
    CK_BYTE_PTR pEncryptedPart, CK_ULONG usEncryptedPartLen,
 
562
                                CK_BYTE_PTR pPart, CK_ULONG_PTR pusPartLen) {
 
563
    PK11_FIPSCHECK();
 
564
    return NSC_DecryptUpdate(hSession,pEncryptedPart,usEncryptedPartLen,
 
565
                                                        pPart,pusPartLen);
 
566
}
 
567
 
 
568
 
 
569
/* FC_DecryptFinal finishes a multiple-part decryption operation. */
 
570
 CK_RV FC_DecryptFinal(CK_SESSION_HANDLE hSession,
 
571
    CK_BYTE_PTR pLastPart, CK_ULONG_PTR pusLastPartLen) {
 
572
    PK11_FIPSCHECK();
 
573
    return NSC_DecryptFinal(hSession,pLastPart,pusLastPartLen);
 
574
}
 
575
 
 
576
 
 
577
/*
 
578
 ************** Crypto Functions:     Digest (HASH)  ************************
 
579
 */
 
580
 
 
581
/* FC_DigestInit initializes a message-digesting operation. */
 
582
 CK_RV FC_DigestInit(CK_SESSION_HANDLE hSession,
 
583
                                        CK_MECHANISM_PTR pMechanism) {
 
584
    PK11_FIPSFATALCHECK();
 
585
    return NSC_DigestInit(hSession, pMechanism);
 
586
}
 
587
 
 
588
 
 
589
/* FC_Digest digests data in a single part. */
 
590
 CK_RV FC_Digest(CK_SESSION_HANDLE hSession,
 
591
    CK_BYTE_PTR pData, CK_ULONG usDataLen, CK_BYTE_PTR pDigest,
 
592
                                                CK_ULONG_PTR pusDigestLen) {
 
593
    PK11_FIPSFATALCHECK();
 
594
    return NSC_Digest(hSession,pData,usDataLen,pDigest,pusDigestLen);
 
595
}
 
596
 
 
597
 
 
598
/* FC_DigestUpdate continues a multiple-part message-digesting operation. */
 
599
 CK_RV FC_DigestUpdate(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pPart,
 
600
                                            CK_ULONG usPartLen) {
 
601
    PK11_FIPSFATALCHECK();
 
602
    return NSC_DigestUpdate(hSession,pPart,usPartLen);
 
603
}
 
604
 
 
605
 
 
606
/* FC_DigestFinal finishes a multiple-part message-digesting operation. */
 
607
 CK_RV FC_DigestFinal(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pDigest,
 
608
                                                CK_ULONG_PTR pusDigestLen) {
 
609
    PK11_FIPSFATALCHECK();
 
610
    return NSC_DigestFinal(hSession,pDigest,pusDigestLen);
 
611
}
 
612
 
 
613
 
 
614
/*
 
615
 ************** Crypto Functions:     Sign  ************************
 
616
 */
 
617
 
 
618
/* FC_SignInit initializes a signature (private key encryption) operation,
 
619
 * where the signature is (will be) an appendix to the data, 
 
620
 * and plaintext cannot be recovered from the signature */
 
621
 CK_RV FC_SignInit(CK_SESSION_HANDLE hSession,
 
622
                 CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) {
 
623
    PK11_FIPSCHECK();
 
624
    return NSC_SignInit(hSession,pMechanism,hKey);
 
625
}
 
626
 
 
627
 
 
628
/* FC_Sign signs (encrypts with private key) data in a single part,
 
629
 * where the signature is (will be) an appendix to the data, 
 
630
 * and plaintext cannot be recovered from the signature */
 
631
 CK_RV FC_Sign(CK_SESSION_HANDLE hSession,
 
632
    CK_BYTE_PTR pData,CK_ULONG usDataLen,CK_BYTE_PTR pSignature,
 
633
                                        CK_ULONG_PTR pusSignatureLen) {
 
634
    PK11_FIPSCHECK();
 
635
    return NSC_Sign(hSession,pData,usDataLen,pSignature,pusSignatureLen);
 
636
}
 
637
 
 
638
 
 
639
/* FC_SignUpdate continues a multiple-part signature operation,
 
640
 * where the signature is (will be) an appendix to the data, 
 
641
 * and plaintext cannot be recovered from the signature */
 
642
 CK_RV FC_SignUpdate(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pPart,
 
643
                                                        CK_ULONG usPartLen) {
 
644
    PK11_FIPSCHECK();
 
645
    return NSC_SignUpdate(hSession,pPart,usPartLen);
 
646
}
 
647
 
 
648
 
 
649
/* FC_SignFinal finishes a multiple-part signature operation, 
 
650
 * returning the signature. */
 
651
 CK_RV FC_SignFinal(CK_SESSION_HANDLE hSession,CK_BYTE_PTR pSignature,
 
652
                                            CK_ULONG_PTR pusSignatureLen) {
 
653
    PK11_FIPSCHECK();
 
654
    return NSC_SignFinal(hSession,pSignature,pusSignatureLen);
 
655
}
 
656
 
 
657
/*
 
658
 ************** Crypto Functions:     Sign Recover  ************************
 
659
 */
 
660
/* FC_SignRecoverInit initializes a signature operation,
 
661
 * where the (digest) data can be recovered from the signature. 
 
662
 * E.g. encryption with the user's private key */
 
663
 CK_RV FC_SignRecoverInit(CK_SESSION_HANDLE hSession,
 
664
                         CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey) {
 
665
    PK11_FIPSCHECK();
 
666
    return NSC_SignRecoverInit(hSession,pMechanism,hKey);
 
667
}
 
668
 
 
669
 
 
670
/* FC_SignRecover signs data in a single operation
 
671
 * where the (digest) data can be recovered from the signature. 
 
672
 * E.g. encryption with the user's private key */
 
673
 CK_RV FC_SignRecover(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData,
 
674
  CK_ULONG usDataLen, CK_BYTE_PTR pSignature, CK_ULONG_PTR pusSignatureLen) {
 
675
    PK11_FIPSCHECK();
 
676
    return NSC_SignRecover(hSession,pData,usDataLen,pSignature,pusSignatureLen);
 
677
}
 
678
 
 
679
/*
 
680
 ************** Crypto Functions:     verify  ************************
 
681
 */
 
682
 
 
683
/* FC_VerifyInit initializes a verification operation, 
 
684
 * where the signature is an appendix to the data, 
 
685
 * and plaintext cannot be recovered from the signature (e.g. DSA) */
 
686
 CK_RV FC_VerifyInit(CK_SESSION_HANDLE hSession,
 
687
                           CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey) {
 
688
    PK11_FIPSCHECK();
 
689
    return NSC_VerifyInit(hSession,pMechanism,hKey);
 
690
}
 
691
 
 
692
 
 
693
/* FC_Verify verifies a signature in a single-part operation, 
 
694
 * where the signature is an appendix to the data, 
 
695
 * and plaintext cannot be recovered from the signature */
 
696
 CK_RV FC_Verify(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData,
 
697
    CK_ULONG usDataLen, CK_BYTE_PTR pSignature, CK_ULONG usSignatureLen) {
 
698
    /* make sure we're legal */
 
699
    PK11_FIPSCHECK();
 
700
    return NSC_Verify(hSession,pData,usDataLen,pSignature,usSignatureLen);
 
701
}
 
702
 
 
703
 
 
704
/* FC_VerifyUpdate continues a multiple-part verification operation, 
 
705
 * where the signature is an appendix to the data, 
 
706
 * and plaintext cannot be recovered from the signature */
 
707
 CK_RV FC_VerifyUpdate( CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
 
708
                                                CK_ULONG usPartLen) {
 
709
    PK11_FIPSCHECK();
 
710
    return NSC_VerifyUpdate(hSession,pPart,usPartLen);
 
711
}
 
712
 
 
713
 
 
714
/* FC_VerifyFinal finishes a multiple-part verification operation, 
 
715
 * checking the signature. */
 
716
 CK_RV FC_VerifyFinal(CK_SESSION_HANDLE hSession,
 
717
                        CK_BYTE_PTR pSignature,CK_ULONG usSignatureLen) {
 
718
    PK11_FIPSCHECK();
 
719
    return NSC_VerifyFinal(hSession,pSignature,usSignatureLen);
 
720
}
 
721
 
 
722
/*
 
723
 ************** Crypto Functions:     Verify  Recover ************************
 
724
 */
 
725
 
 
726
/* FC_VerifyRecoverInit initializes a signature verification operation, 
 
727
 * where the data is recovered from the signature. 
 
728
 * E.g. Decryption with the user's public key */
 
729
 CK_RV FC_VerifyRecoverInit(CK_SESSION_HANDLE hSession,
 
730
                        CK_MECHANISM_PTR pMechanism,CK_OBJECT_HANDLE hKey) {
 
731
    PK11_FIPSCHECK();
 
732
    return NSC_VerifyRecoverInit(hSession,pMechanism,hKey);
 
733
}
 
734
 
 
735
 
 
736
/* FC_VerifyRecover verifies a signature in a single-part operation, 
 
737
 * where the data is recovered from the signature. 
 
738
 * E.g. Decryption with the user's public key */
 
739
 CK_RV FC_VerifyRecover(CK_SESSION_HANDLE hSession,
 
740
                 CK_BYTE_PTR pSignature,CK_ULONG usSignatureLen,
 
741
                                CK_BYTE_PTR pData,CK_ULONG_PTR pusDataLen) {
 
742
    PK11_FIPSCHECK();
 
743
    return NSC_VerifyRecover(hSession,pSignature,usSignatureLen,pData,
 
744
                                                                pusDataLen);
 
745
}
 
746
 
 
747
/*
 
748
 **************************** Key Functions:  ************************
 
749
 */
 
750
 
 
751
/* FC_GenerateKey generates a secret key, creating a new key object. */
 
752
 CK_RV FC_GenerateKey(CK_SESSION_HANDLE hSession,
 
753
    CK_MECHANISM_PTR pMechanism,CK_ATTRIBUTE_PTR pTemplate,CK_ULONG ulCount,
 
754
                                                CK_OBJECT_HANDLE_PTR phKey) {
 
755
    CK_BBOOL *boolptr;
 
756
 
 
757
    PK11_FIPSCHECK();
 
758
 
 
759
    /* all secret keys must be sensitive, if the upper level code tries to say
 
760
     * otherwise, reject it. */
 
761
    boolptr = (CK_BBOOL *) fc_getAttribute(pTemplate, ulCount, CKA_SENSITIVE);
 
762
    if (boolptr != NULL) {
 
763
        if (!(*boolptr)) {
 
764
            return CKR_ATTRIBUTE_VALUE_INVALID;
 
765
        }
 
766
    }
 
767
 
 
768
    return NSC_GenerateKey(hSession,pMechanism,pTemplate,ulCount,phKey);
 
769
}
 
770
 
 
771
 
 
772
/* FC_GenerateKeyPair generates a public-key/private-key pair, 
 
773
 * creating new key objects. */
 
774
 CK_RV FC_GenerateKeyPair (CK_SESSION_HANDLE hSession,
 
775
    CK_MECHANISM_PTR pMechanism, CK_ATTRIBUTE_PTR pPublicKeyTemplate,
 
776
    CK_ULONG usPublicKeyAttributeCount, CK_ATTRIBUTE_PTR pPrivateKeyTemplate,
 
777
    CK_ULONG usPrivateKeyAttributeCount, CK_OBJECT_HANDLE_PTR phPublicKey,
 
778
                                        CK_OBJECT_HANDLE_PTR phPrivateKey) {
 
779
    CK_BBOOL *boolptr;
 
780
 
 
781
    PK11_FIPSCHECK();
 
782
 
 
783
    /* all private keys must be sensitive, if the upper level code tries to say
 
784
     * otherwise, reject it. */
 
785
    boolptr = (CK_BBOOL *) fc_getAttribute(pPrivateKeyTemplate, 
 
786
                                usPrivateKeyAttributeCount, CKA_SENSITIVE);
 
787
    if (boolptr != NULL) {
 
788
        if (!(*boolptr)) {
 
789
            return CKR_ATTRIBUTE_VALUE_INVALID;
 
790
        }
 
791
    }
 
792
    return NSC_GenerateKeyPair (hSession,pMechanism,pPublicKeyTemplate,
 
793
                usPublicKeyAttributeCount,pPrivateKeyTemplate,
 
794
                usPrivateKeyAttributeCount,phPublicKey,phPrivateKey);
 
795
}
 
796
 
 
797
 
 
798
/* FC_WrapKey wraps (i.e., encrypts) a key. */
 
799
 CK_RV FC_WrapKey(CK_SESSION_HANDLE hSession,
 
800
    CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hWrappingKey,
 
801
    CK_OBJECT_HANDLE hKey, CK_BYTE_PTR pWrappedKey,
 
802
                                         CK_ULONG_PTR pusWrappedKeyLen) {
 
803
    PK11_FIPSCHECK();
 
804
    return NSC_WrapKey(hSession,pMechanism,hWrappingKey,hKey,pWrappedKey,
 
805
                                                        pusWrappedKeyLen);
 
806
}
 
807
 
 
808
 
 
809
/* FC_UnwrapKey unwraps (decrypts) a wrapped key, creating a new key object. */
 
810
 CK_RV FC_UnwrapKey(CK_SESSION_HANDLE hSession,
 
811
    CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hUnwrappingKey,
 
812
    CK_BYTE_PTR pWrappedKey, CK_ULONG usWrappedKeyLen,
 
813
    CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usAttributeCount,
 
814
                                                 CK_OBJECT_HANDLE_PTR phKey) {
 
815
    CK_BBOOL *boolptr;
 
816
 
 
817
    PK11_FIPSCHECK();
 
818
 
 
819
    /* all secret keys must be sensitive, if the upper level code tries to say
 
820
     * otherwise, reject it. */
 
821
    boolptr = (CK_BBOOL *) fc_getAttribute(pTemplate, 
 
822
                                        usAttributeCount, CKA_SENSITIVE);
 
823
    if (boolptr != NULL) {
 
824
        if (!(*boolptr)) {
 
825
            return CKR_ATTRIBUTE_VALUE_INVALID;
 
826
        }
 
827
    }
 
828
    return NSC_UnwrapKey(hSession,pMechanism,hUnwrappingKey,pWrappedKey,
 
829
                        usWrappedKeyLen,pTemplate,usAttributeCount,phKey);
 
830
}
 
831
 
 
832
 
 
833
/* FC_DeriveKey derives a key from a base key, creating a new key object. */
 
834
 CK_RV FC_DeriveKey( CK_SESSION_HANDLE hSession,
 
835
         CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hBaseKey,
 
836
         CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usAttributeCount, 
 
837
                                                CK_OBJECT_HANDLE_PTR phKey) {
 
838
    CK_BBOOL *boolptr;
 
839
 
 
840
    PK11_FIPSCHECK();
 
841
 
 
842
    /* all secret keys must be sensitive, if the upper level code tries to say
 
843
     * otherwise, reject it. */
 
844
    boolptr = (CK_BBOOL *) fc_getAttribute(pTemplate, 
 
845
                                        usAttributeCount, CKA_SENSITIVE);
 
846
    if (boolptr != NULL) {
 
847
        if (!(*boolptr)) {
 
848
            return CKR_ATTRIBUTE_VALUE_INVALID;
 
849
        }
 
850
    }
 
851
    return NSC_DeriveKey(hSession,pMechanism,hBaseKey,pTemplate,
 
852
                        usAttributeCount, phKey);
 
853
}
 
854
 
 
855
/*
 
856
 **************************** Radom Functions:  ************************
 
857
 */
 
858
 
 
859
/* FC_SeedRandom mixes additional seed material into the token's random number 
 
860
 * generator. */
 
861
 CK_RV FC_SeedRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSeed,
 
862
    CK_ULONG usSeedLen) {
 
863
    CK_RV crv;
 
864
 
 
865
    PK11_FIPSFATALCHECK();
 
866
    crv = NSC_SeedRandom(hSession,pSeed,usSeedLen);
 
867
    if (crv != CKR_OK) {
 
868
        fatalError = PR_TRUE;
 
869
    }
 
870
    return crv;
 
871
}
 
872
 
 
873
 
 
874
/* FC_GenerateRandom generates random data. */
 
875
 CK_RV FC_GenerateRandom(CK_SESSION_HANDLE hSession,
 
876
    CK_BYTE_PTR pRandomData, CK_ULONG usRandomLen) {
 
877
    CK_RV crv;
 
878
 
 
879
    PK11_FIPSFATALCHECK();
 
880
    crv = NSC_GenerateRandom(hSession,pRandomData,usRandomLen);
 
881
    if (crv != CKR_OK) {
 
882
        fatalError = PR_TRUE;
 
883
    }
 
884
    return crv;
 
885
}
 
886
 
 
887
 
 
888
/* FC_GetFunctionStatus obtains an updated status of a function running 
 
889
 * in parallel with an application. */
 
890
 CK_RV FC_GetFunctionStatus(CK_SESSION_HANDLE hSession) {
 
891
    PK11_FIPSCHECK();
 
892
    return NSC_GetFunctionStatus(hSession);
 
893
}
 
894
 
 
895
 
 
896
/* FC_CancelFunction cancels a function running in parallel */
 
897
 CK_RV FC_CancelFunction(CK_SESSION_HANDLE hSession) {
 
898
    PK11_FIPSCHECK();
 
899
    return NSC_CancelFunction(hSession);
 
900
}
 
901
 
 
902
/*
 
903
 ****************************  Version 1.1 Functions:  ************************
 
904
 */
 
905
 
 
906
/* FC_GetOperationState saves the state of the cryptographic 
 
907
 *operation in a session. */
 
908
CK_RV FC_GetOperationState(CK_SESSION_HANDLE hSession, 
 
909
        CK_BYTE_PTR  pOperationState, CK_ULONG_PTR pulOperationStateLen) {
 
910
    PK11_FIPSFATALCHECK();
 
911
    return NSC_GetOperationState(hSession,pOperationState,pulOperationStateLen);
 
912
}
 
913
 
 
914
 
 
915
/* FC_SetOperationState restores the state of the cryptographic operation 
 
916
 * in a session. */
 
917
CK_RV FC_SetOperationState(CK_SESSION_HANDLE hSession, 
 
918
        CK_BYTE_PTR  pOperationState, CK_ULONG  ulOperationStateLen,
 
919
        CK_OBJECT_HANDLE hEncryptionKey, CK_OBJECT_HANDLE hAuthenticationKey) {
 
920
    PK11_FIPSFATALCHECK();
 
921
    return NSC_SetOperationState(hSession,pOperationState,ulOperationStateLen,
 
922
                                        hEncryptionKey,hAuthenticationKey);
 
923
}
 
924
 
 
925
/* FC_FindObjectsFinal finishes a search for token and session objects. */
 
926
CK_RV FC_FindObjectsFinal(CK_SESSION_HANDLE hSession) {
 
927
    /* let publically readable object be found */
 
928
    PK11_FIPSFATALCHECK();
 
929
    return NSC_FindObjectsFinal(hSession);
 
930
}
 
931
 
 
932
 
 
933
/* Dual-function cryptographic operations */
 
934
 
 
935
/* FC_DigestEncryptUpdate continues a multiple-part digesting and encryption 
 
936
 * operation. */
 
937
CK_RV FC_DigestEncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR  pPart,
 
938
    CK_ULONG  ulPartLen, CK_BYTE_PTR  pEncryptedPart,
 
939
                                         CK_ULONG_PTR pulEncryptedPartLen) {
 
940
    PK11_FIPSCHECK();
 
941
    return NSC_DigestEncryptUpdate(hSession,pPart,ulPartLen,pEncryptedPart,
 
942
                                         pulEncryptedPartLen);
 
943
}
 
944
 
 
945
 
 
946
/* FC_DecryptDigestUpdate continues a multiple-part decryption and digesting 
 
947
 * operation. */
 
948
CK_RV FC_DecryptDigestUpdate(CK_SESSION_HANDLE hSession,
 
949
     CK_BYTE_PTR  pEncryptedPart, CK_ULONG  ulEncryptedPartLen,
 
950
                                CK_BYTE_PTR  pPart, CK_ULONG_PTR pulPartLen) {
 
951
 
 
952
    PK11_FIPSCHECK();
 
953
    return NSC_DecryptDigestUpdate(hSession, pEncryptedPart,ulEncryptedPartLen,
 
954
                                pPart,pulPartLen);
 
955
}
 
956
 
 
957
/* FC_SignEncryptUpdate continues a multiple-part signing and encryption 
 
958
 * operation. */
 
959
CK_RV FC_SignEncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR  pPart,
 
960
         CK_ULONG  ulPartLen, CK_BYTE_PTR  pEncryptedPart,
 
961
                                         CK_ULONG_PTR pulEncryptedPartLen) {
 
962
 
 
963
    PK11_FIPSCHECK();
 
964
    return NSC_SignEncryptUpdate(hSession,pPart,ulPartLen,pEncryptedPart,
 
965
                                         pulEncryptedPartLen);
 
966
}
 
967
 
 
968
/* FC_DecryptVerifyUpdate continues a multiple-part decryption and verify 
 
969
 * operation. */
 
970
CK_RV FC_DecryptVerifyUpdate(CK_SESSION_HANDLE hSession, 
 
971
        CK_BYTE_PTR  pEncryptedData, CK_ULONG  ulEncryptedDataLen, 
 
972
                                CK_BYTE_PTR  pData, CK_ULONG_PTR pulDataLen) {
 
973
 
 
974
    PK11_FIPSCHECK();
 
975
    return NSC_DecryptVerifyUpdate(hSession,pEncryptedData,ulEncryptedDataLen, 
 
976
                                pData,pulDataLen);
 
977
}
 
978
 
 
979
 
 
980
/* FC_DigestKey continues a multi-part message-digesting operation,
 
981
 * by digesting the value of a secret key as part of the data already digested.
 
982
 */
 
983
CK_RV FC_DigestKey(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hKey) {
 
984
    PK11_FIPSCHECK();
 
985
    return NSC_DigestKey(hSession,hKey);
 
986
}
 
987
 
 
988
 
 
989
CK_RV FC_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot,
 
990
                                                         CK_VOID_PTR pReserved)
 
991
{
 
992
    return NSC_WaitForSlotEvent(flags, pSlot, pReserved);
 
993
}