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 /* | 5 /* |
6 * Base64 encoding (binary to ascii). | 6 * Base64 encoding (binary to ascii). |
7 */ | 7 */ |
8 | 8 |
9 #include "nssb64.h" | 9 #include "nssb64.h" |
10 #include "nspr.h" | 10 #include "nspr.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 * | 625 * |
626 * Return value is NULL on error, the output buffer (allocated or provided) | 626 * Return value is NULL on error, the output buffer (allocated or provided) |
627 * otherwise. | 627 * otherwise. |
628 */ | 628 */ |
629 char * | 629 char * |
630 NSSBase64_EncodeItem (PLArenaPool *arenaOpt, char *outStrOpt, | 630 NSSBase64_EncodeItem (PLArenaPool *arenaOpt, char *outStrOpt, |
631 unsigned int maxOutLen, SECItem *inItem) | 631 unsigned int maxOutLen, SECItem *inItem) |
632 { | 632 { |
633 char *out_string = outStrOpt; | 633 char *out_string = outStrOpt; |
634 PRUint32 max_out_len; | 634 PRUint32 max_out_len; |
635 PRUint32 out_len; | 635 PRUint32 out_len = 0; |
636 void *mark = NULL; | 636 void *mark = NULL; |
637 char *dummy; | 637 char *dummy; |
638 | 638 |
639 PORT_Assert(inItem != NULL && inItem->data != NULL && inItem->len != 0); | 639 PORT_Assert(inItem != NULL && inItem->data != NULL && inItem->len != 0); |
640 if (inItem == NULL || inItem->data == NULL || inItem->len == 0) { | 640 if (inItem == NULL || inItem->data == NULL || inItem->len == 0) { |
641 PORT_SetError (SEC_ERROR_INVALID_ARGS); | 641 PORT_SetError (SEC_ERROR_INVALID_ARGS); |
642 return NULL; | 642 return NULL; |
643 } | 643 } |
644 | 644 |
645 max_out_len = PL_Base64MaxEncodedLength (inItem->len, 64); | 645 max_out_len = PL_Base64MaxEncodedLength (inItem->len, 64); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 } | 722 } |
723 | 723 |
724 /* | 724 /* |
725 ** Convert from binary encoding of an item to ascii. | 725 ** Convert from binary encoding of an item to ascii. |
726 */ | 726 */ |
727 char * | 727 char * |
728 BTOA_ConvertItemToAscii (SECItem *binary_item) | 728 BTOA_ConvertItemToAscii (SECItem *binary_item) |
729 { | 729 { |
730 return NSSBase64_EncodeItem (NULL, NULL, 0, binary_item); | 730 return NSSBase64_EncodeItem (NULL, NULL, 0, binary_item); |
731 } | 731 } |
OLD | NEW |