|
1 /** |
|
2 * XML Security Library (http://www.aleksey.com/xmlsec). |
|
3 * |
|
4 * |
|
5 * This is free software; see Copyright file in the source |
|
6 * distribution for preciese wording. |
|
7 * |
|
8 * Copyright (C) 2002-2003 Aleksey Sanin <aleksey@aleksey.com> |
|
9 * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
10 */ |
|
11 #include "xmlsec_globals.h" |
|
12 |
|
13 #include <stdlib.h> |
|
14 #include <stdio.h> |
|
15 #include <stdarg.h> |
|
16 #include <string.h> |
|
17 #include <time.h> |
|
18 |
|
19 #include <libxml2_tree.h> |
|
20 |
|
21 #include "xmlsec_xmlsec.h" |
|
22 #include "xmlsec_app.h" |
|
23 #include "xmlsec_list.h" |
|
24 #include "xmlsec_keysdata.h" |
|
25 #include "xmlsec_keys.h" |
|
26 #include "xmlsec_keysmngr.h" |
|
27 #include "xmlsec_transforms.h" |
|
28 #include "xmlsec_private.h" |
|
29 #include "xmlsec_xmltree.h" |
|
30 #include "xmlsec_errors.h" |
|
31 #include "xmlsec_dl.h" |
|
32 |
|
33 |
|
34 #ifndef XMLSEC_NO_CRYPTO_DYNAMIC_LOADING |
|
35 |
|
36 #include "xmlsec-ltdl.h" |
|
37 |
|
38 /*********************************************************************** |
|
39 * |
|
40 * loaded libraries list |
|
41 * |
|
42 **********************************************************************/ |
|
43 typedef struct _xmlSecCryptoDLLibrary xmlSecCryptoDLLibrary, |
|
44 *xmlSecCryptoDLLibraryPtr; |
|
45 struct _xmlSecCryptoDLLibrary { |
|
46 xmlChar* name; |
|
47 xmlChar* filename; |
|
48 xmlChar* getFunctionsName; |
|
49 xmlSecCryptoDLFunctionsPtr functions; |
|
50 |
|
51 xmlsec_lt_dlhandle handle; |
|
52 }; |
|
53 |
|
54 static xmlSecCryptoDLLibraryPtr xmlSecCryptoDLLibraryCreate (const xmlChar* name); |
|
55 static void xmlSecCryptoDLLibraryDestroy (xmlSecCryptoDLLibraryPtr lib); |
|
56 static xmlSecCryptoDLLibraryPtr xmlSecCryptoDLLibraryDuplicate (xmlSecCryptoDLLibraryPtr lib); |
|
57 static xmlChar* xmlSecCryptoDLLibraryConstructFilename (const xmlChar* name); |
|
58 static xmlChar* xmlSecCryptoDLLibraryConstructGetFunctionsName(const xmlChar* name); |
|
59 |
|
60 |
|
61 static xmlSecPtrListKlass xmlSecCryptoDLLibrariesListKlass = { |
|
62 BAD_CAST "dl-libraries-list", |
|
63 (xmlSecPtrDuplicateItemMethod)xmlSecCryptoDLLibraryDuplicate,/* xmlSecPtrDuplicateItemMethod duplicateItem; */ |
|
64 (xmlSecPtrDestroyItemMethod)xmlSecCryptoDLLibraryDestroy, /* xmlSecPtrDestroyItemMethod destroyItem; */ |
|
65 NULL, /* xmlSecPtrDebugDumpItemMethod debugDumpItem; */ |
|
66 NULL, /* xmlSecPtrDebugDumpItemMethod debugXmlDumpItem; */ |
|
67 }; |
|
68 static xmlSecPtrListId xmlSecCryptoDLLibrariesListGetKlass (void); |
|
69 static int xmlSecCryptoDLLibrariesListFindByName (xmlSecPtrListPtr list, |
|
70 const xmlChar* name); |
|
71 |
|
72 typedef xmlSecCryptoDLFunctionsPtr (*xmlSecCryptoGetFunctionsCallback)(void); |
|
73 |
|
74 static xmlSecCryptoDLLibraryPtr |
|
75 xmlSecCryptoDLLibraryCreate(const xmlChar* name) { |
|
76 xmlSecCryptoDLLibraryPtr lib; |
|
77 xmlSecCryptoGetFunctionsCallback getFunctions; |
|
78 |
|
79 xmlSecAssert2(name != NULL, NULL); |
|
80 |
|
81 /* fprintf (stderr, "loading \"library %s\"...\n", name); */ |
|
82 |
|
83 /* Allocate a new xmlSecCryptoDLLibrary and fill the fields. */ |
|
84 lib = (xmlSecCryptoDLLibraryPtr)xmlMalloc(sizeof(xmlSecCryptoDLLibrary)); |
|
85 if(lib == NULL) { |
|
86 xmlSecError(XMLSEC_ERRORS_HERE, |
|
87 NULL, |
|
88 NULL, |
|
89 XMLSEC_ERRORS_R_MALLOC_FAILED, |
|
90 "size=%d", sizeof(lib)); |
|
91 return(NULL); |
|
92 } |
|
93 memset(lib, 0, sizeof(xmlSecCryptoDLLibrary)); |
|
94 |
|
95 lib->name = xmlStrdup(name); |
|
96 if(lib->name == NULL) { |
|
97 xmlSecError(XMLSEC_ERRORS_HERE, |
|
98 "xmlStrdup", |
|
99 NULL, |
|
100 XMLSEC_ERRORS_R_MALLOC_FAILED, |
|
101 XMLSEC_ERRORS_NO_MESSAGE); |
|
102 xmlSecCryptoDLLibraryDestroy(lib); |
|
103 return(NULL); |
|
104 } |
|
105 |
|
106 lib->filename = xmlSecCryptoDLLibraryConstructFilename(name); |
|
107 if(lib->filename == NULL) { |
|
108 xmlSecError(XMLSEC_ERRORS_HERE, |
|
109 "xmlSecCryptoDLLibraryConstructFilename", |
|
110 NULL, |
|
111 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
112 XMLSEC_ERRORS_NO_MESSAGE); |
|
113 xmlSecCryptoDLLibraryDestroy(lib); |
|
114 return(NULL); |
|
115 } |
|
116 |
|
117 lib->getFunctionsName = xmlSecCryptoDLLibraryConstructGetFunctionsName(name); |
|
118 if(lib->getFunctionsName == NULL) { |
|
119 xmlSecError(XMLSEC_ERRORS_HERE, |
|
120 "xmlSecCryptoDLLibraryConstructGetFunctionsName", |
|
121 NULL, |
|
122 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
123 XMLSEC_ERRORS_NO_MESSAGE); |
|
124 xmlSecCryptoDLLibraryDestroy(lib); |
|
125 return(NULL); |
|
126 } |
|
127 |
|
128 |
|
129 lib->handle = xmlsec_lt_dlopen((char*)lib->filename); |
|
130 if(lib->handle == NULL) { |
|
131 xmlSecError(XMLSEC_ERRORS_HERE, |
|
132 "xmlsec_lt_dlopen", |
|
133 NULL, |
|
134 XMLSEC_ERRORS_R_IO_FAILED, |
|
135 "filename=%s", |
|
136 xmlSecErrorsSafeString(lib->filename)); |
|
137 xmlSecCryptoDLLibraryDestroy(lib); |
|
138 return(NULL); |
|
139 } |
|
140 |
|
141 |
|
142 getFunctions = (xmlSecCryptoGetFunctionsCallback)xmlsec_lt_dlsym(lib->handle, (char*)lib->getFunctionsName); |
|
143 if(getFunctions == NULL) { |
|
144 xmlSecError(XMLSEC_ERRORS_HERE, |
|
145 "xmlsec_lt_dlsym", |
|
146 NULL, |
|
147 XMLSEC_ERRORS_R_IO_FAILED, |
|
148 "function=%s", |
|
149 xmlSecErrorsSafeString(lib->getFunctionsName)); |
|
150 xmlSecCryptoDLLibraryDestroy(lib); |
|
151 return(NULL); |
|
152 } |
|
153 |
|
154 if(getFunctions == NULL) { |
|
155 xmlSecError(XMLSEC_ERRORS_HERE, |
|
156 NULL, |
|
157 NULL, |
|
158 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
159 "invalid configuration: no way to load library"); |
|
160 xmlSecCryptoDLLibraryDestroy(lib); |
|
161 return(NULL); |
|
162 } |
|
163 |
|
164 lib->functions = getFunctions(); |
|
165 if(lib->functions == NULL) { |
|
166 xmlSecError(XMLSEC_ERRORS_HERE, |
|
167 "getFunctions", |
|
168 NULL, |
|
169 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
170 XMLSEC_ERRORS_NO_MESSAGE); |
|
171 xmlSecCryptoDLLibraryDestroy(lib); |
|
172 return(NULL); |
|
173 } |
|
174 |
|
175 /* fprintf (stderr, "library %s loaded\n", name); */ |
|
176 return(lib); |
|
177 } |
|
178 |
|
179 static void |
|
180 xmlSecCryptoDLLibraryDestroy(xmlSecCryptoDLLibraryPtr lib) { |
|
181 xmlSecAssert(lib != NULL); |
|
182 |
|
183 /* fprintf (stderr, "unloading \"library %s\"...\n", lib->name); */ |
|
184 if(lib->name != NULL) { |
|
185 xmlFree(lib->name); |
|
186 } |
|
187 |
|
188 if(lib->filename != NULL) { |
|
189 xmlFree(lib->filename); |
|
190 } |
|
191 |
|
192 if(lib->getFunctionsName != NULL) { |
|
193 xmlFree(lib->getFunctionsName); |
|
194 } |
|
195 |
|
196 if(lib->handle != NULL) { |
|
197 int ret; |
|
198 |
|
199 ret = xmlsec_lt_dlclose(lib->handle); |
|
200 if(ret != 0) { |
|
201 xmlSecError(XMLSEC_ERRORS_HERE, |
|
202 "xmlsec_lt_dlclose", |
|
203 NULL, |
|
204 XMLSEC_ERRORS_R_IO_FAILED, |
|
205 XMLSEC_ERRORS_NO_MESSAGE); |
|
206 } |
|
207 } |
|
208 |
|
209 memset(lib, 0, sizeof(xmlSecCryptoDLLibrary)); |
|
210 xmlFree(lib); |
|
211 } |
|
212 |
|
213 static xmlSecCryptoDLLibraryPtr |
|
214 xmlSecCryptoDLLibraryDuplicate(xmlSecCryptoDLLibraryPtr lib) { |
|
215 xmlSecAssert2(lib != NULL, NULL); |
|
216 xmlSecAssert2(lib->name != NULL, NULL); |
|
217 |
|
218 return(xmlSecCryptoDLLibraryCreate(lib->name)); |
|
219 } |
|
220 |
|
221 static xmlChar* |
|
222 xmlSecCryptoDLLibraryConstructFilename(const xmlChar* name) { |
|
223 static xmlChar tmpl[] = "lib%s-%s" LTDL_SHLIB_EXT; |
|
224 xmlChar* res; |
|
225 int len; |
|
226 |
|
227 xmlSecAssert2(name != NULL, NULL); |
|
228 |
|
229 len = xmlStrlen(BAD_CAST PACKAGE) + xmlStrlen(name) + xmlStrlen(tmpl) + 1; |
|
230 res = (xmlChar*)xmlMalloc(len + 1); |
|
231 if(res == NULL) { |
|
232 xmlSecError(XMLSEC_ERRORS_HERE, |
|
233 NULL, |
|
234 NULL, |
|
235 XMLSEC_ERRORS_R_MALLOC_FAILED, |
|
236 "size=%d", len + 1); |
|
237 return(NULL); |
|
238 } |
|
239 xmlSecStrPrintf(res, len, tmpl, PACKAGE, name); |
|
240 |
|
241 return(res); |
|
242 } |
|
243 |
|
244 static xmlChar* |
|
245 xmlSecCryptoDLLibraryConstructGetFunctionsName(const xmlChar* name) { |
|
246 static xmlChar tmpl[] = "xmlSecCryptoGetFunctions_%s"; |
|
247 xmlChar* res; |
|
248 int len; |
|
249 |
|
250 xmlSecAssert2(name != NULL, NULL); |
|
251 |
|
252 len = xmlStrlen(name) + xmlStrlen(tmpl) + 1; |
|
253 res = (xmlChar*)xmlMalloc(len + 1); |
|
254 if(res == NULL) { |
|
255 xmlSecError(XMLSEC_ERRORS_HERE, |
|
256 NULL, |
|
257 NULL, |
|
258 XMLSEC_ERRORS_R_MALLOC_FAILED, |
|
259 "size=%d", len + 1); |
|
260 return(NULL); |
|
261 } |
|
262 xmlSecStrPrintf(res, len, tmpl, name); |
|
263 |
|
264 return(res); |
|
265 } |
|
266 |
|
267 static xmlSecPtrListId |
|
268 xmlSecCryptoDLLibrariesListGetKlass(void) { |
|
269 return(&xmlSecCryptoDLLibrariesListKlass); |
|
270 } |
|
271 |
|
272 static int |
|
273 xmlSecCryptoDLLibrariesListFindByName(xmlSecPtrListPtr list, const xmlChar* name) { |
|
274 xmlSecSize i, size; |
|
275 xmlSecCryptoDLLibraryPtr lib; |
|
276 |
|
277 xmlSecAssert2(xmlSecPtrListCheckId(list, xmlSecCryptoDLLibrariesListGetKlass()), -1); |
|
278 xmlSecAssert2(name != NULL, -1); |
|
279 |
|
280 size = xmlSecPtrListGetSize(list); |
|
281 for(i = 0; i < size; ++i) { |
|
282 lib = (xmlSecCryptoDLLibraryPtr)xmlSecPtrListGetItem(list, i); |
|
283 if((lib != NULL) && (lib->name != NULL) && (xmlStrcmp(lib->name, name) == 0)) { |
|
284 return(i); |
|
285 } |
|
286 } |
|
287 return(-1); |
|
288 } |
|
289 |
|
290 /****************************************************************************** |
|
291 * |
|
292 * Dynamic load functions |
|
293 * |
|
294 *****************************************************************************/ |
|
295 static xmlSecCryptoDLFunctionsPtr gXmlSecCryptoDLFunctions = NULL; |
|
296 static xmlSecPtrList gXmlSecCryptoDLLibraries; |
|
297 |
|
298 static xmlsec_lt_ptr xmlSecCryptoDLMalloc(size_t size) { |
|
299 xmlsec_lt_ptr res; |
|
300 |
|
301 res = (xmlsec_lt_ptr)xmlMalloc(size); |
|
302 if(res == NULL) { |
|
303 xmlSecError(XMLSEC_ERRORS_HERE, |
|
304 NULL, |
|
305 NULL, |
|
306 XMLSEC_ERRORS_R_MALLOC_FAILED, |
|
307 "size=%d", size); |
|
308 return(NULL); |
|
309 } |
|
310 memset(res, 0, size); |
|
311 return(res); |
|
312 } |
|
313 |
|
314 static void xmlSecCryptoDLFree(xmlsec_lt_ptr ptr) { |
|
315 if(ptr != NULL) { |
|
316 xmlFree(ptr); |
|
317 } |
|
318 } |
|
319 |
|
320 /** |
|
321 * xmlSecCryptoDLInit: |
|
322 * |
|
323 * Initializes dynamic loading engine. This is an internal function |
|
324 * and should not be called by application directly. |
|
325 * |
|
326 * Returns 0 on success or a negative value if an error occurs. |
|
327 */ |
|
328 int |
|
329 xmlSecCryptoDLInit(void) { |
|
330 int ret; |
|
331 |
|
332 ret = xmlSecPtrListInitialize(&gXmlSecCryptoDLLibraries, xmlSecCryptoDLLibrariesListGetKlass()); |
|
333 if(ret < 0) { |
|
334 xmlSecError(XMLSEC_ERRORS_HERE, |
|
335 NULL, |
|
336 "xmlSecPtrListPtrInitialize", |
|
337 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
338 "xmlSecCryptoDLLibrariesListGetKlass"); |
|
339 return(-1); |
|
340 } |
|
341 |
|
342 /* use xmlMalloc/xmlFree */ |
|
343 xmlsec_lt_dlmalloc = xmlSecCryptoDLMalloc; |
|
344 xmlsec_lt_dlfree = xmlSecCryptoDLFree; |
|
345 ret = xmlsec_lt_dlinit (); |
|
346 if(ret != 0) { |
|
347 xmlSecError(XMLSEC_ERRORS_HERE, |
|
348 NULL, |
|
349 "xmlsec_lt_dlinit", |
|
350 XMLSEC_ERRORS_R_IO_FAILED, |
|
351 XMLSEC_ERRORS_NO_MESSAGE); |
|
352 return(-1); |
|
353 } |
|
354 |
|
355 return(0); |
|
356 } |
|
357 |
|
358 |
|
359 /** |
|
360 * xmlSecCryptoDLShutdown: |
|
361 * |
|
362 * Shutdowns dynamic loading engine. This is an internal function |
|
363 * and should not be called by application directly. |
|
364 * |
|
365 * Returns 0 on success or a negative value if an error occurs. |
|
366 */ |
|
367 int |
|
368 xmlSecCryptoDLShutdown(void) { |
|
369 int ret; |
|
370 |
|
371 xmlSecPtrListFinalize(&gXmlSecCryptoDLLibraries); |
|
372 |
|
373 ret = xmlsec_lt_dlexit (); |
|
374 if(ret != 0) { |
|
375 xmlSecError(XMLSEC_ERRORS_HERE, |
|
376 NULL, |
|
377 "xmlsec_lt_dlexit", |
|
378 XMLSEC_ERRORS_R_IO_FAILED, |
|
379 XMLSEC_ERRORS_NO_MESSAGE); |
|
380 } |
|
381 return(0); |
|
382 } |
|
383 |
|
384 /** |
|
385 * xmlSecCryptoDLLoadLibrary: |
|
386 * @crypto: the desired crypto library name ("openssl", "nss", ...). |
|
387 * |
|
388 * Loads the xmlsec-<crypto> library. This function is NOT thread safe, |
|
389 * application MUST NOT call #xmlSecCryptoDLLoadLibrary, #xmlSecCryptoDLGetLibraryFunctions, |
|
390 * and #xmlSecCryptoDLUnloadLibrary functions from multiple threads. |
|
391 * |
|
392 * Returns 0 on success or a negative value if an error occurs. |
|
393 */ |
|
394 int |
|
395 xmlSecCryptoDLLoadLibrary(const xmlChar* crypto) { |
|
396 xmlSecCryptoDLFunctionsPtr functions; |
|
397 int ret; |
|
398 |
|
399 xmlSecAssert2(crypto != NULL, -1); |
|
400 |
|
401 functions = xmlSecCryptoDLGetLibraryFunctions(crypto); |
|
402 if(functions == NULL) { |
|
403 xmlSecError(XMLSEC_ERRORS_HERE, |
|
404 NULL, |
|
405 "xmlSecCryptoDLGetLibraryFunctions", |
|
406 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
407 XMLSEC_ERRORS_NO_MESSAGE); |
|
408 return(-1); |
|
409 } |
|
410 |
|
411 ret = xmlSecCryptoDLSetFunctions(functions); |
|
412 if(ret < 0) { |
|
413 xmlSecError(XMLSEC_ERRORS_HERE, |
|
414 NULL, |
|
415 "xmlSecCryptoDLSetFunctions", |
|
416 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
417 XMLSEC_ERRORS_NO_MESSAGE); |
|
418 return(-1); |
|
419 } |
|
420 return(0); |
|
421 } |
|
422 |
|
423 /** |
|
424 * xmlSecCryptoDLGetLibraryFunctions: |
|
425 * @crypto: the desired crypto library name ("openssl", "nss", ...). |
|
426 * |
|
427 * Loads the xmlsec-<crypto> library and gets global crypto functions/transforms/keys data/keys store |
|
428 * table. This function is NOT thread safe, application MUST NOT call #xmlSecCryptoDLLoadLibrary, |
|
429 * #xmlSecCryptoDLGetLibraryFunctions, and #xmlSecCryptoDLUnloadLibrary functions from multiple threads. |
|
430 * |
|
431 * Returns the table or NULL if an error occurs. |
|
432 */ |
|
433 xmlSecCryptoDLFunctionsPtr |
|
434 xmlSecCryptoDLGetLibraryFunctions(const xmlChar* crypto) { |
|
435 xmlSecCryptoDLLibraryPtr lib; |
|
436 int pos; |
|
437 int ret; |
|
438 |
|
439 xmlSecAssert2(crypto != NULL, NULL); |
|
440 |
|
441 pos = xmlSecCryptoDLLibrariesListFindByName(&gXmlSecCryptoDLLibraries, crypto); |
|
442 if(pos >= 0) { |
|
443 lib = (xmlSecCryptoDLLibraryPtr)xmlSecPtrListGetItem(&gXmlSecCryptoDLLibraries, pos); |
|
444 xmlSecAssert2(lib != NULL, NULL); |
|
445 xmlSecAssert2(lib->functions != NULL, NULL); |
|
446 |
|
447 return(lib->functions); |
|
448 } |
|
449 |
|
450 lib = xmlSecCryptoDLLibraryCreate(crypto); |
|
451 if(lib == NULL) { |
|
452 xmlSecError(XMLSEC_ERRORS_HERE, |
|
453 NULL, |
|
454 "xmlSecCryptoDLLibraryCreate", |
|
455 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
456 "crypto=%s", |
|
457 xmlSecErrorsSafeString(crypto)); |
|
458 return(NULL); |
|
459 } |
|
460 |
|
461 ret = xmlSecPtrListAdd(&gXmlSecCryptoDLLibraries, lib); |
|
462 if(ret < 0) { |
|
463 xmlSecError(XMLSEC_ERRORS_HERE, |
|
464 NULL, |
|
465 "xmlSecPtrListAdd", |
|
466 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
467 "crypto=%s", |
|
468 xmlSecErrorsSafeString(crypto)); |
|
469 xmlSecCryptoDLLibraryDestroy(lib); |
|
470 return(NULL); |
|
471 } |
|
472 |
|
473 return(lib->functions); |
|
474 } |
|
475 |
|
476 /** |
|
477 * xmlSecCryptoDLUnloadLibrary: |
|
478 * @crypto: the desired crypto library name ("openssl", "nss", ...). |
|
479 * |
|
480 * Unloads the xmlsec-<crypto> library. All pointers to this library |
|
481 * functions tables became invalid. This function is NOT thread safe, |
|
482 * application MUST NOT call #xmlSecCryptoDLLoadLibrary, #xmlSecCryptoDLGetLibraryFunctions, |
|
483 * and #xmlSecCryptoDLUnloadLibrary functions from multiple threads. |
|
484 * |
|
485 * Returns 0 on success or a negative value if an error occurs. |
|
486 */ |
|
487 int |
|
488 xmlSecCryptoDLUnloadLibrary(const xmlChar* crypto) { |
|
489 xmlSecCryptoDLLibraryPtr lib; |
|
490 int pos; |
|
491 int ret; |
|
492 |
|
493 xmlSecAssert2(crypto != NULL, -1); |
|
494 |
|
495 pos = xmlSecCryptoDLLibrariesListFindByName(&gXmlSecCryptoDLLibraries, crypto); |
|
496 if(pos < 0) { |
|
497 return(0); |
|
498 } |
|
499 |
|
500 lib = (xmlSecCryptoDLLibraryPtr)xmlSecPtrListGetItem(&gXmlSecCryptoDLLibraries, pos); |
|
501 if((lib != NULL) && (lib->functions == gXmlSecCryptoDLFunctions)) { |
|
502 gXmlSecCryptoDLFunctions = NULL; |
|
503 } |
|
504 |
|
505 ret = xmlSecPtrListRemove(&gXmlSecCryptoDLLibraries, pos); |
|
506 if(ret < 0) { |
|
507 xmlSecError(XMLSEC_ERRORS_HERE, |
|
508 NULL, |
|
509 "xmlSecPtrListRemove", |
|
510 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
511 XMLSEC_ERRORS_NO_MESSAGE); |
|
512 return(-1); |
|
513 } |
|
514 |
|
515 return(0); |
|
516 } |
|
517 |
|
518 /** |
|
519 * xmlSecCryptoDLSetFunctions: |
|
520 * @functions: the new table |
|
521 * |
|
522 * Sets global crypto functions/transforms/keys data/keys store table. |
|
523 * |
|
524 * Returns 0 on success or a negative value if an error occurs. |
|
525 */ |
|
526 int |
|
527 xmlSecCryptoDLSetFunctions(xmlSecCryptoDLFunctionsPtr functions) { |
|
528 xmlSecAssert2(functions != NULL, -1); |
|
529 |
|
530 gXmlSecCryptoDLFunctions = functions; |
|
531 |
|
532 return(0); |
|
533 } |
|
534 |
|
535 /** |
|
536 * xmlSecCryptoDLGetFunctions: |
|
537 * |
|
538 * Gets global crypto functions/transforms/keys data/keys store table. |
|
539 * |
|
540 * Returns the table. |
|
541 */ |
|
542 xmlSecCryptoDLFunctionsPtr |
|
543 xmlSecCryptoDLGetFunctions(void) { |
|
544 return(gXmlSecCryptoDLFunctions); |
|
545 } |
|
546 |
|
547 #endif /* XMLSEC_NO_CRYPTO_DYNAMIC_LOADING */ |
|
548 |
|
549 /** |
|
550 * xmlSecCryptoDLFunctionsRegisterKeyDataAndTransforms: |
|
551 * @functions: the functions table. |
|
552 * |
|
553 * Registers the key data and transforms klasses from @functions table in xmlsec. |
|
554 * |
|
555 * Returns 0 on success or a negative value if an error occurs. |
|
556 */ |
|
557 EXPORT_C |
|
558 int |
|
559 xmlSecCryptoDLFunctionsRegisterKeyDataAndTransforms(struct _xmlSecCryptoDLFunctions* functions) { |
|
560 xmlSecAssert2(functions != NULL, -1); |
|
561 |
|
562 /** |
|
563 * Register keys |
|
564 */ |
|
565 if((functions->keyDataAesGetKlass != NULL) && (xmlSecKeyDataIdsRegister(functions->keyDataAesGetKlass()) < 0)) { |
|
566 xmlSecError(XMLSEC_ERRORS_HERE, |
|
567 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(functions->keyDataAesGetKlass())), |
|
568 "xmlSecKeyDataIdsRegister", |
|
569 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
570 XMLSEC_ERRORS_NO_MESSAGE); |
|
571 return(-1); |
|
572 } |
|
573 if((functions->keyDataDesGetKlass != NULL) && (xmlSecKeyDataIdsRegister(functions->keyDataDesGetKlass()) < 0)) { |
|
574 xmlSecError(XMLSEC_ERRORS_HERE, |
|
575 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(functions->keyDataDesGetKlass())), |
|
576 "xmlSecKeyDataIdsRegister", |
|
577 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
578 XMLSEC_ERRORS_NO_MESSAGE); |
|
579 return(-1); |
|
580 } |
|
581 if((functions->keyDataDsaGetKlass != NULL) && (xmlSecKeyDataIdsRegister(functions->keyDataDsaGetKlass()) < 0)) { |
|
582 xmlSecError(XMLSEC_ERRORS_HERE, |
|
583 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(functions->keyDataDsaGetKlass())), |
|
584 "xmlSecKeyDataIdsRegister", |
|
585 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
586 XMLSEC_ERRORS_NO_MESSAGE); |
|
587 return(-1); |
|
588 } |
|
589 if((functions->keyDataHmacGetKlass != NULL) && (xmlSecKeyDataIdsRegister(functions->keyDataHmacGetKlass()) < 0)) { |
|
590 xmlSecError(XMLSEC_ERRORS_HERE, |
|
591 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(functions->keyDataHmacGetKlass())), |
|
592 "xmlSecKeyDataIdsRegister", |
|
593 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
594 XMLSEC_ERRORS_NO_MESSAGE); |
|
595 return(-1); |
|
596 } |
|
597 if((functions->keyDataRsaGetKlass != NULL) && (xmlSecKeyDataIdsRegister(functions->keyDataRsaGetKlass()) < 0)) { |
|
598 xmlSecError(XMLSEC_ERRORS_HERE, |
|
599 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(functions->keyDataRsaGetKlass())), |
|
600 "xmlSecKeyDataIdsRegister", |
|
601 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
602 XMLSEC_ERRORS_NO_MESSAGE); |
|
603 return(-1); |
|
604 } |
|
605 if((functions->keyDataX509GetKlass != NULL) && (xmlSecKeyDataIdsRegister(functions->keyDataX509GetKlass()) < 0)) { |
|
606 xmlSecError(XMLSEC_ERRORS_HERE, |
|
607 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(functions->keyDataX509GetKlass())), |
|
608 "xmlSecKeyDataIdsRegister", |
|
609 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
610 XMLSEC_ERRORS_NO_MESSAGE); |
|
611 return(-1); |
|
612 } |
|
613 if((functions->keyDataRawX509CertGetKlass != NULL) && (xmlSecKeyDataIdsRegister(functions->keyDataRawX509CertGetKlass()) < 0)) { |
|
614 xmlSecError(XMLSEC_ERRORS_HERE, |
|
615 xmlSecErrorsSafeString(xmlSecKeyDataKlassGetName(functions->keyDataRawX509CertGetKlass())), |
|
616 "xmlSecKeyDataIdsRegister", |
|
617 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
618 XMLSEC_ERRORS_NO_MESSAGE); |
|
619 return(-1); |
|
620 } |
|
621 |
|
622 |
|
623 /** |
|
624 * Register transforms |
|
625 */ |
|
626 if((functions->transformAes128CbcGetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformAes128CbcGetKlass()) < 0) { |
|
627 xmlSecError(XMLSEC_ERRORS_HERE, |
|
628 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformAes128CbcGetKlass())), |
|
629 "xmlSecTransformIdsRegister", |
|
630 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
631 XMLSEC_ERRORS_NO_MESSAGE); |
|
632 return(-1); |
|
633 } |
|
634 |
|
635 if((functions->transformAes192CbcGetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformAes192CbcGetKlass()) < 0) { |
|
636 xmlSecError(XMLSEC_ERRORS_HERE, |
|
637 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformAes192CbcGetKlass())), |
|
638 "xmlSecTransformIdsRegister", |
|
639 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
640 XMLSEC_ERRORS_NO_MESSAGE); |
|
641 return(-1); |
|
642 } |
|
643 |
|
644 if((functions->transformAes256CbcGetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformAes256CbcGetKlass()) < 0) { |
|
645 xmlSecError(XMLSEC_ERRORS_HERE, |
|
646 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformAes256CbcGetKlass())), |
|
647 "xmlSecTransformIdsRegister", |
|
648 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
649 XMLSEC_ERRORS_NO_MESSAGE); |
|
650 return(-1); |
|
651 } |
|
652 |
|
653 if((functions->transformKWAes128GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformKWAes128GetKlass()) < 0) { |
|
654 xmlSecError(XMLSEC_ERRORS_HERE, |
|
655 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformKWAes128GetKlass())), |
|
656 "xmlSecTransformIdsRegister", |
|
657 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
658 XMLSEC_ERRORS_NO_MESSAGE); |
|
659 return(-1); |
|
660 } |
|
661 |
|
662 if((functions->transformKWAes192GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformKWAes192GetKlass()) < 0) { |
|
663 xmlSecError(XMLSEC_ERRORS_HERE, |
|
664 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformKWAes192GetKlass())), |
|
665 "xmlSecTransformIdsRegister", |
|
666 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
667 XMLSEC_ERRORS_NO_MESSAGE); |
|
668 return(-1); |
|
669 } |
|
670 |
|
671 if((functions->transformKWAes256GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformKWAes256GetKlass()) < 0) { |
|
672 xmlSecError(XMLSEC_ERRORS_HERE, |
|
673 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformKWAes256GetKlass())), |
|
674 "xmlSecTransformIdsRegister", |
|
675 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
676 XMLSEC_ERRORS_NO_MESSAGE); |
|
677 return(-1); |
|
678 } |
|
679 |
|
680 if((functions->transformDes3CbcGetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformDes3CbcGetKlass()) < 0) { |
|
681 xmlSecError(XMLSEC_ERRORS_HERE, |
|
682 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformDes3CbcGetKlass())), |
|
683 "xmlSecTransformIdsRegister", |
|
684 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
685 XMLSEC_ERRORS_NO_MESSAGE); |
|
686 return(-1); |
|
687 } |
|
688 |
|
689 if((functions->transformKWDes3GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformKWDes3GetKlass()) < 0) { |
|
690 xmlSecError(XMLSEC_ERRORS_HERE, |
|
691 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformKWDes3GetKlass())), |
|
692 "xmlSecTransformIdsRegister", |
|
693 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
694 XMLSEC_ERRORS_NO_MESSAGE); |
|
695 return(-1); |
|
696 } |
|
697 |
|
698 if((functions->transformDsaSha1GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformDsaSha1GetKlass()) < 0) { |
|
699 xmlSecError(XMLSEC_ERRORS_HERE, |
|
700 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformDsaSha1GetKlass())), |
|
701 "xmlSecTransformIdsRegister", |
|
702 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
703 XMLSEC_ERRORS_NO_MESSAGE); |
|
704 return(-1); |
|
705 } |
|
706 |
|
707 if((functions->transformHmacMd5GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformHmacMd5GetKlass()) < 0) { |
|
708 xmlSecError(XMLSEC_ERRORS_HERE, |
|
709 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformHmacMd5GetKlass())), |
|
710 "xmlSecTransformIdsRegister", |
|
711 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
712 XMLSEC_ERRORS_NO_MESSAGE); |
|
713 return(-1); |
|
714 } |
|
715 |
|
716 if((functions->transformHmacRipemd160GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformHmacRipemd160GetKlass()) < 0) { |
|
717 xmlSecError(XMLSEC_ERRORS_HERE, |
|
718 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformHmacRipemd160GetKlass())), |
|
719 "xmlSecTransformIdsRegister", |
|
720 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
721 XMLSEC_ERRORS_NO_MESSAGE); |
|
722 return(-1); |
|
723 } |
|
724 |
|
725 if((functions->transformHmacSha1GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformHmacSha1GetKlass()) < 0) { |
|
726 xmlSecError(XMLSEC_ERRORS_HERE, |
|
727 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformHmacSha1GetKlass())), |
|
728 "xmlSecTransformIdsRegister", |
|
729 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
730 XMLSEC_ERRORS_NO_MESSAGE); |
|
731 return(-1); |
|
732 } |
|
733 |
|
734 if((functions->transformHmacSha224GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformHmacSha224GetKlass()) < 0) { |
|
735 xmlSecError(XMLSEC_ERRORS_HERE, |
|
736 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformHmacSha224GetKlass())), |
|
737 "xmlSecTransformIdsRegister", |
|
738 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
739 XMLSEC_ERRORS_NO_MESSAGE); |
|
740 return(-1); |
|
741 } |
|
742 |
|
743 if((functions->transformHmacSha256GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformHmacSha256GetKlass()) < 0) { |
|
744 xmlSecError(XMLSEC_ERRORS_HERE, |
|
745 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformHmacSha256GetKlass())), |
|
746 "xmlSecTransformIdsRegister", |
|
747 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
748 XMLSEC_ERRORS_NO_MESSAGE); |
|
749 return(-1); |
|
750 } |
|
751 |
|
752 if((functions->transformHmacSha384GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformHmacSha384GetKlass()) < 0) { |
|
753 xmlSecError(XMLSEC_ERRORS_HERE, |
|
754 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformHmacSha384GetKlass())), |
|
755 "xmlSecTransformIdsRegister", |
|
756 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
757 XMLSEC_ERRORS_NO_MESSAGE); |
|
758 return(-1); |
|
759 } |
|
760 |
|
761 if((functions->transformHmacSha512GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformHmacSha512GetKlass()) < 0) { |
|
762 xmlSecError(XMLSEC_ERRORS_HERE, |
|
763 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformHmacSha512GetKlass())), |
|
764 "xmlSecTransformIdsRegister", |
|
765 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
766 XMLSEC_ERRORS_NO_MESSAGE); |
|
767 return(-1); |
|
768 } |
|
769 |
|
770 if((functions->transformMd5GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformMd5GetKlass()) < 0) { |
|
771 xmlSecError(XMLSEC_ERRORS_HERE, |
|
772 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformMd5GetKlass())), |
|
773 "xmlSecTransformIdsRegister", |
|
774 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
775 XMLSEC_ERRORS_NO_MESSAGE); |
|
776 return(-1); |
|
777 } |
|
778 |
|
779 if((functions->transformRipemd160GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformRipemd160GetKlass()) < 0) { |
|
780 xmlSecError(XMLSEC_ERRORS_HERE, |
|
781 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformRipemd160GetKlass())), |
|
782 "xmlSecTransformIdsRegister", |
|
783 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
784 XMLSEC_ERRORS_NO_MESSAGE); |
|
785 return(-1); |
|
786 } |
|
787 |
|
788 if((functions->transformRsaMd5GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformRsaMd5GetKlass()) < 0) { |
|
789 xmlSecError(XMLSEC_ERRORS_HERE, |
|
790 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformRsaMd5GetKlass())), |
|
791 "xmlSecTransformIdsRegister", |
|
792 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
793 XMLSEC_ERRORS_NO_MESSAGE); |
|
794 return(-1); |
|
795 } |
|
796 |
|
797 if((functions->transformRsaRipemd160GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformRsaRipemd160GetKlass()) < 0) { |
|
798 xmlSecError(XMLSEC_ERRORS_HERE, |
|
799 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformRsaRipemd160GetKlass())), |
|
800 "xmlSecTransformIdsRegister", |
|
801 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
802 XMLSEC_ERRORS_NO_MESSAGE); |
|
803 return(-1); |
|
804 } |
|
805 |
|
806 if((functions->transformRsaSha1GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformRsaSha1GetKlass()) < 0) { |
|
807 xmlSecError(XMLSEC_ERRORS_HERE, |
|
808 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformRsaSha1GetKlass())), |
|
809 "xmlSecTransformIdsRegister", |
|
810 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
811 XMLSEC_ERRORS_NO_MESSAGE); |
|
812 return(-1); |
|
813 } |
|
814 |
|
815 if((functions->transformRsaSha224GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformRsaSha224GetKlass()) < 0) { |
|
816 xmlSecError(XMLSEC_ERRORS_HERE, |
|
817 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformRsaSha224GetKlass())), |
|
818 "xmlSecTransformIdsRegister", |
|
819 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
820 XMLSEC_ERRORS_NO_MESSAGE); |
|
821 return(-1); |
|
822 } |
|
823 |
|
824 if((functions->transformRsaSha256GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformRsaSha256GetKlass()) < 0) { |
|
825 xmlSecError(XMLSEC_ERRORS_HERE, |
|
826 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformRsaSha256GetKlass())), |
|
827 "xmlSecTransformIdsRegister", |
|
828 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
829 XMLSEC_ERRORS_NO_MESSAGE); |
|
830 return(-1); |
|
831 } |
|
832 |
|
833 if((functions->transformRsaSha384GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformRsaSha384GetKlass()) < 0) { |
|
834 xmlSecError(XMLSEC_ERRORS_HERE, |
|
835 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformRsaSha384GetKlass())), |
|
836 "xmlSecTransformIdsRegister", |
|
837 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
838 XMLSEC_ERRORS_NO_MESSAGE); |
|
839 return(-1); |
|
840 } |
|
841 |
|
842 if((functions->transformRsaSha512GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformRsaSha512GetKlass()) < 0) { |
|
843 xmlSecError(XMLSEC_ERRORS_HERE, |
|
844 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformRsaSha512GetKlass())), |
|
845 "xmlSecTransformIdsRegister", |
|
846 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
847 XMLSEC_ERRORS_NO_MESSAGE); |
|
848 return(-1); |
|
849 } |
|
850 |
|
851 if((functions->transformRsaPkcs1GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformRsaPkcs1GetKlass()) < 0) { |
|
852 xmlSecError(XMLSEC_ERRORS_HERE, |
|
853 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformRsaPkcs1GetKlass())), |
|
854 "xmlSecTransformIdsRegister", |
|
855 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
856 XMLSEC_ERRORS_NO_MESSAGE); |
|
857 return(-1); |
|
858 } |
|
859 |
|
860 if((functions->transformRsaOaepGetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformRsaOaepGetKlass()) < 0) { |
|
861 xmlSecError(XMLSEC_ERRORS_HERE, |
|
862 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformRsaOaepGetKlass())), |
|
863 "xmlSecTransformIdsRegister", |
|
864 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
865 XMLSEC_ERRORS_NO_MESSAGE); |
|
866 return(-1); |
|
867 } |
|
868 |
|
869 if((functions->transformSha1GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformSha1GetKlass()) < 0) { |
|
870 xmlSecError(XMLSEC_ERRORS_HERE, |
|
871 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformSha1GetKlass())), |
|
872 "xmlSecTransformIdsRegister", |
|
873 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
874 XMLSEC_ERRORS_NO_MESSAGE); |
|
875 return(-1); |
|
876 } |
|
877 |
|
878 if((functions->transformSha224GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformSha224GetKlass()) < 0) { |
|
879 xmlSecError(XMLSEC_ERRORS_HERE, |
|
880 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformSha224GetKlass())), |
|
881 "xmlSecTransformIdsRegister", |
|
882 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
883 XMLSEC_ERRORS_NO_MESSAGE); |
|
884 return(-1); |
|
885 } |
|
886 |
|
887 if((functions->transformSha256GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformSha256GetKlass()) < 0) { |
|
888 xmlSecError(XMLSEC_ERRORS_HERE, |
|
889 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformSha256GetKlass())), |
|
890 "xmlSecTransformIdsRegister", |
|
891 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
892 XMLSEC_ERRORS_NO_MESSAGE); |
|
893 return(-1); |
|
894 } |
|
895 |
|
896 if((functions->transformSha384GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformSha384GetKlass()) < 0) { |
|
897 xmlSecError(XMLSEC_ERRORS_HERE, |
|
898 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformSha384GetKlass())), |
|
899 "xmlSecTransformIdsRegister", |
|
900 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
901 XMLSEC_ERRORS_NO_MESSAGE); |
|
902 return(-1); |
|
903 } |
|
904 |
|
905 if((functions->transformSha512GetKlass != NULL) && xmlSecTransformIdsRegister(functions->transformSha512GetKlass()) < 0) { |
|
906 xmlSecError(XMLSEC_ERRORS_HERE, |
|
907 xmlSecErrorsSafeString(xmlSecTransformKlassGetName(functions->transformSha512GetKlass())), |
|
908 "xmlSecTransformIdsRegister", |
|
909 XMLSEC_ERRORS_R_XMLSEC_FAILED, |
|
910 XMLSEC_ERRORS_NO_MESSAGE); |
|
911 return(-1); |
|
912 } |
|
913 |
|
914 return(0); |
|
915 } |
|
916 |
|
917 |