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.

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

mercurial