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) 2003 Cordys R&D BV, All rights reserved.
9  * Copyright (C) 2003-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved.
10  */
11 /**
12  * SECTION:kw_aes
13  * @Short_description: AES Key Transport transforms implementation for Microsoft Crypto API.
14  * @Stability: Private
15  *
16  */
17 
18 #include "globals.h"
19 
20 #include <string.h>
21 
22 #include <windows.h>
23 #include <wincrypt.h>
24 
25 #include <xmlsec/xmlsec.h>
26 #include <xmlsec/keys.h>
27 #include <xmlsec/transforms.h>
28 #include <xmlsec/errors.h>
29 
30 #include <xmlsec/mscrypto/crypto.h>
31 
32 #include "../kw_aes_des.h"
33 #include "private.h"
34 
35 
36 #ifndef XMLSEC_NO_AES
37 
38 /*********************************************************************
39  *
40  * AES KW implementation
41  *
42  *********************************************************************/
43 static int      xmlSecMSCryptoKWAesBlockEncrypt         (const xmlSecByte * in,
44                                                          xmlSecSize inSize,
45                                                          xmlSecByte * out,
46                                                          xmlSecSize outSize,
47                                                          void * cb_ctx);
48 static int      xmlSecMSCryptoKWAesBlockDecrypt         (const xmlSecByte * in,
49                                                          xmlSecSize inSize,
50                                                          xmlSecByte * out,
51                                                          xmlSecSize outSize,
52                                                          void * cb_ctx);
53 
54 /* klass for KW AES operation */
55 static xmlSecKWAesKlass xmlSecMSCryptoKWAesKlass = {
56     /* callbacks */
57     xmlSecMSCryptoKWAesBlockEncrypt,        /* xmlSecKWAesBlockEncryptMethod       encrypt; */
58     xmlSecMSCryptoKWAesBlockDecrypt,        /* xmlSecKWAesBlockDecryptMethod       decrypt; */
59 
60     /* for the future */
61     NULL,                                   /* void*                               reserved0; */
62     NULL                                    /* void*                               reserved1; */
63 };
64 
65 /**************************************************************************
66  *
67  * Internal MSCrypto KW AES cipher CTX
68  *
69  *****************************************************************************/
70 typedef struct _xmlSecMSCryptoKWAesCtx                  xmlSecMSCryptoKWAesCtx,
71                                                         *xmlSecMSCryptoKWAesCtxPtr;
72 struct _xmlSecMSCryptoKWAesCtx {
73     ALG_ID                              algorithmIdentifier;
74     const xmlSecMSCryptoProviderInfo  * providers;
75     xmlSecKeyDataId                     keyId;
76     xmlSecSize                          keySize;
77 
78     HCRYPTPROV                          cryptProvider;
79     HCRYPTKEY                           pubPrivKey;
80     xmlSecBuffer                        keyBuffer;
81 };
82 
83 /******************************************************************************
84  *
85  *  KW AES transforms
86  *
87  * xmlSecMSCryptoKWAesCtx block is located after xmlSecTransform structure
88  *
89  *****************************************************************************/
90 #define xmlSecMSCryptoKWAesSize   \
91     (sizeof(xmlSecTransform) + sizeof(xmlSecMSCryptoKWAesCtx))
92 #define xmlSecMSCryptoKWAesGetCtx(transform) \
93     ((xmlSecMSCryptoKWAesCtxPtr)(((unsigned char*)(transform)) + sizeof(xmlSecTransform)))
94 
95 static int      xmlSecMSCryptoKWAesInitialize       (xmlSecTransformPtr transform);
96 static void     xmlSecMSCryptoKWAesFinalize         (xmlSecTransformPtr transform);
97 static int      xmlSecMSCryptoKWAesSetKeyReq        (xmlSecTransformPtr transform,
98                                                      xmlSecKeyReqPtr keyReq);
99 static int      xmlSecMSCryptoKWAesSetKey           (xmlSecTransformPtr transform,
100                                                      xmlSecKeyPtr key);
101 static int      xmlSecMSCryptoKWAesExecute          (xmlSecTransformPtr transform,
102                                                      int last,
103                                                      xmlSecTransformCtxPtr transformCtx);
104 static int      xmlSecMSCryptoKWAesCheckId          (xmlSecTransformPtr transform);
105 
106 
107 
108 
109 /* Ordered list of providers to search for algorithm implementation using
110  * xmlSecMSCryptoFindProvider() function
111  *
112  * MUST END with { NULL, 0 } !!!
113  */
114 static xmlSecMSCryptoProviderInfo xmlSecMSCryptoProviderInfo_Aes[] = {
115     { XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV,                PROV_RSA_AES},
116     { XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV_PROTOTYPE,      PROV_RSA_AES },
117     { NULL, 0 }
118 };
119 
120 static int
xmlSecMSCryptoKWAesCheckId(xmlSecTransformPtr transform)121 xmlSecMSCryptoKWAesCheckId(xmlSecTransformPtr transform) {
122 
123     if(xmlSecTransformCheckId(transform, xmlSecMSCryptoTransformKWAes128Id) ||
124        xmlSecTransformCheckId(transform, xmlSecMSCryptoTransformKWAes192Id) ||
125        xmlSecTransformCheckId(transform, xmlSecMSCryptoTransformKWAes256Id)) {
126 
127        return(1);
128     }
129 
130     return(0);
131 }
132 
133 static int
xmlSecMSCryptoKWAesInitialize(xmlSecTransformPtr transform)134 xmlSecMSCryptoKWAesInitialize(xmlSecTransformPtr transform) {
135     xmlSecMSCryptoKWAesCtxPtr ctx;
136     int ret;
137 
138     xmlSecAssert2(xmlSecMSCryptoKWAesCheckId(transform), -1);
139     xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecMSCryptoKWAesSize), -1);
140 
141     ctx = xmlSecMSCryptoKWAesGetCtx(transform);
142     xmlSecAssert2(ctx != NULL, -1);
143 
144     memset(ctx, 0, sizeof(xmlSecMSCryptoKWAesCtx));
145 
146     if(transform->id == xmlSecMSCryptoTransformKWAes128Id) {
147         ctx->algorithmIdentifier    = CALG_AES_128;
148         ctx->keyId                  = xmlSecMSCryptoKeyDataAesId;
149         ctx->providers              = xmlSecMSCryptoProviderInfo_Aes;
150         ctx->keySize                = XMLSEC_KW_AES128_KEY_SIZE;
151     } else if(transform->id == xmlSecMSCryptoTransformKWAes192Id) {
152         ctx->algorithmIdentifier    = CALG_AES_192;
153         ctx->keyId                  = xmlSecMSCryptoKeyDataAesId;
154         ctx->providers              = xmlSecMSCryptoProviderInfo_Aes;
155         ctx->keySize                = XMLSEC_KW_AES192_KEY_SIZE;
156     } else if(transform->id == xmlSecMSCryptoTransformKWAes256Id) {
157         ctx->algorithmIdentifier    = CALG_AES_256;
158         ctx->keyId                  = xmlSecMSCryptoKeyDataAesId;
159         ctx->providers              = xmlSecMSCryptoProviderInfo_Aes;
160         ctx->keySize                = XMLSEC_KW_AES256_KEY_SIZE;
161     } else {
162         xmlSecInvalidTransfromError(transform)
163         return(-1);
164     }
165 
166     ret = xmlSecBufferInitialize(&ctx->keyBuffer, 0);
167     if(ret < 0) {
168         xmlSecInternalError("xmlSecBufferInitialize",
169                 xmlSecTransformGetName(transform));
170         return(-1);
171     }
172 
173     /* find provider */
174     ctx->cryptProvider = xmlSecMSCryptoFindProvider(ctx->providers, NULL, CRYPT_VERIFYCONTEXT, TRUE);
175     if(ctx->cryptProvider == 0) {
176         xmlSecInternalError("xmlSecMSCryptoFindProvider",
177                              xmlSecTransformGetName(transform));
178         return(-1);
179     }
180 
181     /* Create dummy key to be able to import plain session keys */
182     if (!xmlSecMSCryptoCreatePrivateExponentOneKey(ctx->cryptProvider, &(ctx->pubPrivKey))) {
183         xmlSecInternalError("xmlSecMSCryptoCreatePrivateExponentOneKey",
184                              xmlSecTransformGetName(transform));
185         return(-1);
186     }
187 
188     return(0);
189 }
190 
191 static void
xmlSecMSCryptoKWAesFinalize(xmlSecTransformPtr transform)192 xmlSecMSCryptoKWAesFinalize(xmlSecTransformPtr transform) {
193     xmlSecMSCryptoKWAesCtxPtr ctx;
194 
195     xmlSecAssert(xmlSecMSCryptoKWAesCheckId(transform));
196     xmlSecAssert(xmlSecTransformCheckSize(transform, xmlSecMSCryptoKWAesSize));
197 
198     ctx = xmlSecMSCryptoKWAesGetCtx(transform);
199     xmlSecAssert(ctx != NULL);
200 
201     if (ctx->pubPrivKey) {
202         CryptDestroyKey(ctx->pubPrivKey);
203     }
204     if (ctx->cryptProvider) {
205         CryptReleaseContext(ctx->cryptProvider, 0);
206     }
207 
208     xmlSecBufferFinalize(&ctx->keyBuffer);
209 
210     memset(ctx, 0, sizeof(xmlSecMSCryptoKWAesCtx));
211 }
212 
213 static int
xmlSecMSCryptoKWAesSetKeyReq(xmlSecTransformPtr transform,xmlSecKeyReqPtr keyReq)214 xmlSecMSCryptoKWAesSetKeyReq(xmlSecTransformPtr transform,  xmlSecKeyReqPtr keyReq) {
215     xmlSecMSCryptoKWAesCtxPtr ctx;
216 
217     xmlSecAssert2(xmlSecMSCryptoKWAesCheckId(transform), -1);
218     xmlSecAssert2((transform->operation == xmlSecTransformOperationEncrypt) || (transform->operation == xmlSecTransformOperationDecrypt), -1);
219     xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecMSCryptoKWAesSize), -1);
220     xmlSecAssert2(keyReq != NULL, -1);
221 
222     ctx = xmlSecMSCryptoKWAesGetCtx(transform);
223     xmlSecAssert2(ctx != NULL, -1);
224     xmlSecAssert2(ctx->cryptProvider != 0, -1);
225 
226     keyReq->keyId       = ctx->keyId;
227     keyReq->keyType     = xmlSecKeyDataTypeSymmetric;
228     if(transform->operation == xmlSecTransformOperationEncrypt) {
229         keyReq->keyUsage = xmlSecKeyUsageEncrypt;
230     } else {
231         keyReq->keyUsage = xmlSecKeyUsageDecrypt;
232     }
233 
234     keyReq->keyBitsSize = 8 * ctx->keySize;
235     return(0);
236 }
237 
238 
239 
240 static int
xmlSecMSCryptoKWAesSetKey(xmlSecTransformPtr transform,xmlSecKeyPtr key)241 xmlSecMSCryptoKWAesSetKey(xmlSecTransformPtr transform, xmlSecKeyPtr key) {
242     xmlSecMSCryptoKWAesCtxPtr ctx;
243     xmlSecBufferPtr buffer;
244     xmlSecSize keySize;
245     int ret;
246 
247     xmlSecAssert2(xmlSecMSCryptoKWAesCheckId(transform), -1);
248     xmlSecAssert2((transform->operation == xmlSecTransformOperationEncrypt) || (transform->operation == xmlSecTransformOperationDecrypt), -1);
249     xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecMSCryptoKWAesSize), -1);
250     xmlSecAssert2(key != NULL, -1);
251     xmlSecAssert2(xmlSecKeyDataCheckId(xmlSecKeyGetValue(key), xmlSecMSCryptoKeyDataAesId), -1);
252 
253     ctx = xmlSecMSCryptoKWAesGetCtx(transform);
254     xmlSecAssert2(ctx != NULL, -1);
255 
256     buffer = xmlSecKeyDataBinaryValueGetBuffer(xmlSecKeyGetValue(key));
257     xmlSecAssert2(buffer != NULL, -1);
258 
259     keySize = xmlSecBufferGetSize(buffer);
260     if(keySize < ctx->keySize) {
261         xmlSecInvalidKeyDataSizeError(keySize, ctx->keySize,
262                 xmlSecTransformGetName(transform));
263         return(-1);
264     }
265 
266     ret = xmlSecBufferSetData(&(ctx->keyBuffer),
267                             xmlSecBufferGetData(buffer),
268                             ctx->keySize);
269     if(ret < 0) {
270         xmlSecInternalError2("xmlSecBufferSetData",
271                              xmlSecTransformGetName(transform),
272                              "size=%d", ctx->keySize);
273         return(-1);
274     }
275 
276     return(0);
277 }
278 
279 static int
xmlSecMSCryptoKWAesExecute(xmlSecTransformPtr transform,int last,xmlSecTransformCtxPtr transformCtx)280 xmlSecMSCryptoKWAesExecute(xmlSecTransformPtr transform, int last, xmlSecTransformCtxPtr transformCtx) {
281     xmlSecMSCryptoKWAesCtxPtr ctx;
282     xmlSecBufferPtr in, out;
283     xmlSecSize inSize, outSize;
284     int ret;
285 
286     xmlSecAssert2(xmlSecMSCryptoKWAesCheckId(transform), -1);
287     xmlSecAssert2((transform->operation == xmlSecTransformOperationEncrypt) || (transform->operation == xmlSecTransformOperationDecrypt), -1);
288     xmlSecAssert2(xmlSecTransformCheckSize(transform, xmlSecMSCryptoKWAesSize), -1);
289     xmlSecAssert2(transformCtx != NULL, -1);
290 
291     ctx = xmlSecMSCryptoKWAesGetCtx(transform);
292     xmlSecAssert2(ctx != NULL, -1);
293 
294     in = &(transform->inBuf);
295     out = &(transform->outBuf);
296     inSize = xmlSecBufferGetSize(in);
297     outSize = xmlSecBufferGetSize(out);
298     xmlSecAssert2(outSize == 0, -1);
299 
300     if(transform->status == xmlSecTransformStatusNone) {
301         transform->status = xmlSecTransformStatusWorking;
302     }
303 
304     if((transform->status == xmlSecTransformStatusWorking) && (last == 0)) {
305         /* just do nothing */
306     } else  if((transform->status == xmlSecTransformStatusWorking) && (last != 0)) {
307         if((inSize % 8) != 0) {
308             xmlSecInvalidSizeNotMultipleOfError("Input data", inSize, 8,
309                                                 xmlSecTransformGetName(transform));
310             return(-1);
311         }
312 
313         if(transform->operation == xmlSecTransformOperationEncrypt) {
314             /* the encoded key might be 8 bytes longer plus 8 bytes just in case */
315             outSize = inSize + XMLSEC_KW_AES_MAGIC_BLOCK_SIZE +
316                                XMLSEC_KW_AES_BLOCK_SIZE;
317         } else {
318             outSize = inSize + XMLSEC_KW_AES_BLOCK_SIZE;
319         }
320 
321         ret = xmlSecBufferSetMaxSize(out, outSize);
322         if(ret < 0) {
323             xmlSecInternalError2("xmlSecBufferSetMaxSize",
324                                  xmlSecTransformGetName(transform),
325                                  "size=%d", outSize);
326             return(-1);
327         }
328 
329         if(transform->operation == xmlSecTransformOperationEncrypt) {
330             ret = xmlSecKWAesEncode(&xmlSecMSCryptoKWAesKlass, ctx,
331                                     xmlSecBufferGetData(in), inSize,
332                                     xmlSecBufferGetData(out), outSize);
333             if(ret < 0) {
334                 xmlSecInternalError("xmlSecKWAesEncode",
335                                     xmlSecTransformGetName(transform));
336                 return(-1);
337             }
338             outSize = ret;
339         } else {
340             ret = xmlSecKWAesDecode(&xmlSecMSCryptoKWAesKlass, ctx,
341                                     xmlSecBufferGetData(in), inSize,
342                                     xmlSecBufferGetData(out), outSize);
343             if(ret < 0) {
344                 xmlSecInternalError("xmlSecKWAesEncode",
345                                     xmlSecTransformGetName(transform));
346                 return(-1);
347             }
348             outSize = ret;
349         }
350 
351         ret = xmlSecBufferSetSize(out, outSize);
352         if(ret < 0) {
353             xmlSecInternalError2("xmlSecBufferSetSize",
354                                  xmlSecTransformGetName(transform),
355                                  "size=%d", outSize);
356             return(-1);
357         }
358 
359         ret = xmlSecBufferRemoveHead(in, inSize);
360         if(ret < 0) {
361             xmlSecInternalError2("xmlSecBufferRemoveHead",
362                                  xmlSecTransformGetName(transform),
363                                  "size=%d", inSize);
364             return(-1);
365         }
366 
367         transform->status = xmlSecTransformStatusFinished;
368     } else if(transform->status == xmlSecTransformStatusFinished) {
369         /* the only way we can get here is if there is no input */
370         xmlSecAssert2(xmlSecBufferGetSize(&(transform->inBuf)) == 0, -1);
371     } else {
372         xmlSecInvalidTransfromStatusError(transform);
373         return(-1);
374     }
375     return(0);
376 }
377 
378 
379 /*********************************************************************
380  *
381  * AES KW implementation
382  *
383  ********************************************************************/
384 static int
xmlSecMSCryptoKWAesBlockEncrypt(const xmlSecByte * in,xmlSecSize inSize,xmlSecByte * out,xmlSecSize outSize,void * context)385 xmlSecMSCryptoKWAesBlockEncrypt(const xmlSecByte * in, xmlSecSize inSize,
386                                 xmlSecByte * out, xmlSecSize outSize,
387                                 void * context) {
388     xmlSecMSCryptoKWAesCtxPtr ctx = (xmlSecMSCryptoKWAesCtxPtr)context;
389     HCRYPTKEY cryptKey = 0;
390     DWORD dwCLen;
391 
392     xmlSecAssert2(in != NULL, -1);
393     xmlSecAssert2(inSize >= XMLSEC_KW_AES_BLOCK_SIZE, -1);
394     xmlSecAssert2(out != NULL, -1);
395     xmlSecAssert2(outSize >= inSize, -1);
396     xmlSecAssert2(ctx != NULL, -1);
397     xmlSecAssert2(ctx->pubPrivKey != 0, -1);
398     xmlSecAssert2(xmlSecBufferGetSize(&ctx->keyBuffer) == ctx->keySize, -1);
399 
400     /* Import this key and get an HCRYPTKEY handle, we do it again and again
401        to ensure we don't go into CBC mode */
402     if (!xmlSecMSCryptoImportPlainSessionBlob(ctx->cryptProvider,
403         ctx->pubPrivKey,
404         ctx->algorithmIdentifier,
405         xmlSecBufferGetData(&ctx->keyBuffer),
406         xmlSecBufferGetSize(&ctx->keyBuffer),
407         TRUE,
408         &cryptKey))  {
409 
410         xmlSecInternalError("xmlSecMSCryptoImportPlainSessionBlob", NULL);
411         return(-1);
412     }
413     xmlSecAssert2(cryptKey != 0, -1);
414 
415     /* Set process last block to false, since we handle padding ourselves, and MSCrypto padding
416      * can be skipped. I hope this will work .... */
417     if(out != in) {
418         memcpy(out, in, inSize);
419     }
420     dwCLen = inSize;
421     if(!CryptEncrypt(cryptKey, 0, FALSE, 0, out, &dwCLen, outSize)) {
422         xmlSecMSCryptoError("CryptEncrypt", NULL);
423         CryptDestroyKey(cryptKey);
424         return(-1);
425     }
426 
427     /* cleanup */
428     CryptDestroyKey(cryptKey);
429     return(dwCLen);
430 }
431 
432 static int
xmlSecMSCryptoKWAesBlockDecrypt(const xmlSecByte * in,xmlSecSize inSize,xmlSecByte * out,xmlSecSize outSize,void * context)433 xmlSecMSCryptoKWAesBlockDecrypt(const xmlSecByte * in, xmlSecSize inSize,
434                                 xmlSecByte * out, xmlSecSize outSize,
435                                 void * context) {
436     xmlSecMSCryptoKWAesCtxPtr ctx = (xmlSecMSCryptoKWAesCtxPtr)context;
437     HCRYPTKEY cryptKey = 0;
438     DWORD dwCLen;
439 
440     xmlSecAssert2(in != NULL, -1);
441     xmlSecAssert2(inSize >= XMLSEC_KW_AES_BLOCK_SIZE, -1);
442     xmlSecAssert2(out != NULL, -1);
443     xmlSecAssert2(outSize >= inSize, -1);
444     xmlSecAssert2(ctx != NULL, -1);
445     xmlSecAssert2(ctx->pubPrivKey != 0, -1);
446     xmlSecAssert2(xmlSecBufferGetSize(&ctx->keyBuffer) == ctx->keySize, -1);
447 
448     /* Import this key and get an HCRYPTKEY handle, we do it again and again
449        to ensure we don't go into CBC mode */
450     if (!xmlSecMSCryptoImportPlainSessionBlob(ctx->cryptProvider,
451         ctx->pubPrivKey,
452         ctx->algorithmIdentifier,
453         xmlSecBufferGetData(&ctx->keyBuffer),
454         xmlSecBufferGetSize(&ctx->keyBuffer),
455         TRUE,
456         &cryptKey))  {
457 
458         xmlSecInternalError("xmlSecMSCryptoImportPlainSessionBlob", NULL);
459         return(-1);
460     }
461     xmlSecAssert2(cryptKey != 0, -1);
462 
463     /* Set process last block to false, since we handle padding ourselves, and MSCrypto padding
464      * can be skipped. I hope this will work .... */
465     if(out != in) {
466         memcpy(out, in, inSize);
467     }
468     dwCLen = inSize;
469     if(!CryptDecrypt(cryptKey, 0, FALSE, 0, out, &dwCLen)) {
470         xmlSecMSCryptoError("CryptDecrypt", NULL);
471         CryptDestroyKey(cryptKey);
472         return(-1);
473     }
474 
475     /* cleanup */
476     CryptDestroyKey(cryptKey);
477     return(dwCLen);
478 }
479 
480 /*********************************************************************
481  *
482  * AES KW cipher transforms
483  *
484  ********************************************************************/
485 
486 /*
487  * The AES-128 kew wrapper transform klass.
488  */
489 static xmlSecTransformKlass xmlSecMSCryptoKWAes128Klass = {
490     /* klass/object sizes */
491     sizeof(xmlSecTransformKlass),               /* xmlSecSize klassSize */
492     xmlSecMSCryptoKWAesSize,              /* xmlSecSize objSize */
493 
494     xmlSecNameKWAes128,                         /* const xmlChar* name; */
495     xmlSecHrefKWAes128,                         /* const xmlChar* href; */
496     xmlSecTransformUsageEncryptionMethod,       /* xmlSecAlgorithmUsage usage; */
497 
498     xmlSecMSCryptoKWAesInitialize,        /* xmlSecTransformInitializeMethod initialize; */
499     xmlSecMSCryptoKWAesFinalize,          /* xmlSecTransformFinalizeMethod finalize; */
500     NULL,                                       /* xmlSecTransformNodeReadMethod readNode; */
501     NULL,                                       /* xmlSecTransformNodeWriteMethod writeNode; */
502     xmlSecMSCryptoKWAesSetKeyReq,         /* xmlSecTransformSetKeyMethod setKeyReq; */
503     xmlSecMSCryptoKWAesSetKey,                  /* xmlSecTransformSetKeyMethod setKey; */
504     NULL,                                       /* xmlSecTransformValidateMethod validate; */
505     xmlSecTransformDefaultGetDataType,          /* xmlSecTransformGetDataTypeMethod getDataType; */
506     xmlSecTransformDefaultPushBin,              /* xmlSecTransformPushBinMethod pushBin; */
507     xmlSecTransformDefaultPopBin,               /* xmlSecTransformPopBinMethod popBin; */
508     NULL,                                       /* xmlSecTransformPushXmlMethod pushXml; */
509     NULL,                                       /* xmlSecTransformPopXmlMethod popXml; */
510     xmlSecMSCryptoKWAesExecute,                 /* xmlSecTransformExecuteMethod execute; */
511 
512     NULL,                                       /* void* reserved0; */
513     NULL,                                       /* void* reserved1; */
514 };
515 
516 /**
517  * xmlSecMSCryptoTransformKWAes128GetKlass:
518  *
519  * The AES-128 kew wrapper transform klass.
520  *
521  * Returns: AES-128 kew wrapper transform klass.
522  */
523 xmlSecTransformId
xmlSecMSCryptoTransformKWAes128GetKlass(void)524 xmlSecMSCryptoTransformKWAes128GetKlass(void) {
525     return(&xmlSecMSCryptoKWAes128Klass);
526 }
527 
528 
529 /*
530  * The AES-192 kew wrapper transform klass.
531  */
532 static xmlSecTransformKlass xmlSecMSCryptoKWAes192Klass = {
533     /* klass/object sizes */
534     sizeof(xmlSecTransformKlass),               /* xmlSecSize klassSize */
535     xmlSecMSCryptoKWAesSize,              /* xmlSecSize objSize */
536 
537     xmlSecNameKWAes192,                         /* const xmlChar* name; */
538     xmlSecHrefKWAes192,                         /* const xmlChar* href; */
539     xmlSecTransformUsageEncryptionMethod,       /* xmlSecAlgorithmUsage usage; */
540 
541     xmlSecMSCryptoKWAesInitialize,        /* xmlSecTransformInitializeMethod initialize; */
542     xmlSecMSCryptoKWAesFinalize,          /* xmlSecTransformFinalizeMethod finalize; */
543     NULL,                                       /* xmlSecTransformNodeReadMethod readNode; */
544     NULL,                                       /* xmlSecTransformNodeWriteMethod writeNode; */
545     xmlSecMSCryptoKWAesSetKeyReq,         /* xmlSecTransformSetKeyMethod setKeyReq; */
546     xmlSecMSCryptoKWAesSetKey,                  /* xmlSecTransformSetKeyMethod setKey; */
547     NULL,                                       /* xmlSecTransformValidateMethod validate; */
548     xmlSecTransformDefaultGetDataType,          /* xmlSecTransformGetDataTypeMethod getDataType; */
549     xmlSecTransformDefaultPushBin,              /* xmlSecTransformPushBinMethod pushBin; */
550     xmlSecTransformDefaultPopBin,               /* xmlSecTransformPopBinMethod popBin; */
551     NULL,                                       /* xmlSecTransformPushXmlMethod pushXml; */
552     NULL,                                       /* xmlSecTransformPopXmlMethod popXml; */
553     xmlSecMSCryptoKWAesExecute,                 /* xmlSecTransformExecuteMethod execute; */
554 
555     NULL,                                       /* void* reserved0; */
556     NULL,                                       /* void* reserved1; */
557 };
558 
559 /**
560  * xmlSecMSCryptoTransformKWAes192GetKlass:
561  *
562  * The AES-192 kew wrapper transform klass.
563  *
564  * Returns: AES-192 kew wrapper transform klass.
565  */
566 xmlSecTransformId
xmlSecMSCryptoTransformKWAes192GetKlass(void)567 xmlSecMSCryptoTransformKWAes192GetKlass(void) {
568     return(&xmlSecMSCryptoKWAes192Klass);
569 }
570 
571 /*
572  * The AES-256 kew wrapper transform klass.
573  */
574 static xmlSecTransformKlass xmlSecMSCryptoKWAes256Klass = {
575     /* klass/object sizes */
576     sizeof(xmlSecTransformKlass),               /* xmlSecSize klassSize */
577     xmlSecMSCryptoKWAesSize,              /* xmlSecSize objSize */
578 
579     xmlSecNameKWAes256,                         /* const xmlChar* name; */
580     xmlSecHrefKWAes256,                         /* const xmlChar* href; */
581     xmlSecTransformUsageEncryptionMethod,       /* xmlSecAlgorithmUsage usage; */
582 
583     xmlSecMSCryptoKWAesInitialize,        /* xmlSecTransformInitializeMethod initialize; */
584     xmlSecMSCryptoKWAesFinalize,          /* xmlSecTransformFinalizeMethod finalize; */
585     NULL,                                       /* xmlSecTransformNodeReadMethod readNode; */
586     NULL,                                       /* xmlSecTransformNodeWriteMethod writeNode; */
587     xmlSecMSCryptoKWAesSetKeyReq,         /* xmlSecTransformSetKeyMethod setKeyReq; */
588     xmlSecMSCryptoKWAesSetKey,                  /* xmlSecTransformSetKeyMethod setKey; */
589     NULL,                                       /* xmlSecTransformValidateMethod validate; */
590     xmlSecTransformDefaultGetDataType,          /* xmlSecTransformGetDataTypeMethod getDataType; */
591     xmlSecTransformDefaultPushBin,              /* xmlSecTransformPushBinMethod pushBin; */
592     xmlSecTransformDefaultPopBin,               /* xmlSecTransformPopBinMethod popBin; */
593     NULL,                                           /* xmlSecTransformPushXmlMethod pushXml; */
594     NULL,                                       /* xmlSecTransformPopXmlMethod popXml; */
595     xmlSecMSCryptoKWAesExecute,                 /* xmlSecTransformExecuteMethod execute; */
596 
597     NULL,                                       /* void* reserved0; */
598     NULL,                                       /* void* reserved1; */
599 };
600 
601 /**
602  * xmlSecMSCryptoTransformKWAes256GetKlass:
603  *
604  * The AES-256 kew wrapper transform klass.
605  *
606  * Returns: AES-256 kew wrapper transform klass.
607  */
608 xmlSecTransformId
xmlSecMSCryptoTransformKWAes256GetKlass(void)609 xmlSecMSCryptoTransformKWAes256GetKlass(void) {
610     return(&xmlSecMSCryptoKWAes256Klass);
611 }
612 
613 #endif /* XMLSEC_NO_AES */
614