1 /** 2 * \file base64.h 3 * 4 * Copyright (C) 2006-2010, Brainspark B.V. 5 * 6 * This file is part of PolarSSL (http://www.polarssl.org) 7 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> 8 * 9 * All rights reserved. 10 * 11 * This program is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program. If not, see <http://www.gnu.org/licenses/>. 23 */ 24 25 #ifndef BASE64_H 26 #define BASE64_H 27 28 #include <string.h> 29 30 #define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x0010 /**< Output buffer too small. */ 31 #define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x0012 /**< Invalid character in input. */ 32 33 #if 0 34 /** 35 * \brief Encode a buffer into base64 format 36 * 37 * \param dst destination buffer 38 * \param dlen size of the buffer 39 * \param src source buffer 40 * \param slen amount of data to be encoded 41 * 42 * \return 0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL. 43 * *dlen is always updated to reflect the amount 44 * of data that has (or would have) been written. 45 * 46 * \note Call this function with *dlen = 0 to obtain the 47 * required buffer size in *dlen 48 */ 49 int base64_encode( unsigned char *dst, size_t *dlen, 50 const unsigned char *src, size_t slen ); 51 #endif 52 53 /** 54 * \brief Decode a base64-formatted buffer 55 * 56 * \param dst destination buffer 57 * \param dlen size of the buffer 58 * \param src source buffer 59 * \param slen amount of data to be decoded 60 * 61 * \return 0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or 62 * POLARSSL_ERR_BASE64_INVALID_DATA if the input data is not 63 * correct. *dlen is always updated to reflect the amount 64 * of data that has (or would have) been written. 65 * 66 * \note Call this function with *dlen = 0 to obtain the 67 * required buffer size in *dlen 68 */ 69 int base64_decode( unsigned char *dst, size_t *dlen, 70 const unsigned char *src, size_t slen ); 71 72 #endif /* base64.h */ 73