|
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 "ckmk.h" |
|
6 |
|
7 /* |
|
8 * nssmkey/msession.c |
|
9 * |
|
10 * This file implements the NSSCKMDSession object for the |
|
11 * "nssmkey" cryptoki module. |
|
12 */ |
|
13 |
|
14 static NSSCKMDFindObjects * |
|
15 ckmk_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_ckmk_FindObjectsInit(fwSession, pTemplate, ulAttributeCount, pError); |
|
29 } |
|
30 |
|
31 static NSSCKMDObject * |
|
32 ckmk_mdSession_CreateObject |
|
33 ( |
|
34 NSSCKMDSession *mdSession, |
|
35 NSSCKFWSession *fwSession, |
|
36 NSSCKMDToken *mdToken, |
|
37 NSSCKFWToken *fwToken, |
|
38 NSSCKMDInstance *mdInstance, |
|
39 NSSCKFWInstance *fwInstance, |
|
40 NSSArena *arena, |
|
41 CK_ATTRIBUTE_PTR pTemplate, |
|
42 CK_ULONG ulAttributeCount, |
|
43 CK_RV *pError |
|
44 ) |
|
45 { |
|
46 return nss_ckmk_CreateObject(fwSession, pTemplate, ulAttributeCount, pError); |
|
47 } |
|
48 |
|
49 NSS_IMPLEMENT NSSCKMDSession * |
|
50 nss_ckmk_CreateSession |
|
51 ( |
|
52 NSSCKFWSession *fwSession, |
|
53 CK_RV *pError |
|
54 ) |
|
55 { |
|
56 NSSArena *arena; |
|
57 NSSCKMDSession *rv; |
|
58 |
|
59 arena = NSSCKFWSession_GetArena(fwSession, pError); |
|
60 if( (NSSArena *)NULL == arena ) { |
|
61 return (NSSCKMDSession *)NULL; |
|
62 } |
|
63 |
|
64 rv = nss_ZNEW(arena, NSSCKMDSession); |
|
65 if( (NSSCKMDSession *)NULL == rv ) { |
|
66 *pError = CKR_HOST_MEMORY; |
|
67 return (NSSCKMDSession *)NULL; |
|
68 } |
|
69 |
|
70 /* |
|
71 * rv was zeroed when allocated, so we only |
|
72 * need to set the non-zero members. |
|
73 */ |
|
74 |
|
75 rv->etc = (void *)fwSession; |
|
76 /* rv->Close */ |
|
77 /* rv->GetDeviceError */ |
|
78 /* rv->Login */ |
|
79 /* rv->Logout */ |
|
80 /* rv->InitPIN */ |
|
81 /* rv->SetPIN */ |
|
82 /* rv->GetOperationStateLen */ |
|
83 /* rv->GetOperationState */ |
|
84 /* rv->SetOperationState */ |
|
85 rv->CreateObject = ckmk_mdSession_CreateObject; |
|
86 /* rv->CopyObject */ |
|
87 rv->FindObjectsInit = ckmk_mdSession_FindObjectsInit; |
|
88 /* rv->SeedRandom */ |
|
89 /* rv->GetRandom */ |
|
90 /* rv->null */ |
|
91 |
|
92 return rv; |
|
93 } |