comparison nss/lib/ckfw/crypto.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 /*
6 * crypto.c
7 *
8 * This file implements the NSSCKFWCryptoOperation type and methods.
9 */
10
11 #ifndef CK_T
12 #include "ck.h"
13 #endif /* CK_T */
14
15 /*
16 * NSSCKFWCryptoOperation
17 *
18 * -- create/destroy --
19 * nssCKFWCrytoOperation_Create
20 * nssCKFWCryptoOperation_Destroy
21 *
22 * -- implement public accessors --
23 * nssCKFWCryptoOperation_GetMDCryptoOperation
24 * nssCKFWCryptoOperation_GetType
25 *
26 * -- private accessors --
27 *
28 * -- module fronts --
29 * nssCKFWCryptoOperation_GetFinalLength
30 * nssCKFWCryptoOperation_GetOperationLength
31 * nssCKFWCryptoOperation_Final
32 * nssCKFWCryptoOperation_Update
33 * nssCKFWCryptoOperation_DigestUpdate
34 * nssCKFWCryptoOperation_UpdateFinal
35 */
36
37 struct NSSCKFWCryptoOperationStr {
38 /* NSSArena *arena; */
39 NSSCKMDCryptoOperation *mdOperation;
40 NSSCKMDSession *mdSession;
41 NSSCKFWSession *fwSession;
42 NSSCKMDToken *mdToken;
43 NSSCKFWToken *fwToken;
44 NSSCKMDInstance *mdInstance;
45 NSSCKFWInstance *fwInstance;
46 NSSCKFWCryptoOperationType type;
47 };
48
49 /*
50 * nssCKFWCrytoOperation_Create
51 */
52 NSS_EXTERN NSSCKFWCryptoOperation *
53 nssCKFWCryptoOperation_Create(
54 NSSCKMDCryptoOperation *mdOperation,
55 NSSCKMDSession *mdSession,
56 NSSCKFWSession *fwSession,
57 NSSCKMDToken *mdToken,
58 NSSCKFWToken *fwToken,
59 NSSCKMDInstance *mdInstance,
60 NSSCKFWInstance *fwInstance,
61 NSSCKFWCryptoOperationType type,
62 CK_RV *pError
63 )
64 {
65 NSSCKFWCryptoOperation *fwOperation;
66 fwOperation = nss_ZNEW(NULL, NSSCKFWCryptoOperation);
67 if (!fwOperation) {
68 *pError = CKR_HOST_MEMORY;
69 return (NSSCKFWCryptoOperation *)NULL;
70 }
71 fwOperation->mdOperation = mdOperation;
72 fwOperation->mdSession = mdSession;
73 fwOperation->fwSession = fwSession;
74 fwOperation->mdToken = mdToken;
75 fwOperation->fwToken = fwToken;
76 fwOperation->mdInstance = mdInstance;
77 fwOperation->fwInstance = fwInstance;
78 fwOperation->type = type;
79 return fwOperation;
80 }
81
82 /*
83 * nssCKFWCryptoOperation_Destroy
84 */
85 NSS_EXTERN void
86 nssCKFWCryptoOperation_Destroy
87 (
88 NSSCKFWCryptoOperation *fwOperation
89 )
90 {
91 if ((NSSCKMDCryptoOperation *) NULL != fwOperation->mdOperation) {
92 if (fwOperation->mdOperation->Destroy) {
93 fwOperation->mdOperation->Destroy(
94 fwOperation->mdOperation,
95 fwOperation,
96 fwOperation->mdInstance,
97 fwOperation->fwInstance);
98 }
99 }
100 nss_ZFreeIf(fwOperation);
101 }
102
103 /*
104 * nssCKFWCryptoOperation_GetMDCryptoOperation
105 */
106 NSS_EXTERN NSSCKMDCryptoOperation *
107 nssCKFWCryptoOperation_GetMDCryptoOperation
108 (
109 NSSCKFWCryptoOperation *fwOperation
110 )
111 {
112 return fwOperation->mdOperation;
113 }
114
115 /*
116 * nssCKFWCryptoOperation_GetType
117 */
118 NSS_EXTERN NSSCKFWCryptoOperationType
119 nssCKFWCryptoOperation_GetType
120 (
121 NSSCKFWCryptoOperation *fwOperation
122 )
123 {
124 return fwOperation->type;
125 }
126
127 /*
128 * nssCKFWCryptoOperation_GetFinalLength
129 */
130 NSS_EXTERN CK_ULONG
131 nssCKFWCryptoOperation_GetFinalLength
132 (
133 NSSCKFWCryptoOperation *fwOperation,
134 CK_RV *pError
135 )
136 {
137 if (!fwOperation->mdOperation->GetFinalLength) {
138 *pError = CKR_FUNCTION_FAILED;
139 return 0;
140 }
141 return fwOperation->mdOperation->GetFinalLength(
142 fwOperation->mdOperation,
143 fwOperation,
144 fwOperation->mdSession,
145 fwOperation->fwSession,
146 fwOperation->mdToken,
147 fwOperation->fwToken,
148 fwOperation->mdInstance,
149 fwOperation->fwInstance,
150 pError);
151 }
152
153 /*
154 * nssCKFWCryptoOperation_GetOperationLength
155 */
156 NSS_EXTERN CK_ULONG
157 nssCKFWCryptoOperation_GetOperationLength
158 (
159 NSSCKFWCryptoOperation *fwOperation,
160 NSSItem *inputBuffer,
161 CK_RV *pError
162 )
163 {
164 if (!fwOperation->mdOperation->GetOperationLength) {
165 *pError = CKR_FUNCTION_FAILED;
166 return 0;
167 }
168 return fwOperation->mdOperation->GetOperationLength(
169 fwOperation->mdOperation,
170 fwOperation,
171 fwOperation->mdSession,
172 fwOperation->fwSession,
173 fwOperation->mdToken,
174 fwOperation->fwToken,
175 fwOperation->mdInstance,
176 fwOperation->fwInstance,
177 inputBuffer,
178 pError);
179 }
180
181 /*
182 * nssCKFWCryptoOperation_Final
183 */
184 NSS_EXTERN CK_RV
185 nssCKFWCryptoOperation_Final
186 (
187 NSSCKFWCryptoOperation *fwOperation,
188 NSSItem *outputBuffer
189 )
190 {
191 if (!fwOperation->mdOperation->Final) {
192 return CKR_FUNCTION_FAILED;
193 }
194 return fwOperation->mdOperation->Final(
195 fwOperation->mdOperation,
196 fwOperation,
197 fwOperation->mdSession,
198 fwOperation->fwSession,
199 fwOperation->mdToken,
200 fwOperation->fwToken,
201 fwOperation->mdInstance,
202 fwOperation->fwInstance,
203 outputBuffer);
204 }
205
206 /*
207 * nssCKFWCryptoOperation_Update
208 */
209 NSS_EXTERN CK_RV
210 nssCKFWCryptoOperation_Update
211 (
212 NSSCKFWCryptoOperation *fwOperation,
213 NSSItem *inputBuffer,
214 NSSItem *outputBuffer
215 )
216 {
217 if (!fwOperation->mdOperation->Update) {
218 return CKR_FUNCTION_FAILED;
219 }
220 return fwOperation->mdOperation->Update(
221 fwOperation->mdOperation,
222 fwOperation,
223 fwOperation->mdSession,
224 fwOperation->fwSession,
225 fwOperation->mdToken,
226 fwOperation->fwToken,
227 fwOperation->mdInstance,
228 fwOperation->fwInstance,
229 inputBuffer,
230 outputBuffer);
231 }
232
233 /*
234 * nssCKFWCryptoOperation_DigestUpdate
235 */
236 NSS_EXTERN CK_RV
237 nssCKFWCryptoOperation_DigestUpdate
238 (
239 NSSCKFWCryptoOperation *fwOperation,
240 NSSItem *inputBuffer
241 )
242 {
243 if (!fwOperation->mdOperation->DigestUpdate) {
244 return CKR_FUNCTION_FAILED;
245 }
246 return fwOperation->mdOperation->DigestUpdate(
247 fwOperation->mdOperation,
248 fwOperation,
249 fwOperation->mdSession,
250 fwOperation->fwSession,
251 fwOperation->mdToken,
252 fwOperation->fwToken,
253 fwOperation->mdInstance,
254 fwOperation->fwInstance,
255 inputBuffer);
256 }
257
258 /*
259 * nssCKFWCryptoOperation_DigestKey
260 */
261 NSS_EXTERN CK_RV
262 nssCKFWCryptoOperation_DigestKey
263 (
264 NSSCKFWCryptoOperation *fwOperation,
265 NSSCKFWObject *fwObject /* Key */
266 )
267 {
268 NSSCKMDObject *mdObject;
269
270 if (!fwOperation->mdOperation->DigestKey) {
271 return CKR_FUNCTION_FAILED;
272 }
273 mdObject = nssCKFWObject_GetMDObject(fwObject);
274 return fwOperation->mdOperation->DigestKey(
275 fwOperation->mdOperation,
276 fwOperation,
277 fwOperation->mdToken,
278 fwOperation->fwToken,
279 fwOperation->mdInstance,
280 fwOperation->fwInstance,
281 mdObject,
282 fwObject);
283 }
284
285 /*
286 * nssCKFWCryptoOperation_UpdateFinal
287 */
288 NSS_EXTERN CK_RV
289 nssCKFWCryptoOperation_UpdateFinal
290 (
291 NSSCKFWCryptoOperation *fwOperation,
292 NSSItem *inputBuffer,
293 NSSItem *outputBuffer
294 )
295 {
296 if (!fwOperation->mdOperation->UpdateFinal) {
297 return CKR_FUNCTION_FAILED;
298 }
299 return fwOperation->mdOperation->UpdateFinal(
300 fwOperation->mdOperation,
301 fwOperation,
302 fwOperation->mdSession,
303 fwOperation->fwSession,
304 fwOperation->mdToken,
305 fwOperation->fwToken,
306 fwOperation->mdInstance,
307 fwOperation->fwInstance,
308 inputBuffer,
309 outputBuffer);
310 }
311
312 /*
313 * nssCKFWCryptoOperation_UpdateCombo
314 */
315 NSS_EXTERN CK_RV
316 nssCKFWCryptoOperation_UpdateCombo
317 (
318 NSSCKFWCryptoOperation *fwOperation,
319 NSSCKFWCryptoOperation *fwPeerOperation,
320 NSSItem *inputBuffer,
321 NSSItem *outputBuffer
322 )
323 {
324 if (!fwOperation->mdOperation->UpdateCombo) {
325 return CKR_FUNCTION_FAILED;
326 }
327 return fwOperation->mdOperation->UpdateCombo(
328 fwOperation->mdOperation,
329 fwOperation,
330 fwPeerOperation->mdOperation,
331 fwPeerOperation,
332 fwOperation->mdSession,
333 fwOperation->fwSession,
334 fwOperation->mdToken,
335 fwOperation->fwToken,
336 fwOperation->mdInstance,
337 fwOperation->fwInstance,
338 inputBuffer,
339 outputBuffer);
340 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)