OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 #include "secder.h" | 5 #include "secder.h" |
6 #include "secerr.h" | 6 #include "secerr.h" |
7 | 7 |
8 #if 0 | 8 #if 0 |
9 /* | 9 /* |
10 * Generic templates for individual/simple items. | 10 * Generic templates for individual/simple items. |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 buf += contents_len; | 436 buf += contents_len; |
437 } | 437 } |
438 break; | 438 break; |
439 } | 439 } |
440 | 440 |
441 return buf; | 441 return buf; |
442 } | 442 } |
443 | 443 |
444 | 444 |
445 SECStatus | 445 SECStatus |
446 DER_Encode(PRArenaPool *arena, SECItem *dest, DERTemplate *dtemplate, void *src) | 446 DER_Encode(PLArenaPool *arena, SECItem *dest, DERTemplate *dtemplate, void *src) |
447 { | 447 { |
448 unsigned int contents_len, header_len; | 448 unsigned int contents_len, header_len; |
449 | 449 |
450 src = (void **)((char *)src + dtemplate->offset); | 450 src = (void **)((char *)src + dtemplate->offset); |
451 | 451 |
452 /* | 452 /* |
453 * First figure out how long the encoding will be. Do this by | 453 * First figure out how long the encoding will be. Do this by |
454 * traversing the template from top to bottom and accumulating | 454 * traversing the template from top to bottom and accumulating |
455 * the length of each leaf item. | 455 * the length of each leaf item. |
456 */ | 456 */ |
457 contents_len = contents_length (dtemplate, src); | 457 contents_len = contents_length (dtemplate, src); |
458 header_len = header_length (dtemplate, contents_len); | 458 header_len = header_length (dtemplate, contents_len); |
459 | 459 |
460 dest->len = contents_len + header_len; | 460 dest->len = contents_len + header_len; |
461 | 461 |
462 /* Allocate storage to hold the encoding */ | 462 /* Allocate storage to hold the encoding */ |
463 dest->data = (unsigned char*) PORT_ArenaAlloc(arena, dest->len); | 463 dest->data = (unsigned char*) PORT_ArenaAlloc(arena, dest->len); |
464 if (dest->data == NULL) { | 464 if (dest->data == NULL) { |
465 PORT_SetError(SEC_ERROR_NO_MEMORY); | 465 PORT_SetError(SEC_ERROR_NO_MEMORY); |
466 return SECFailure; | 466 return SECFailure; |
467 } | 467 } |
468 | 468 |
469 /* Now encode into the buffer */ | 469 /* Now encode into the buffer */ |
470 (void) der_encode (dest->data, dtemplate, src); | 470 (void) der_encode (dest->data, dtemplate, src); |
471 | 471 |
472 return SECSuccess; | 472 return SECSuccess; |
473 } | 473 } |
OLD | NEW |