security/nss/lib/util/nssb64.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial