comparison nss/lib/ckfw/builtins/bobject.c @ 0:1e5118fa0cb1

This is NSS with a Cmake Buildsyste To compile a static NSS library for Windows we've used the Chromium-NSS fork and added a Cmake buildsystem to compile it statically for Windows. See README.chromium for chromium changes and README.trustbridge for our modifications.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 28 Jul 2014 10:47:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e5118fa0cb1
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/object.c
9 *
10 * This file implements the NSSCKMDObject object for the
11 * "builtin objects" cryptoki module.
12 */
13
14 /*
15 * Finalize - unneeded
16 * Destroy - CKR_SESSION_READ_ONLY
17 * IsTokenObject - CK_TRUE
18 * GetAttributeCount
19 * GetAttributeTypes
20 * GetAttributeSize
21 * GetAttribute
22 * SetAttribute - unneeded
23 * GetObjectSize
24 */
25
26 static CK_RV
27 builtins_mdObject_Destroy
28 (
29 NSSCKMDObject *mdObject,
30 NSSCKFWObject *fwObject,
31 NSSCKMDSession *mdSession,
32 NSSCKFWSession *fwSession,
33 NSSCKMDToken *mdToken,
34 NSSCKFWToken *fwToken,
35 NSSCKMDInstance *mdInstance,
36 NSSCKFWInstance *fwInstance
37 )
38 {
39 return CKR_SESSION_READ_ONLY;
40 }
41
42 static CK_BBOOL
43 builtins_mdObject_IsTokenObject
44 (
45 NSSCKMDObject *mdObject,
46 NSSCKFWObject *fwObject,
47 NSSCKMDSession *mdSession,
48 NSSCKFWSession *fwSession,
49 NSSCKMDToken *mdToken,
50 NSSCKFWToken *fwToken,
51 NSSCKMDInstance *mdInstance,
52 NSSCKFWInstance *fwInstance
53 )
54 {
55 return CK_TRUE;
56 }
57
58 static CK_ULONG
59 builtins_mdObject_GetAttributeCount
60 (
61 NSSCKMDObject *mdObject,
62 NSSCKFWObject *fwObject,
63 NSSCKMDSession *mdSession,
64 NSSCKFWSession *fwSession,
65 NSSCKMDToken *mdToken,
66 NSSCKFWToken *fwToken,
67 NSSCKMDInstance *mdInstance,
68 NSSCKFWInstance *fwInstance,
69 CK_RV *pError
70 )
71 {
72 builtinsInternalObject *io = (builtinsInternalObject *)mdObject->etc;
73 return io->n;
74 }
75
76 static CK_RV
77 builtins_mdObject_GetAttributeTypes
78 (
79 NSSCKMDObject *mdObject,
80 NSSCKFWObject *fwObject,
81 NSSCKMDSession *mdSession,
82 NSSCKFWSession *fwSession,
83 NSSCKMDToken *mdToken,
84 NSSCKFWToken *fwToken,
85 NSSCKMDInstance *mdInstance,
86 NSSCKFWInstance *fwInstance,
87 CK_ATTRIBUTE_TYPE_PTR typeArray,
88 CK_ULONG ulCount
89 )
90 {
91 builtinsInternalObject *io = (builtinsInternalObject *)mdObject->etc;
92 CK_ULONG i;
93
94 if( io->n != ulCount ) {
95 return CKR_BUFFER_TOO_SMALL;
96 }
97
98 for( i = 0; i < io->n; i++ ) {
99 typeArray[i] = io->types[i];
100 }
101
102 return CKR_OK;
103 }
104
105 static CK_ULONG
106 builtins_mdObject_GetAttributeSize
107 (
108 NSSCKMDObject *mdObject,
109 NSSCKFWObject *fwObject,
110 NSSCKMDSession *mdSession,
111 NSSCKFWSession *fwSession,
112 NSSCKMDToken *mdToken,
113 NSSCKFWToken *fwToken,
114 NSSCKMDInstance *mdInstance,
115 NSSCKFWInstance *fwInstance,
116 CK_ATTRIBUTE_TYPE attribute,
117 CK_RV *pError
118 )
119 {
120 builtinsInternalObject *io = (builtinsInternalObject *)mdObject->etc;
121 CK_ULONG i;
122
123 for( i = 0; i < io->n; i++ ) {
124 if( attribute == io->types[i] ) {
125 return (CK_ULONG)(io->items[i].size);
126 }
127 }
128
129 *pError = CKR_ATTRIBUTE_TYPE_INVALID;
130 return 0;
131 }
132
133 static NSSCKFWItem
134 builtins_mdObject_GetAttribute
135 (
136 NSSCKMDObject *mdObject,
137 NSSCKFWObject *fwObject,
138 NSSCKMDSession *mdSession,
139 NSSCKFWSession *fwSession,
140 NSSCKMDToken *mdToken,
141 NSSCKFWToken *fwToken,
142 NSSCKMDInstance *mdInstance,
143 NSSCKFWInstance *fwInstance,
144 CK_ATTRIBUTE_TYPE attribute,
145 CK_RV *pError
146 )
147 {
148 NSSCKFWItem mdItem;
149 builtinsInternalObject *io = (builtinsInternalObject *)mdObject->etc;
150 CK_ULONG i;
151
152 mdItem.needsFreeing = PR_FALSE;
153 mdItem.item = (NSSItem*) NULL;
154
155 for( i = 0; i < io->n; i++ ) {
156 if( attribute == io->types[i] ) {
157 mdItem.item = (NSSItem*) &io->items[i];
158 return mdItem;
159 }
160 }
161
162 *pError = CKR_ATTRIBUTE_TYPE_INVALID;
163 return mdItem;
164 }
165
166 static CK_ULONG
167 builtins_mdObject_GetObjectSize
168 (
169 NSSCKMDObject *mdObject,
170 NSSCKFWObject *fwObject,
171 NSSCKMDSession *mdSession,
172 NSSCKFWSession *fwSession,
173 NSSCKMDToken *mdToken,
174 NSSCKFWToken *fwToken,
175 NSSCKMDInstance *mdInstance,
176 NSSCKFWInstance *fwInstance,
177 CK_RV *pError
178 )
179 {
180 builtinsInternalObject *io = (builtinsInternalObject *)mdObject->etc;
181 CK_ULONG i;
182 CK_ULONG rv = sizeof(CK_ULONG);
183
184 for( i = 0; i < io->n; i++ ) {
185 rv += sizeof(CK_ATTRIBUTE_TYPE) + sizeof(NSSItem) + io->items[i].size;
186 }
187
188 return rv;
189 }
190
191 static const NSSCKMDObject
192 builtins_prototype_mdObject = {
193 (void *)NULL, /* etc */
194 NULL, /* Finalize */
195 builtins_mdObject_Destroy,
196 builtins_mdObject_IsTokenObject,
197 builtins_mdObject_GetAttributeCount,
198 builtins_mdObject_GetAttributeTypes,
199 builtins_mdObject_GetAttributeSize,
200 builtins_mdObject_GetAttribute,
201 NULL, /* FreeAttribute */
202 NULL, /* SetAttribute */
203 builtins_mdObject_GetObjectSize,
204 (void *)NULL /* null terminator */
205 };
206
207 NSS_IMPLEMENT NSSCKMDObject *
208 nss_builtins_CreateMDObject
209 (
210 NSSArena *arena,
211 builtinsInternalObject *io,
212 CK_RV *pError
213 )
214 {
215 if ( (void*)NULL == io->mdObject.etc) {
216 (void) nsslibc_memcpy(&io->mdObject,&builtins_prototype_mdObject,
217 sizeof(builtins_prototype_mdObject));
218 io->mdObject.etc = (void *)io;
219 }
220
221 return &io->mdObject;
222 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)