OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 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 | 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/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 #include "ckmk.h" | 5 #include "ckmk.h" |
6 | 6 |
7 /* | 7 /* |
8 * nssmkey/msession.c | 8 * nssmkey/msession.c |
9 * | 9 * |
10 * This file implements the NSSCKMDSession object for the | 10 * This file implements the NSSCKMDSession object for the |
11 * "nssmkey" cryptoki module. | 11 * "nssmkey" cryptoki module. |
12 */ | 12 */ |
13 | 13 |
14 static NSSCKMDFindObjects * | 14 static NSSCKMDFindObjects *ckmk_mdSession_FindObjectsInit( |
15 ckmk_mdSession_FindObjectsInit | 15 NSSCKMDSession *mdSession, NSSCKFWSession *fwSession, NSSCKMDToken *mdToken, |
16 ( | 16 NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, |
17 NSSCKMDSession *mdSession, | 17 NSSCKFWInstance *fwInstance, CK_ATTRIBUTE_PTR pTemplate, |
18 NSSCKFWSession *fwSession, | 18 CK_ULONG ulAttributeCount, CK_RV *pError) { |
19 NSSCKMDToken *mdToken, | 19 return nss_ckmk_FindObjectsInit(fwSession, pTemplate, ulAttributeCount, |
20 NSSCKFWToken *fwToken, | 20 pError); |
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 } | 21 } |
30 | 22 |
31 static NSSCKMDObject * | 23 static NSSCKMDObject *ckmk_mdSession_CreateObject( |
32 ckmk_mdSession_CreateObject | 24 NSSCKMDSession *mdSession, NSSCKFWSession *fwSession, NSSCKMDToken *mdToken, |
33 ( | 25 NSSCKFWToken *fwToken, NSSCKMDInstance *mdInstance, |
34 NSSCKMDSession *mdSession, | 26 NSSCKFWInstance *fwInstance, NSSArena *arena, CK_ATTRIBUTE_PTR pTemplate, |
35 NSSCKFWSession *fwSession, | 27 CK_ULONG ulAttributeCount, CK_RV *pError) { |
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); | 28 return nss_ckmk_CreateObject(fwSession, pTemplate, ulAttributeCount, pError); |
47 } | 29 } |
48 | 30 |
49 NSS_IMPLEMENT NSSCKMDSession * | 31 NSS_IMPLEMENT NSSCKMDSession *nss_ckmk_CreateSession(NSSCKFWSession *fwSession, |
50 nss_ckmk_CreateSession | 32 CK_RV *pError) { |
51 ( | |
52 NSSCKFWSession *fwSession, | |
53 CK_RV *pError | |
54 ) | |
55 { | |
56 NSSArena *arena; | 33 NSSArena *arena; |
57 NSSCKMDSession *rv; | 34 NSSCKMDSession *rv; |
58 | 35 |
59 arena = NSSCKFWSession_GetArena(fwSession, pError); | 36 arena = NSSCKFWSession_GetArena(fwSession, pError); |
60 if( (NSSArena *)NULL == arena ) { | 37 if ((NSSArena *)NULL == arena) { |
61 return (NSSCKMDSession *)NULL; | 38 return (NSSCKMDSession *)NULL; |
62 } | 39 } |
63 | 40 |
64 rv = nss_ZNEW(arena, NSSCKMDSession); | 41 rv = nss_ZNEW(arena, NSSCKMDSession); |
65 if( (NSSCKMDSession *)NULL == rv ) { | 42 if ((NSSCKMDSession *)NULL == rv) { |
66 *pError = CKR_HOST_MEMORY; | 43 *pError = CKR_HOST_MEMORY; |
67 return (NSSCKMDSession *)NULL; | 44 return (NSSCKMDSession *)NULL; |
68 } | 45 } |
69 | 46 |
70 /* | 47 /* |
71 * rv was zeroed when allocated, so we only | 48 * rv was zeroed when allocated, so we only |
72 * need to set the non-zero members. | 49 * need to set the non-zero members. |
73 */ | 50 */ |
74 | 51 |
75 rv->etc = (void *)fwSession; | 52 rv->etc = (void *)fwSession; |
76 /* rv->Close */ | 53 /* rv->Close */ |
77 /* rv->GetDeviceError */ | 54 /* rv->GetDeviceError */ |
78 /* rv->Login */ | 55 /* rv->Login */ |
79 /* rv->Logout */ | 56 /* rv->Logout */ |
80 /* rv->InitPIN */ | 57 /* rv->InitPIN */ |
81 /* rv->SetPIN */ | 58 /* rv->SetPIN */ |
82 /* rv->GetOperationStateLen */ | 59 /* rv->GetOperationStateLen */ |
83 /* rv->GetOperationState */ | 60 /* rv->GetOperationState */ |
84 /* rv->SetOperationState */ | 61 /* rv->SetOperationState */ |
85 rv->CreateObject = ckmk_mdSession_CreateObject; | 62 rv->CreateObject = ckmk_mdSession_CreateObject; |
86 /* rv->CopyObject */ | 63 /* rv->CopyObject */ |
87 rv->FindObjectsInit = ckmk_mdSession_FindObjectsInit; | 64 rv->FindObjectsInit = ckmk_mdSession_FindObjectsInit; |
88 /* rv->SeedRandom */ | 65 /* rv->SeedRandom */ |
89 /* rv->GetRandom */ | 66 /* rv->GetRandom */ |
90 /* rv->null */ | 67 /* rv->null */ |
91 | 68 |
92 return rv; | 69 return rv; |
93 } | 70 } |
OLD | NEW |