|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #include "builtins.h" |
|
6 |
|
7 /* |
|
8 * builtins/session.c |
|
9 * |
|
10 * This file implements the NSSCKMDSession object for the |
|
11 * "builtin objects" cryptoki module. |
|
12 */ |
|
13 |
|
14 static NSSCKMDFindObjects * |
|
15 builtins_mdSession_FindObjectsInit |
|
16 ( |
|
17 NSSCKMDSession *mdSession, |
|
18 NSSCKFWSession *fwSession, |
|
19 NSSCKMDToken *mdToken, |
|
20 NSSCKFWToken *fwToken, |
|
21 NSSCKMDInstance *mdInstance, |
|
22 NSSCKFWInstance *fwInstance, |
|
23 CK_ATTRIBUTE_PTR pTemplate, |
|
24 CK_ULONG ulAttributeCount, |
|
25 CK_RV *pError |
|
26 ) |
|
27 { |
|
28 return nss_builtins_FindObjectsInit(fwSession, pTemplate, ulAttributeCount, pError); |
|
29 } |
|
30 |
|
31 NSS_IMPLEMENT NSSCKMDSession * |
|
32 nss_builtins_CreateSession |
|
33 ( |
|
34 NSSCKFWSession *fwSession, |
|
35 CK_RV *pError |
|
36 ) |
|
37 { |
|
38 NSSArena *arena; |
|
39 NSSCKMDSession *rv; |
|
40 |
|
41 arena = NSSCKFWSession_GetArena(fwSession, pError); |
|
42 if( (NSSArena *)NULL == arena ) { |
|
43 return (NSSCKMDSession *)NULL; |
|
44 } |
|
45 |
|
46 rv = nss_ZNEW(arena, NSSCKMDSession); |
|
47 if( (NSSCKMDSession *)NULL == rv ) { |
|
48 *pError = CKR_HOST_MEMORY; |
|
49 return (NSSCKMDSession *)NULL; |
|
50 } |
|
51 |
|
52 /* |
|
53 * rv was zeroed when allocated, so we only |
|
54 * need to set the non-zero members. |
|
55 */ |
|
56 |
|
57 rv->etc = (void *)fwSession; |
|
58 /* rv->Close */ |
|
59 /* rv->GetDeviceError */ |
|
60 /* rv->Login */ |
|
61 /* rv->Logout */ |
|
62 /* rv->InitPIN */ |
|
63 /* rv->SetPIN */ |
|
64 /* rv->GetOperationStateLen */ |
|
65 /* rv->GetOperationState */ |
|
66 /* rv->SetOperationState */ |
|
67 /* rv->CreateObject */ |
|
68 /* rv->CopyObject */ |
|
69 rv->FindObjectsInit = builtins_mdSession_FindObjectsInit; |
|
70 /* rv->SeedRandom */ |
|
71 /* rv->GetRandom */ |
|
72 /* rv->null */ |
|
73 |
|
74 return rv; |
|
75 } |