1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public License Version
5
* 1.1 (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
* http://www.mozilla.org/MPL/
9
* Software distributed under the License is distributed on an "AS IS" basis,
10
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
* for the specific language governing rights and limitations under the
14
* The Original Code is the Netscape security libraries.
16
* The Initial Developer of the Original Code is
17
* Netscape Communications Corporation.
18
* Portions created by the Initial Developer are Copyright (C) 1994-2000
19
* the Initial Developer. All Rights Reserved.
23
* Alternatively, the contents of this file may be used under the terms of
24
* either the GNU General Public License Version 2 or later (the "GPL"), or
25
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
* in which case the provisions of the GPL or the LGPL are applicable instead
27
* of those above. If you wish to allow use of your version of this file only
28
* under the terms of either the GPL or the LGPL, and not to allow others to
29
* use your version of this file under the terms of the MPL, indicate your
30
* decision by deleting the provisions above and replace them with the notice
31
* and other provisions required by the GPL or the LGPL. If you do not delete
32
* the provisions above, a recipient may use your version of this file under
33
* the terms of any one of the MPL, the GPL or the LGPL.
35
* ***** END LICENSE BLOCK ***** */
38
* Public prototypes for base64 encoding/decoding.
40
* $Id: nssb64.h,v 1.3 2004/04/25 15:03:17 gerv%gerv.net Exp $
51
* Functions to start a base64 decoding/encoding context.
54
extern NSSBase64Decoder *
55
NSSBase64Decoder_Create (PRInt32 (*output_fn) (void *, const unsigned char *,
59
extern NSSBase64Encoder *
60
NSSBase64Encoder_Create (PRInt32 (*output_fn) (void *, const char *, PRInt32),
64
* Push data through the decoder/encoder, causing the output_fn (provided
65
* to Create) to be called with the decoded/encoded data.
69
NSSBase64Decoder_Update (NSSBase64Decoder *data, const char *buffer,
73
NSSBase64Encoder_Update (NSSBase64Encoder *data, const unsigned char *buffer,
77
* When you're done processing, call this to close the context.
78
* If "abort_p" is false, then calling this may cause the output_fn
79
* to be called one last time (as the last buffered data is flushed out).
83
NSSBase64Decoder_Destroy (NSSBase64Decoder *data, PRBool abort_p);
86
NSSBase64Encoder_Destroy (NSSBase64Encoder *data, PRBool abort_p);
89
* Perform base64 decoding from an ascii string "inStr" to an Item.
90
* The length of the input must be provided as "inLen". The Item
91
* may be provided (as "outItemOpt"); you can also pass in a NULL
92
* and the Item will be allocated for you.
94
* In any case, the data within the Item will be allocated for you.
95
* All allocation will happen out of the passed-in "arenaOpt", if non-NULL.
96
* If "arenaOpt" is NULL, standard allocation (heap) will be used and
97
* you will want to free the result via SECITEM_FreeItem.
99
* Return value is NULL on error, the Item (allocated or provided) otherwise.
102
NSSBase64_DecodeBuffer (PRArenaPool *arenaOpt, SECItem *outItemOpt,
103
const char *inStr, unsigned int inLen);
106
* Perform base64 encoding of binary data "inItem" to an ascii string.
107
* The output buffer may be provided (as "outStrOpt"); you can also pass
108
* in a NULL and the buffer will be allocated for you. The result will
109
* be null-terminated, and if the buffer is provided, "maxOutLen" must
110
* specify the maximum length of the buffer and will be checked to
111
* supply sufficient space space for the encoded result. (If "outStrOpt"
112
* is NULL, "maxOutLen" is ignored.)
114
* If "outStrOpt" is NULL, allocation will happen out of the passed-in
115
* "arenaOpt", if *it* is non-NULL, otherwise standard allocation (heap)
118
* Return value is NULL on error, the output buffer (allocated or provided)
122
NSSBase64_EncodeItem (PRArenaPool *arenaOpt, char *outStrOpt,
123
unsigned int maxOutLen, SECItem *inItem);
127
#endif /* _NSSB64_H_ */