| OLD | NEW |
| (Empty) |
| 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 | |
| 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
| 4 | |
| 5 /* | |
| 6 * Public prototypes for base64 encoding/decoding. | |
| 7 * | |
| 8 * $Id: nssb64.h,v 1.6 2012/04/25 14:50:16 gerv%gerv.net Exp $ | |
| 9 */ | |
| 10 #ifndef _NSSB64_H_ | |
| 11 #define _NSSB64_H_ | |
| 12 | |
| 13 #include "utilrename.h" | |
| 14 #include "seccomon.h" | |
| 15 #include "nssb64t.h" | |
| 16 | |
| 17 SEC_BEGIN_PROTOS | |
| 18 | |
| 19 /* | |
| 20 * Functions to start a base64 decoding/encoding context. | |
| 21 */ | |
| 22 | |
| 23 extern NSSBase64Decoder * | |
| 24 NSSBase64Decoder_Create (PRInt32 (*output_fn) (void *, const unsigned char *, | |
| 25 PRInt32), | |
| 26 void *output_arg); | |
| 27 | |
| 28 extern NSSBase64Encoder * | |
| 29 NSSBase64Encoder_Create (PRInt32 (*output_fn) (void *, const char *, PRInt32), | |
| 30 void *output_arg); | |
| 31 | |
| 32 /* | |
| 33 * Push data through the decoder/encoder, causing the output_fn (provided | |
| 34 * to Create) to be called with the decoded/encoded data. | |
| 35 */ | |
| 36 | |
| 37 extern SECStatus | |
| 38 NSSBase64Decoder_Update (NSSBase64Decoder *data, const char *buffer, | |
| 39 PRUint32 size); | |
| 40 | |
| 41 extern SECStatus | |
| 42 NSSBase64Encoder_Update (NSSBase64Encoder *data, const unsigned char *buffer, | |
| 43 PRUint32 size); | |
| 44 | |
| 45 /* | |
| 46 * When you're done processing, call this to close the context. | |
| 47 * If "abort_p" is false, then calling this may cause the output_fn | |
| 48 * to be called one last time (as the last buffered data is flushed out). | |
| 49 */ | |
| 50 | |
| 51 extern SECStatus | |
| 52 NSSBase64Decoder_Destroy (NSSBase64Decoder *data, PRBool abort_p); | |
| 53 | |
| 54 extern SECStatus | |
| 55 NSSBase64Encoder_Destroy (NSSBase64Encoder *data, PRBool abort_p); | |
| 56 | |
| 57 /* | |
| 58 * Perform base64 decoding from an ascii string "inStr" to an Item. | |
| 59 * The length of the input must be provided as "inLen". The Item | |
| 60 * may be provided (as "outItemOpt"); you can also pass in a NULL | |
| 61 * and the Item will be allocated for you. | |
| 62 * | |
| 63 * In any case, the data within the Item will be allocated for you. | |
| 64 * All allocation will happen out of the passed-in "arenaOpt", if non-NULL. | |
| 65 * If "arenaOpt" is NULL, standard allocation (heap) will be used and | |
| 66 * you will want to free the result via SECITEM_FreeItem. | |
| 67 * | |
| 68 * Return value is NULL on error, the Item (allocated or provided) otherwise. | |
| 69 */ | |
| 70 extern SECItem * | |
| 71 NSSBase64_DecodeBuffer (PLArenaPool *arenaOpt, SECItem *outItemOpt, | |
| 72 const char *inStr, unsigned int inLen); | |
| 73 | |
| 74 /* | |
| 75 * Perform base64 encoding of binary data "inItem" to an ascii string. | |
| 76 * The output buffer may be provided (as "outStrOpt"); you can also pass | |
| 77 * in a NULL and the buffer will be allocated for you. The result will | |
| 78 * be null-terminated, and if the buffer is provided, "maxOutLen" must | |
| 79 * specify the maximum length of the buffer and will be checked to | |
| 80 * supply sufficient space space for the encoded result. (If "outStrOpt" | |
| 81 * is NULL, "maxOutLen" is ignored.) | |
| 82 * | |
| 83 * If "outStrOpt" is NULL, allocation will happen out of the passed-in | |
| 84 * "arenaOpt", if *it* is non-NULL, otherwise standard allocation (heap) | |
| 85 * will be used. | |
| 86 * | |
| 87 * Return value is NULL on error, the output buffer (allocated or provided) | |
| 88 * otherwise. | |
| 89 */ | |
| 90 extern char * | |
| 91 NSSBase64_EncodeItem (PLArenaPool *arenaOpt, char *outStrOpt, | |
| 92 unsigned int maxOutLen, SECItem *inItem); | |
| 93 | |
| 94 SEC_END_PROTOS | |
| 95 | |
| 96 #endif /* _NSSB64_H_ */ | |
| OLD | NEW |