|
1 /** |
|
2 * |
|
3 * XMLSec library |
|
4 * |
|
5 * DES Algorithm support |
|
6 * |
|
7 * This is free software; see Copyright file in the source |
|
8 * distribution for preciese wording. |
|
9 * |
|
10 * Copyright (C) 2002-2003 Aleksey Sanin <aleksey@aleksey.com> |
|
11 * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
|
12 */ |
|
13 #include "xmlsecc_globals.h" |
|
14 |
|
15 #include <stdlib.h> |
|
16 #include <stdio.h> |
|
17 #include <string.h> |
|
18 #include "xmlsecc_config.h" |
|
19 #include "xmlsec_xmlsec.h" |
|
20 #include "xmlsec_xmltree.h" |
|
21 #include "xmlsec_keys.h" |
|
22 #include "xmlsec_keyinfo.h" |
|
23 #include "xmlsec_transforms.h" |
|
24 #include "xmlsec_errors.h" |
|
25 |
|
26 #include "xmlsecc_crypto.h" |
|
27 |
|
28 /***************************************************************************** |
|
29 * |
|
30 * Symmetic (binary) keys - just a wrapper for xmlSecKeyDataBinary |
|
31 * |
|
32 ****************************************************************************/ |
|
33 static int xmlSecSymbianCryptoSymKeyDataInitialize (xmlSecKeyDataPtr data); |
|
34 static int xmlSecSymbianCryptoSymKeyDataDuplicate (xmlSecKeyDataPtr dst, |
|
35 xmlSecKeyDataPtr src); |
|
36 static void xmlSecSymbianCryptoSymKeyDataFinalize (xmlSecKeyDataPtr data); |
|
37 static int xmlSecSymbianCryptoSymKeyDataXmlRead (xmlSecKeyDataId id, |
|
38 xmlSecKeyPtr key, |
|
39 xmlNodePtr node, |
|
40 xmlSecKeyInfoCtxPtr keyInfoCtx); |
|
41 static int xmlSecSymbianCryptoSymKeyDataXmlWrite (xmlSecKeyDataId id, |
|
42 xmlSecKeyPtr key, |
|
43 xmlNodePtr node, |
|
44 xmlSecKeyInfoCtxPtr keyInfoCtx); |
|
45 static int xmlSecSymbianCryptoSymKeyDataBinRead (xmlSecKeyDataId id, |
|
46 xmlSecKeyPtr key, |
|
47 const xmlSecByte* buf, |
|
48 xmlSecSize bufSize, |
|
49 xmlSecKeyInfoCtxPtr keyInfoCtx); |
|
50 static int xmlSecSymbianCryptoSymKeyDataBinWrite (xmlSecKeyDataId id, |
|
51 xmlSecKeyPtr key, |
|
52 xmlSecByte** buf, |
|
53 xmlSecSize* bufSize, |
|
54 xmlSecKeyInfoCtxPtr keyInfoCtx); |
|
55 static int xmlSecSymbianCryptoSymKeyDataGenerate (xmlSecKeyDataPtr data, |
|
56 xmlSecSize sizeBits, |
|
57 xmlSecKeyDataType type); |
|
58 |
|
59 static xmlSecKeyDataType xmlSecSymbianCryptoSymKeyDataGetType (xmlSecKeyDataPtr data); |
|
60 static xmlSecSize xmlSecSymbianCryptoSymKeyDataGetSize (xmlSecKeyDataPtr data); |
|
61 static void xmlSecSymbianCryptoSymKeyDataDebugDump (xmlSecKeyDataPtr data, |
|
62 FILE* output); |
|
63 static void xmlSecSymbianCryptoSymKeyDataDebugXmlDump (xmlSecKeyDataPtr data, |
|
64 FILE* output); |
|
65 static int xmlSecSymbianCryptoSymKeyDataKlassCheck (xmlSecKeyDataKlass* klass); |
|
66 |
|
67 #define xmlSecSymbianCryptoSymKeyDataCheckId(data) \ |
|
68 (xmlSecKeyDataIsValid((data)) && \ |
|
69 xmlSecSymbianCryptoSymKeyDataKlassCheck((data)->id)) |
|
70 |
|
71 static int |
|
72 xmlSecSymbianCryptoSymKeyDataInitialize(xmlSecKeyDataPtr data) { |
|
73 xmlSecAssert2(xmlSecSymbianCryptoSymKeyDataCheckId(data), -1); |
|
74 |
|
75 return(xmlSecKeyDataBinaryValueInitialize(data)); |
|
76 } |
|
77 |
|
78 static int |
|
79 xmlSecSymbianCryptoSymKeyDataDuplicate(xmlSecKeyDataPtr dst, xmlSecKeyDataPtr src) { |
|
80 xmlSecAssert2(xmlSecSymbianCryptoSymKeyDataCheckId(dst), -1); |
|
81 xmlSecAssert2(xmlSecSymbianCryptoSymKeyDataCheckId(src), -1); |
|
82 xmlSecAssert2(dst->id == src->id, -1); |
|
83 |
|
84 return(xmlSecKeyDataBinaryValueDuplicate(dst, src)); |
|
85 } |
|
86 |
|
87 static void |
|
88 xmlSecSymbianCryptoSymKeyDataFinalize(xmlSecKeyDataPtr data) { |
|
89 xmlSecAssert(xmlSecSymbianCryptoSymKeyDataCheckId(data)); |
|
90 |
|
91 xmlSecKeyDataBinaryValueFinalize(data); |
|
92 } |
|
93 |
|
94 static int |
|
95 xmlSecSymbianCryptoSymKeyDataXmlRead(xmlSecKeyDataId id, xmlSecKeyPtr key, |
|
96 xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) { |
|
97 xmlSecAssert2(xmlSecSymbianCryptoSymKeyDataKlassCheck(id), -1); |
|
98 |
|
99 return(xmlSecKeyDataBinaryValueXmlRead(id, key, node, keyInfoCtx)); |
|
100 } |
|
101 |
|
102 static int |
|
103 xmlSecSymbianCryptoSymKeyDataXmlWrite(xmlSecKeyDataId id, xmlSecKeyPtr key, |
|
104 xmlNodePtr node, xmlSecKeyInfoCtxPtr keyInfoCtx) { |
|
105 xmlSecAssert2(xmlSecSymbianCryptoSymKeyDataKlassCheck(id), -1); |
|
106 |
|
107 return(xmlSecKeyDataBinaryValueXmlWrite(id, key, node, keyInfoCtx)); |
|
108 } |
|
109 |
|
110 static int |
|
111 xmlSecSymbianCryptoSymKeyDataBinRead(xmlSecKeyDataId id, xmlSecKeyPtr key, |
|
112 const xmlSecByte* buf, xmlSecSize bufSize, |
|
113 xmlSecKeyInfoCtxPtr keyInfoCtx) { |
|
114 xmlSecAssert2(xmlSecSymbianCryptoSymKeyDataKlassCheck(id), -1); |
|
115 |
|
116 return(xmlSecKeyDataBinaryValueBinRead(id, key, buf, bufSize, keyInfoCtx)); |
|
117 } |
|
118 |
|
119 static int |
|
120 xmlSecSymbianCryptoSymKeyDataBinWrite(xmlSecKeyDataId id, xmlSecKeyPtr key, |
|
121 xmlSecByte** buf, xmlSecSize* bufSize, |
|
122 xmlSecKeyInfoCtxPtr keyInfoCtx) { |
|
123 xmlSecAssert2(xmlSecSymbianCryptoSymKeyDataKlassCheck(id), -1); |
|
124 |
|
125 return(xmlSecKeyDataBinaryValueBinWrite(id, key, buf, bufSize, keyInfoCtx)); |
|
126 } |
|
127 |
|
128 static int |
|
129 xmlSecSymbianCryptoSymKeyDataGenerate(xmlSecKeyDataPtr data, |
|
130 xmlSecSize sizeBits, |
|
131 xmlSecKeyDataType type ATTRIBUTE_UNUSED) { |
|
132 xmlSecBufferPtr buffer; |
|
133 |
|
134 xmlSecAssert2(xmlSecSymbianCryptoSymKeyDataCheckId(data), -1); |
|
135 xmlSecAssert2(sizeBits > 0, -1); |
|
136 |
|
137 buffer = xmlSecKeyDataBinaryValueGetBuffer(data); |
|
138 xmlSecAssert2(buffer, -1); |
|
139 |
|
140 return(xmlSecSymbianCryptoGenerateRandom(buffer, (sizeBits + 7) / 8)); |
|
141 } |
|
142 |
|
143 static xmlSecKeyDataType |
|
144 xmlSecSymbianCryptoSymKeyDataGetType(xmlSecKeyDataPtr data) { |
|
145 xmlSecBufferPtr buffer; |
|
146 |
|
147 xmlSecAssert2(xmlSecSymbianCryptoSymKeyDataCheckId(data), xmlSecKeyDataTypeUnknown); |
|
148 |
|
149 buffer = xmlSecKeyDataBinaryValueGetBuffer(data); |
|
150 xmlSecAssert2(buffer, xmlSecKeyDataTypeUnknown); |
|
151 |
|
152 return((xmlSecBufferGetSize(buffer) > 0) ? |
|
153 xmlSecKeyDataTypeSymmetric : xmlSecKeyDataTypeUnknown); |
|
154 } |
|
155 |
|
156 static xmlSecSize |
|
157 xmlSecSymbianCryptoSymKeyDataGetSize(xmlSecKeyDataPtr data) { |
|
158 xmlSecAssert2(xmlSecSymbianCryptoSymKeyDataCheckId(data), 0); |
|
159 |
|
160 return(xmlSecKeyDataBinaryValueGetSize(data)); |
|
161 } |
|
162 |
|
163 static void |
|
164 xmlSecSymbianCryptoSymKeyDataDebugDump(xmlSecKeyDataPtr data, FILE* output) { |
|
165 xmlSecAssert(xmlSecSymbianCryptoSymKeyDataCheckId(data)); |
|
166 |
|
167 xmlSecKeyDataBinaryValueDebugDump(data, output); |
|
168 } |
|
169 |
|
170 static void |
|
171 xmlSecSymbianCryptoSymKeyDataDebugXmlDump(xmlSecKeyDataPtr data, FILE* output) { |
|
172 xmlSecAssert(xmlSecSymbianCryptoSymKeyDataCheckId(data)); |
|
173 |
|
174 xmlSecKeyDataBinaryValueDebugXmlDump(data, output); |
|
175 } |
|
176 |
|
177 static int |
|
178 xmlSecSymbianCryptoSymKeyDataKlassCheck(xmlSecKeyDataKlass* klass) { |
|
179 #ifndef XMLSEC_NO_DES |
|
180 if(klass == xmlSecSymbianCryptoKeyDataDesId) { |
|
181 return(1); |
|
182 } |
|
183 #endif /* XMLSEC_NO_DES */ |
|
184 |
|
185 #ifndef XMLSEC_NO_AES |
|
186 if(klass == xmlSecSymbianCryptoKeyDataAesId) { |
|
187 return(1); |
|
188 } |
|
189 #endif /* XMLSEC_NO_AES */ |
|
190 |
|
191 #ifndef XMLSEC_NO_HMAC |
|
192 if(klass == xmlSecSymbianCryptoKeyDataHmacId) { |
|
193 return(1); |
|
194 } |
|
195 #endif /* XMLSEC_NO_HMAC */ |
|
196 |
|
197 return(0); |
|
198 } |
|
199 |
|
200 #ifndef XMLSEC_NO_AES |
|
201 /************************************************************************** |
|
202 * |
|
203 * <xmlsec:AESKeyValue> processing |
|
204 * |
|
205 *************************************************************************/ |
|
206 static xmlSecKeyDataKlass xmlSecSymbianCryptoKeyDataAesKlass = { |
|
207 sizeof(xmlSecKeyDataKlass), |
|
208 xmlSecKeyDataBinarySize, |
|
209 |
|
210 /* data */ |
|
211 xmlSecNameAESKeyValue, |
|
212 xmlSecKeyDataUsageKeyValueNode | xmlSecKeyDataUsageRetrievalMethodNodeXml, |
|
213 /* xmlSecKeyDataUsage usage; */ |
|
214 xmlSecHrefAESKeyValue, /* const xmlChar* href; */ |
|
215 xmlSecNodeAESKeyValue, /* const xmlChar* dataNodeName; */ |
|
216 xmlSecNs, /* const xmlChar* dataNodeNs; */ |
|
217 |
|
218 /* constructors/destructor */ |
|
219 xmlSecSymbianCryptoSymKeyDataInitialize, /* xmlSecKeyDataInitializeMethod initialize; */ |
|
220 xmlSecSymbianCryptoSymKeyDataDuplicate, /* xmlSecKeyDataDuplicateMethod duplicate; */ |
|
221 xmlSecSymbianCryptoSymKeyDataFinalize, /* xmlSecKeyDataFinalizeMethod finalize; */ |
|
222 xmlSecSymbianCryptoSymKeyDataGenerate, /* xmlSecKeyDataGenerateMethod generate; */ |
|
223 |
|
224 /* get info */ |
|
225 xmlSecSymbianCryptoSymKeyDataGetType, /* xmlSecKeyDataGetTypeMethod getType; */ |
|
226 xmlSecSymbianCryptoSymKeyDataGetSize, /* xmlSecKeyDataGetSizeMethod getSize; */ |
|
227 NULL, /* xmlSecKeyDataGetIdentifier getIdentifier; */ |
|
228 |
|
229 /* read/write */ |
|
230 xmlSecSymbianCryptoSymKeyDataXmlRead, /* xmlSecKeyDataXmlReadMethod xmlRead; */ |
|
231 xmlSecSymbianCryptoSymKeyDataXmlWrite, /* xmlSecKeyDataXmlWriteMethod xmlWrite; */ |
|
232 xmlSecSymbianCryptoSymKeyDataBinRead, /* xmlSecKeyDataBinReadMethod binRead; */ |
|
233 xmlSecSymbianCryptoSymKeyDataBinWrite, /* xmlSecKeyDataBinWriteMethod binWrite; */ |
|
234 |
|
235 /* debug */ |
|
236 xmlSecSymbianCryptoSymKeyDataDebugDump, /* xmlSecKeyDataDebugDumpMethod debugDump; */ |
|
237 xmlSecSymbianCryptoSymKeyDataDebugXmlDump, /* xmlSecKeyDataDebugDumpMethod debugXmlDump; */ |
|
238 |
|
239 /* reserved for the future */ |
|
240 NULL, /* void* reserved0; */ |
|
241 NULL, /* void* reserved1; */ |
|
242 }; |
|
243 |
|
244 /** |
|
245 * xmlSecSymbianCryptoKeyDataAesGetKlass: |
|
246 * |
|
247 * The AES key data klass. |
|
248 * |
|
249 * Returns AES key data klass. |
|
250 */ |
|
251 EXPORT_C |
|
252 xmlSecKeyDataId |
|
253 xmlSecSymbianCryptoKeyDataAesGetKlass(void) { |
|
254 return(&xmlSecSymbianCryptoKeyDataAesKlass); |
|
255 } |
|
256 |
|
257 /** |
|
258 * xmlSecSymbianCryptoKeyDataAesSet: |
|
259 * @data: the pointer to AES key data. |
|
260 * @buf: the pointer to key value. |
|
261 * @bufSize: the key value size (in bytes). |
|
262 * |
|
263 * Sets the value of AES key data. |
|
264 * |
|
265 * Returns 0 on success or a negative value if an error occurs. |
|
266 */ |
|
267 EXPORT_C |
|
268 int |
|
269 xmlSecSymbianCryptoKeyDataAesSet(xmlSecKeyDataPtr data, |
|
270 const xmlSecByte* buf, xmlSecSize bufSize) { |
|
271 xmlSecBufferPtr buffer; |
|
272 |
|
273 xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecSymbianCryptoKeyDataAesId), -1); |
|
274 xmlSecAssert2(buf, -1); |
|
275 xmlSecAssert2(bufSize > 0, -1); |
|
276 |
|
277 buffer = xmlSecKeyDataBinaryValueGetBuffer(data); |
|
278 xmlSecAssert2(buffer, -1); |
|
279 |
|
280 return(xmlSecBufferSetData(buffer, buf, bufSize)); |
|
281 } |
|
282 #endif /* XMLSEC_NO_AES */ |
|
283 |
|
284 #ifndef XMLSEC_NO_DES |
|
285 /************************************************************************** |
|
286 * |
|
287 * <xmlsec:DESKeyValue> processing |
|
288 * |
|
289 *************************************************************************/ |
|
290 static xmlSecKeyDataKlass xmlSecSymbianCryptoKeyDataDesKlass = { |
|
291 sizeof(xmlSecKeyDataKlass), |
|
292 xmlSecKeyDataBinarySize, |
|
293 |
|
294 /* data */ |
|
295 xmlSecNameDESKeyValue, |
|
296 xmlSecKeyDataUsageKeyValueNode | xmlSecKeyDataUsageRetrievalMethodNodeXml, |
|
297 /* xmlSecKeyDataUsage usage; */ |
|
298 xmlSecHrefDESKeyValue, /* const xmlChar* href; */ |
|
299 xmlSecNodeDESKeyValue, /* const xmlChar* dataNodeName; */ |
|
300 xmlSecNs, /* const xmlChar* dataNodeNs; */ |
|
301 |
|
302 /* constructors/destructor */ |
|
303 xmlSecSymbianCryptoSymKeyDataInitialize, /* xmlSecKeyDataInitializeMethod initialize; */ |
|
304 xmlSecSymbianCryptoSymKeyDataDuplicate, /* xmlSecKeyDataDuplicateMethod duplicate; */ |
|
305 xmlSecSymbianCryptoSymKeyDataFinalize, /* xmlSecKeyDataFinalizeMethod finalize; */ |
|
306 xmlSecSymbianCryptoSymKeyDataGenerate, /* xmlSecKeyDataGenerateMethod generate; */ |
|
307 |
|
308 /* get info */ |
|
309 xmlSecSymbianCryptoSymKeyDataGetType, /* xmlSecKeyDataGetTypeMethod getType; */ |
|
310 xmlSecSymbianCryptoSymKeyDataGetSize, /* xmlSecKeyDataGetSizeMethod getSize; */ |
|
311 NULL, /* xmlSecKeyDataGetIdentifier getIdentifier; */ |
|
312 |
|
313 /* read/write */ |
|
314 xmlSecSymbianCryptoSymKeyDataXmlRead, /* xmlSecKeyDataXmlReadMethod xmlRead; */ |
|
315 xmlSecSymbianCryptoSymKeyDataXmlWrite, /* xmlSecKeyDataXmlWriteMethod xmlWrite; */ |
|
316 xmlSecSymbianCryptoSymKeyDataBinRead, /* xmlSecKeyDataBinReadMethod binRead; */ |
|
317 xmlSecSymbianCryptoSymKeyDataBinWrite, /* xmlSecKeyDataBinWriteMethod binWrite; */ |
|
318 |
|
319 /* debug */ |
|
320 xmlSecSymbianCryptoSymKeyDataDebugDump, /* xmlSecKeyDataDebugDumpMethod debugDump; */ |
|
321 xmlSecSymbianCryptoSymKeyDataDebugXmlDump, /* xmlSecKeyDataDebugDumpMethod debugXmlDump; */ |
|
322 |
|
323 /* reserved for the future */ |
|
324 NULL, /* void* reserved0; */ |
|
325 NULL, /* void* reserved1; */ |
|
326 }; |
|
327 |
|
328 /** |
|
329 * xmlSecSymbianCryptoKeyDataDesGetKlass: |
|
330 * |
|
331 * The DES key data klass. |
|
332 * |
|
333 * Returns DES key data klass. |
|
334 */ |
|
335 EXPORT_C |
|
336 xmlSecKeyDataId |
|
337 xmlSecSymbianCryptoKeyDataDesGetKlass(void) { |
|
338 return(&xmlSecSymbianCryptoKeyDataDesKlass); |
|
339 } |
|
340 |
|
341 /** |
|
342 * xmlSecSymbianCryptoKeyDataDesSet: |
|
343 * @data: the pointer to DES key data. |
|
344 * @buf: the pointer to key value. |
|
345 * @bufSize: the key value size (in bytes). |
|
346 * |
|
347 * Sets the value of DES key data. |
|
348 * |
|
349 * Returns 0 on success or a negative value if an error occurs. |
|
350 */ |
|
351 EXPORT_C |
|
352 int |
|
353 xmlSecSymbianCryptoKeyDataDesSet(xmlSecKeyDataPtr data, |
|
354 const xmlSecByte* buf, |
|
355 xmlSecSize bufSize) { |
|
356 xmlSecBufferPtr buffer; |
|
357 |
|
358 xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecSymbianCryptoKeyDataDesId), -1); |
|
359 xmlSecAssert2(buf, -1); |
|
360 xmlSecAssert2(bufSize > 0, -1); |
|
361 |
|
362 buffer = xmlSecKeyDataBinaryValueGetBuffer(data); |
|
363 xmlSecAssert2(buffer, -1); |
|
364 |
|
365 return(xmlSecBufferSetData(buffer, buf, bufSize)); |
|
366 } |
|
367 |
|
368 #endif /* XMLSEC_NO_DES */ |
|
369 |
|
370 #ifndef XMLSEC_NO_HMAC |
|
371 /************************************************************************** |
|
372 * |
|
373 * <xmlsec:HMACKeyValue> processing |
|
374 * |
|
375 *************************************************************************/ |
|
376 static xmlSecKeyDataKlass xmlSecSymbianCryptoKeyDataHmacKlass = { |
|
377 sizeof(xmlSecKeyDataKlass), |
|
378 xmlSecKeyDataBinarySize, |
|
379 |
|
380 /* data */ |
|
381 xmlSecNameHMACKeyValue, |
|
382 xmlSecKeyDataUsageKeyValueNode | xmlSecKeyDataUsageRetrievalMethodNodeXml, |
|
383 /* xmlSecKeyDataUsage usage; */ |
|
384 xmlSecHrefHMACKeyValue, /* const xmlChar* href; */ |
|
385 xmlSecNodeHMACKeyValue, /* const xmlChar* dataNodeName; */ |
|
386 xmlSecNs, /* const xmlChar* dataNodeNs; */ |
|
387 |
|
388 /* constructors/destructor */ |
|
389 xmlSecSymbianCryptoSymKeyDataInitialize, /* xmlSecKeyDataInitializeMethod initialize; */ |
|
390 xmlSecSymbianCryptoSymKeyDataDuplicate, /* xmlSecKeyDataDuplicateMethod duplicate; */ |
|
391 xmlSecSymbianCryptoSymKeyDataFinalize, /* xmlSecKeyDataFinalizeMethod finalize; */ |
|
392 xmlSecSymbianCryptoSymKeyDataGenerate, /* xmlSecKeyDataGenerateMethod generate; */ |
|
393 |
|
394 /* get info */ |
|
395 xmlSecSymbianCryptoSymKeyDataGetType, /* xmlSecKeyDataGetTypeMethod getType; */ |
|
396 xmlSecSymbianCryptoSymKeyDataGetSize, /* xmlSecKeyDataGetSizeMethod getSize; */ |
|
397 NULL, /* xmlSecKeyDataGetIdentifier getIdentifier; */ |
|
398 |
|
399 /* read/write */ |
|
400 xmlSecSymbianCryptoSymKeyDataXmlRead, /* xmlSecKeyDataXmlReadMethod xmlRead; */ |
|
401 xmlSecSymbianCryptoSymKeyDataXmlWrite, /* xmlSecKeyDataXmlWriteMethod xmlWrite; */ |
|
402 xmlSecSymbianCryptoSymKeyDataBinRead, /* xmlSecKeyDataBinReadMethod binRead; */ |
|
403 xmlSecSymbianCryptoSymKeyDataBinWrite, /* xmlSecKeyDataBinWriteMethod binWrite; */ |
|
404 |
|
405 /* debug */ |
|
406 xmlSecSymbianCryptoSymKeyDataDebugDump, /* xmlSecKeyDataDebugDumpMethod debugDump; */ |
|
407 xmlSecSymbianCryptoSymKeyDataDebugXmlDump, /* xmlSecKeyDataDebugDumpMethod debugXmlDump; */ |
|
408 |
|
409 /* reserved for the future */ |
|
410 NULL, /* void* reserved0; */ |
|
411 NULL, /* void* reserved1; */ |
|
412 }; |
|
413 |
|
414 /** |
|
415 * xmlSecSymbianCryptoKeyDataHmacGetKlass: |
|
416 * |
|
417 * The HMAC key data klass. |
|
418 * |
|
419 * Returns HMAC key data klass. |
|
420 */ |
|
421 EXPORT_C |
|
422 xmlSecKeyDataId |
|
423 xmlSecSymbianCryptoKeyDataHmacGetKlass(void) { |
|
424 return(&xmlSecSymbianCryptoKeyDataHmacKlass); |
|
425 } |
|
426 |
|
427 /** |
|
428 * xmlSecSymbianCryptoKeyDataHmacSet: |
|
429 * @data: the pointer to HMAC key data. |
|
430 * @buf: the pointer to key value. |
|
431 * @bufSize: the key value size (in bytes). |
|
432 * |
|
433 * Sets the value of HMAC key data. |
|
434 * |
|
435 * Returns 0 on success or a negative value if an error occurs. |
|
436 */ |
|
437 EXPORT_C |
|
438 int |
|
439 xmlSecSymbianCryptoKeyDataHmacSet(xmlSecKeyDataPtr data, |
|
440 const xmlSecByte* buf, |
|
441 xmlSecSize bufSize) { |
|
442 xmlSecBufferPtr buffer; |
|
443 |
|
444 xmlSecAssert2(xmlSecKeyDataCheckId(data, xmlSecSymbianCryptoKeyDataHmacId), -1); |
|
445 xmlSecAssert2(buf, -1); |
|
446 xmlSecAssert2(bufSize > 0, -1); |
|
447 |
|
448 buffer = xmlSecKeyDataBinaryValueGetBuffer(data); |
|
449 xmlSecAssert2(buffer, -1); |
|
450 |
|
451 return(xmlSecBufferSetData(buffer, buf, bufSize)); |
|
452 } |
|
453 |
|
454 #endif /* XMLSEC_NO_HMAC */ |