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-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved.
9 */
10 /**
11 * SECTION:digests
12 * @Short_description: Digests transforms implementation for GCrypt.
13 * @Stability: Private
14 *
15 */
16
17 #include "globals.h"
18
19 #include <string.h>
20
21 #include <gcrypt.h>
22
23 #include <xmlsec/xmlsec.h>
24 #include <xmlsec/keys.h>
25 #include <xmlsec/transforms.h>
26 #include <xmlsec/errors.h>
27
28 #include <xmlsec/gcrypt/app.h>
29 #include <xmlsec/gcrypt/crypto.h>
30
31 /**************************************************************************
32 *
33 * Internal GCRYPT Digest CTX
34 *
35 *****************************************************************************/
36 typedef struct _xmlSecGCryptDigestCtx xmlSecGCryptDigestCtx, *xmlSecGCryptDigestCtxPtr;
37 struct _xmlSecGCryptDigestCtx {
38 int digest;
39 gcry_md_hd_t digestCtx;
40 xmlSecByte dgst[XMLSEC_GCRYPT_MAX_DIGEST_SIZE];
41 xmlSecSize dgstSize; /* dgst size in bytes */
42 };
43
44 /******************************************************************************
45 *
46 * Digest transforms
47 *
48 * xmlSecGCryptDigestCtx is located after xmlSecTransform
49 *
50 *****************************************************************************/
51 #define xmlSecGCryptDigestSize \
52 (sizeof(xmlSecTransform) + sizeof(xmlSecGCryptDigestCtx))
53 #define xmlSecGCryptDigestGetCtx(transform) \
54 ((xmlSecGCryptDigestCtxPtr)(((xmlSecByte*)(transform)) + sizeof(xmlSecTransform)))
55
56 static int xmlSecGCryptDigestInitialize (xmlSecTransformPtr transform);
57 static void xmlSecGCryptDigestFinalize (xmlSecTransformPtr transform);
58 static int xmlSecGCryptDigestVerify (xmlSecTransformPtr transform,
59 const xmlSecByte* data,
60 xmlSecSize dataSize,
61 xmlSecTransformCtxPtr transformCtx);
62 static int xmlSecGCryptDigestExecute (xmlSecTransformPtr transform,
63 int last,
64 xmlSecTransformCtxPtr transformCtx);
65 static int xmlSecGCryptDigestCheckId (xmlSecTransformPtr transform);
66
67 static int
xmlSecGCryptDigestCheckId(xmlSecTransformPtr transform)68 xmlSecGCryptDigestCheckId(xmlSecTransformPtr transform) {
69
70 #ifndef XMLSEC_NO_SHA1
71 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformSha1Id)) {
72 return(1);
73 } else
74 #endif /* XMLSEC_NO_SHA1 */
75
76 #ifndef XMLSEC_NO_SHA256
77 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformSha256Id)) {
78 return(1);
79 } else
80 #endif /* XMLSEC_NO_SHA256 */
81
82 #ifndef XMLSEC_NO_SHA384
83 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformSha384Id)) {
84 return(1);
85 } else
86 #endif /* XMLSEC_NO_SHA384 */
87
88 #ifndef XMLSEC_NO_SHA512
89 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformSha512Id)) {
90 return(1);
91 } else
92 #endif /* XMLSEC_NO_SHA512 */
93
94 #ifndef XMLSEC_NO_MD5
95 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformMd5Id)) {
96 return(1);
97 } else
98 #endif /* XMLSEC_NO_MD5 */
99
100 #ifndef XMLSEC_NO_RIPEMD160
101 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformRipemd160Id)) {
102 return(1);
103 } else
104 #endif /* XMLSEC_NO_RIPEMD160 */
105
106 /* not found */
107 {
108 return(0);
109 }
110
111 /* just in case */
112 return(0);
113 }
114
115 static int
xmlSecGCryptDigestInitialize(xmlSecTransformPtr transform)116 xmlSecGCryptDigestInitialize(xmlSecTransformPtr transform) {
117 xmlSecGCryptDigestCtxPtr ctx;
118 gcry_error_t err;
119
120 xmlSecAssert2(xmlSecGCryptDigestCheckId(transform), -1);
121 xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecGCryptDigestSize), -1);
122
123 ctx = xmlSecGCryptDigestGetCtx(transform);
124 xmlSecAssert2(ctx != NULL, -1);
125
126 /* initialize context */
127 memset(ctx, 0, sizeof(xmlSecGCryptDigestCtx));
128
129 #ifndef XMLSEC_NO_SHA1
130 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformSha1Id)) {
131 ctx->digest = GCRY_MD_SHA1;
132 } else
133 #endif /* XMLSEC_NO_SHA1 */
134
135 #ifndef XMLSEC_NO_SHA256
136 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformSha256Id)) {
137 ctx->digest = GCRY_MD_SHA256;
138 } else
139 #endif /* XMLSEC_NO_SHA256 */
140
141 #ifndef XMLSEC_NO_SHA384
142 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformSha384Id)) {
143 ctx->digest = GCRY_MD_SHA384;
144 } else
145 #endif /* XMLSEC_NO_SHA384 */
146
147 #ifndef XMLSEC_NO_SHA512
148 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformSha512Id)) {
149 ctx->digest = GCRY_MD_SHA512;
150 } else
151 #endif /* XMLSEC_NO_SHA512 */
152
153 #ifndef XMLSEC_NO_MD5
154 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformMd5Id)) {
155 ctx->digest = GCRY_MD_MD5;
156 } else
157 #endif /* XMLSEC_NO_MD5 */
158
159 #ifndef XMLSEC_NO_RIPEMD160
160 if(xmlSecTransformCheckId(transform, xmlSecGCryptTransformRipemd160Id)) {
161 ctx->digest = GCRY_MD_RMD160;
162 } else
163 #endif /* XMLSEC_NO_RIPEMD160 */
164
165 if(1) {
166 xmlSecInvalidTransfromError(transform)
167 return(-1);
168 }
169
170 /* create digest ctx */
171 err = gcry_md_open(&ctx->digestCtx, ctx->digest, GCRY_MD_FLAG_SECURE); /* we are paranoid */
172 if(err != GPG_ERR_NO_ERROR) {
173 xmlSecGCryptError("gcry_md_open", err,
174 xmlSecTransformGetName(transform));
175 return(-1);
176 }
177 return(0);
178 }
179
180 static void
xmlSecGCryptDigestFinalize(xmlSecTransformPtr transform)181 xmlSecGCryptDigestFinalize(xmlSecTransformPtr transform) {
182 xmlSecGCryptDigestCtxPtr ctx;
183
184 xmlSecAssert(xmlSecGCryptDigestCheckId(transform));
185 xmlSecAssert(xmlSecTransformCheckSize(transform, xmlSecGCryptDigestSize));
186
187 ctx = xmlSecGCryptDigestGetCtx(transform);
188 xmlSecAssert(ctx != NULL);
189
190 if(ctx->digestCtx != NULL) {
191 gcry_md_close(ctx->digestCtx);
192 }
193 memset(ctx, 0, sizeof(xmlSecGCryptDigestCtx));
194 }
195
196 static int
xmlSecGCryptDigestVerify(xmlSecTransformPtr transform,const xmlSecByte * data,xmlSecSize dataSize,xmlSecTransformCtxPtr transformCtx)197 xmlSecGCryptDigestVerify(xmlSecTransformPtr transform,
198 const xmlSecByte* data, xmlSecSize dataSize,
199 xmlSecTransformCtxPtr transformCtx) {
200 xmlSecGCryptDigestCtxPtr ctx;
201
202 xmlSecAssert2(xmlSecGCryptDigestCheckId(transform), -1);
203 xmlSecAssert2(transform->operation == xmlSecTransformOperationVerify, -1);
204 xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecGCryptDigestSize), -1);
205 xmlSecAssert2(transform->status == xmlSecTransformStatusFinished, -1);
206 xmlSecAssert2(data != NULL, -1);
207 xmlSecAssert2(transformCtx != NULL, -1);
208
209 ctx = xmlSecGCryptDigestGetCtx(transform);
210 xmlSecAssert2(ctx != NULL, -1);
211 xmlSecAssert2(ctx->dgstSize > 0, -1);
212
213 if(dataSize != ctx->dgstSize) {
214 xmlSecInvalidSizeError("Input data",
215 dataSize, ctx->dgstSize, xmlSecTransformGetName(transform));
216 transform->status = xmlSecTransformStatusFail;
217 return(0);
218 }
219
220 if(memcmp(ctx->dgst, data, dataSize) != 0) {
221 xmlSecInvalidDataError("data and digest do not match",
222 xmlSecTransformGetName(transform));
223 transform->status = xmlSecTransformStatusFail;
224 return(0);
225 }
226
227 transform->status = xmlSecTransformStatusOk;
228 return(0);
229 }
230
231 static int
xmlSecGCryptDigestExecute(xmlSecTransformPtr transform,int last,xmlSecTransformCtxPtr transformCtx)232 xmlSecGCryptDigestExecute(xmlSecTransformPtr transform, int last, xmlSecTransformCtxPtr transformCtx) {
233 xmlSecGCryptDigestCtxPtr ctx;
234 xmlSecBufferPtr in, out;
235 int ret;
236
237 xmlSecAssert2(xmlSecGCryptDigestCheckId(transform), -1);
238 xmlSecAssert2((transform->operation == xmlSecTransformOperationSign) || (transform->operation == xmlSecTransformOperationVerify), -1);
239 xmlSecAssert2(transformCtx != NULL, -1);
240 xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecGCryptDigestSize), -1);
241
242 ctx = xmlSecGCryptDigestGetCtx(transform);
243 xmlSecAssert2(ctx != NULL, -1);
244 xmlSecAssert2(ctx->digest != GCRY_MD_NONE, -1);
245 xmlSecAssert2(ctx->digestCtx != NULL, -1);
246
247 in = &(transform->inBuf);
248 out = &(transform->outBuf);
249
250 if(transform->status == xmlSecTransformStatusNone) {
251 transform->status = xmlSecTransformStatusWorking;
252 }
253
254 if(transform->status == xmlSecTransformStatusWorking) {
255 xmlSecSize inSize;
256
257 inSize = xmlSecBufferGetSize(in);
258 if(inSize > 0) {
259 gcry_md_write(ctx->digestCtx, xmlSecBufferGetData(in), inSize);
260
261 ret = xmlSecBufferRemoveHead(in, inSize);
262 if(ret < 0) {
263 xmlSecInternalError2("xmlSecBufferRemoveHead",
264 xmlSecTransformGetName(transform),
265 "size=%d", inSize);
266 return(-1);
267 }
268 }
269 if(last != 0) {
270 xmlSecByte* buf;
271
272 /* get the final digest */
273 gcry_md_final(ctx->digestCtx);
274 buf = gcry_md_read(ctx->digestCtx, ctx->digest);
275 if(buf == NULL) {
276 xmlSecGCryptError("gcry_md_read", GPG_ERR_NO_ERROR,
277 xmlSecTransformGetName(transform));
278 return(-1);
279 }
280
281 /* copy it to our internal buffer */
282 ctx->dgstSize = gcry_md_get_algo_dlen(ctx->digest);
283 xmlSecAssert2(ctx->dgstSize > 0, -1);
284 xmlSecAssert2(ctx->dgstSize <= sizeof(ctx->dgst), -1);
285 memcpy(ctx->dgst, buf, ctx->dgstSize);
286
287 /* and to the output if needed */
288 if(transform->operation == xmlSecTransformOperationSign) {
289 ret = xmlSecBufferAppend(out, ctx->dgst, ctx->dgstSize);
290 if(ret < 0) {
291 xmlSecInternalError2("xmlSecBufferAppend",
292 xmlSecTransformGetName(transform),
293 "size=%d", ctx->dgstSize);
294 return(-1);
295 }
296 }
297 transform->status = xmlSecTransformStatusFinished;
298 }
299 } else if(transform->status == xmlSecTransformStatusFinished) {
300 /* the only way we can get here is if there is no input */
301 xmlSecAssert2(xmlSecBufferGetSize(&(transform->inBuf)) == 0, -1);
302 } else {
303 xmlSecInvalidTransfromStatusError(transform);
304 return(-1);
305 }
306
307 return(0);
308 }
309
310 #ifndef XMLSEC_NO_SHA1
311 /******************************************************************************
312 *
313 * SHA1 Digest transforms
314 *
315 *****************************************************************************/
316 static xmlSecTransformKlass xmlSecGCryptSha1Klass = {
317 /* klass/object sizes */
318 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
319 xmlSecGCryptDigestSize, /* xmlSecSize objSize */
320
321 /* data */
322 xmlSecNameSha1, /* const xmlChar* name; */
323 xmlSecHrefSha1, /* const xmlChar* href; */
324 xmlSecTransformUsageDigestMethod, /* xmlSecTransformUsage usage; */
325
326 /* methods */
327 xmlSecGCryptDigestInitialize, /* xmlSecTransformInitializeMethod initialize; */
328 xmlSecGCryptDigestFinalize, /* xmlSecTransformFinalizeMethod finalize; */
329 NULL, /* xmlSecTransformNodeReadMethod readNode; */
330 NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
331 NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
332 NULL, /* xmlSecTransformSetKeyMethod setKey; */
333 xmlSecGCryptDigestVerify, /* xmlSecTransformVerifyMethod verify; */
334 xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
335 xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
336 xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
337 NULL, /* xmlSecTransformPushXmlMethod pushXml; */
338 NULL, /* xmlSecTransformPopXmlMethod popXml; */
339 xmlSecGCryptDigestExecute, /* xmlSecTransformExecuteMethod execute; */
340
341 NULL, /* void* reserved0; */
342 NULL, /* void* reserved1; */
343 };
344
345 /**
346 * xmlSecGCryptTransformSha1GetKlass:
347 *
348 * SHA-1 digest transform klass.
349 *
350 * Returns: pointer to SHA-1 digest transform klass.
351 */
352 xmlSecTransformId
xmlSecGCryptTransformSha1GetKlass(void)353 xmlSecGCryptTransformSha1GetKlass(void) {
354 return(&xmlSecGCryptSha1Klass);
355 }
356 #endif /* XMLSEC_NO_SHA1 */
357
358
359 #ifndef XMLSEC_NO_SHA256
360 /******************************************************************************
361 *
362 * SHA256 Digest transforms
363 *
364 *****************************************************************************/
365 static xmlSecTransformKlass xmlSecGCryptSha256Klass = {
366 /* klass/object sizes */
367 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
368 xmlSecGCryptDigestSize, /* xmlSecSize objSize */
369
370 /* data */
371 xmlSecNameSha256, /* const xmlChar* name; */
372 xmlSecHrefSha256, /* const xmlChar* href; */
373 xmlSecTransformUsageDigestMethod, /* xmlSecTransformUsage usage; */
374
375 /* methods */
376 xmlSecGCryptDigestInitialize, /* xmlSecTransformInitializeMethod initialize; */
377 xmlSecGCryptDigestFinalize, /* xmlSecTransformFinalizeMethod finalize; */
378 NULL, /* xmlSecTransformNodeReadMethod readNode; */
379 NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
380 NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
381 NULL, /* xmlSecTransformSetKeyMethod setKey; */
382 xmlSecGCryptDigestVerify, /* xmlSecTransformVerifyMethod verify; */
383 xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
384 xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
385 xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
386 NULL, /* xmlSecTransformPushXmlMethod pushXml; */
387 NULL, /* xmlSecTransformPopXmlMethod popXml; */
388 xmlSecGCryptDigestExecute, /* xmlSecTransformExecuteMethod execute; */
389
390 NULL, /* void* reserved0; */
391 NULL, /* void* reserved1; */
392 };
393
394 /**
395 * xmlSecGCryptTransformSha256GetKlass:
396 *
397 * SHA256 digest transform klass.
398 *
399 * Returns: pointer to SHA256 digest transform klass.
400 */
401 xmlSecTransformId
xmlSecGCryptTransformSha256GetKlass(void)402 xmlSecGCryptTransformSha256GetKlass(void) {
403 return(&xmlSecGCryptSha256Klass);
404 }
405 #endif /* XMLSEC_NO_SHA256 */
406
407 #ifndef XMLSEC_NO_SHA384
408 /******************************************************************************
409 *
410 * SHA384 Digest transforms
411 *
412 *****************************************************************************/
413 static xmlSecTransformKlass xmlSecGCryptSha384Klass = {
414 /* klass/object sizes */
415 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
416 xmlSecGCryptDigestSize, /* xmlSecSize objSize */
417
418 /* data */
419 xmlSecNameSha384, /* const xmlChar* name; */
420 xmlSecHrefSha384, /* const xmlChar* href; */
421 xmlSecTransformUsageDigestMethod, /* xmlSecTransformUsage usage; */
422
423 /* methods */
424 xmlSecGCryptDigestInitialize, /* xmlSecTransformInitializeMethod initialize; */
425 xmlSecGCryptDigestFinalize, /* xmlSecTransformFinalizeMethod finalize; */
426 NULL, /* xmlSecTransformNodeReadMethod readNode; */
427 NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
428 NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
429 NULL, /* xmlSecTransformSetKeyMethod setKey; */
430 xmlSecGCryptDigestVerify, /* xmlSecTransformVerifyMethod verify; */
431 xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
432 xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
433 xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
434 NULL, /* xmlSecTransformPushXmlMethod pushXml; */
435 NULL, /* xmlSecTransformPopXmlMethod popXml; */
436 xmlSecGCryptDigestExecute, /* xmlSecTransformExecuteMethod execute; */
437
438 NULL, /* void* reserved0; */
439 NULL, /* void* reserved1; */
440 };
441
442 /**
443 * xmlSecGCryptTransformSha384GetKlass:
444 *
445 * SHA384 digest transform klass.
446 *
447 * Returns: pointer to SHA384 digest transform klass.
448 */
449 xmlSecTransformId
xmlSecGCryptTransformSha384GetKlass(void)450 xmlSecGCryptTransformSha384GetKlass(void) {
451 return(&xmlSecGCryptSha384Klass);
452 }
453 #endif /* XMLSEC_NO_SHA384 */
454
455 #ifndef XMLSEC_NO_SHA512
456 /******************************************************************************
457 *
458 * SHA512 Digest transforms
459 *
460 *****************************************************************************/
461 static xmlSecTransformKlass xmlSecGCryptSha512Klass = {
462 /* klass/object sizes */
463 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
464 xmlSecGCryptDigestSize, /* xmlSecSize objSize */
465
466 /* data */
467 xmlSecNameSha512, /* const xmlChar* name; */
468 xmlSecHrefSha512, /* const xmlChar* href; */
469 xmlSecTransformUsageDigestMethod, /* xmlSecTransformUsage usage; */
470
471 /* methods */
472 xmlSecGCryptDigestInitialize, /* xmlSecTransformInitializeMethod initialize; */
473 xmlSecGCryptDigestFinalize, /* xmlSecTransformFinalizeMethod finalize; */
474 NULL, /* xmlSecTransformNodeReadMethod readNode; */
475 NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
476 NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
477 NULL, /* xmlSecTransformSetKeyMethod setKey; */
478 xmlSecGCryptDigestVerify, /* xmlSecTransformVerifyMethod verify; */
479 xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
480 xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
481 xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
482 NULL, /* xmlSecTransformPushXmlMethod pushXml; */
483 NULL, /* xmlSecTransformPopXmlMethod popXml; */
484 xmlSecGCryptDigestExecute, /* xmlSecTransformExecuteMethod execute; */
485
486 NULL, /* void* reserved0; */
487 NULL, /* void* reserved1; */
488 };
489
490 /**
491 * xmlSecGCryptTransformSha512GetKlass:
492 *
493 * SHA512 digest transform klass.
494 *
495 * Returns: pointer to SHA512 digest transform klass.
496 */
497 xmlSecTransformId
xmlSecGCryptTransformSha512GetKlass(void)498 xmlSecGCryptTransformSha512GetKlass(void) {
499 return(&xmlSecGCryptSha512Klass);
500 }
501 #endif /* XMLSEC_NO_SHA512 */
502
503 #ifndef XMLSEC_NO_MD5
504 /******************************************************************************
505 *
506 * MD5 Digest transforms
507 *
508 *****************************************************************************/
509 static xmlSecTransformKlass xmlSecGCryptMd5Klass = {
510 /* klass/object sizes */
511 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
512 xmlSecGCryptDigestSize, /* xmlSecSize objSize */
513
514 /* data */
515 xmlSecNameMd5, /* const xmlChar* name; */
516 xmlSecHrefMd5, /* const xmlChar* href; */
517 xmlSecTransformUsageDigestMethod, /* xmlSecTransformUsage usage; */
518
519 /* methods */
520 xmlSecGCryptDigestInitialize, /* xmlSecTransformInitializeMethod initialize; */
521 xmlSecGCryptDigestFinalize, /* xmlSecTransformFinalizeMethod finalize; */
522 NULL, /* xmlSecTransformNodeReadMethod readNode; */
523 NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
524 NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
525 NULL, /* xmlSecTransformSetKeyMethod setKey; */
526 xmlSecGCryptDigestVerify, /* xmlSecTransformVerifyMethod verify; */
527 xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
528 xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
529 xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
530 NULL, /* xmlSecTransformPushXmlMethod pushXml; */
531 NULL, /* xmlSecTransformPopXmlMethod popXml; */
532 xmlSecGCryptDigestExecute, /* xmlSecTransformExecuteMethod execute; */
533
534 NULL, /* void* reserved0; */
535 NULL, /* void* reserved1; */
536 };
537
538 /**
539 * xmlSecGCryptTransformMd5GetKlass:
540 *
541 * MD5 digest transform klass.
542 *
543 * Returns: pointer to MD5 digest transform klass.
544 */
545 xmlSecTransformId
xmlSecGCryptTransformMd5GetKlass(void)546 xmlSecGCryptTransformMd5GetKlass(void) {
547 return(&xmlSecGCryptMd5Klass);
548 }
549 #endif /* XMLSEC_NO_MD5 */
550
551 #ifndef XMLSEC_NO_RIPEMD160
552 /******************************************************************************
553 *
554 * RIPEMD160 Digest transforms
555 *
556 *****************************************************************************/
557 static xmlSecTransformKlass xmlSecGCryptRipemd160Klass = {
558 /* klass/object sizes */
559 sizeof(xmlSecTransformKlass), /* xmlSecSize klassSize */
560 xmlSecGCryptDigestSize, /* xmlSecSize objSize */
561
562 /* data */
563 xmlSecNameRipemd160, /* const xmlChar* name; */
564 xmlSecHrefRipemd160, /* const xmlChar* href; */
565 xmlSecTransformUsageDigestMethod, /* xmlSecTransformUsage usage; */
566
567 /* methods */
568 xmlSecGCryptDigestInitialize, /* xmlSecTransformInitializeMethod initialize; */
569 xmlSecGCryptDigestFinalize, /* xmlSecTransformFinalizeMethod finalize; */
570 NULL, /* xmlSecTransformNodeReadMethod readNode; */
571 NULL, /* xmlSecTransformNodeWriteMethod writeNode; */
572 NULL, /* xmlSecTransformSetKeyReqMethod setKeyReq; */
573 NULL, /* xmlSecTransformSetKeyMethod setKey; */
574 xmlSecGCryptDigestVerify, /* xmlSecTransformVerifyMethod verify; */
575 xmlSecTransformDefaultGetDataType, /* xmlSecTransformGetDataTypeMethod getDataType; */
576 xmlSecTransformDefaultPushBin, /* xmlSecTransformPushBinMethod pushBin; */
577 xmlSecTransformDefaultPopBin, /* xmlSecTransformPopBinMethod popBin; */
578 NULL, /* xmlSecTransformPushXmlMethod pushXml; */
579 NULL, /* xmlSecTransformPopXmlMethod popXml; */
580 xmlSecGCryptDigestExecute, /* xmlSecTransformExecuteMethod execute; */
581
582 NULL, /* void* reserved0; */
583 NULL, /* void* reserved1; */
584 };
585
586 /**
587 * xmlSecGCryptTransformRipemd160GetKlass:
588 *
589 * RIPEMD160 digest transform klass.
590 *
591 * Returns: pointer to RIPEMD160 digest transform klass.
592 */
593 xmlSecTransformId
xmlSecGCryptTransformRipemd160GetKlass(void)594 xmlSecGCryptTransformRipemd160GetKlass(void) {
595 return(&xmlSecGCryptRipemd160Klass);
596 }
597 #endif /* XMLSEC_NO_RIPEMD160 */
598