Example program to test AES-GCM functionality. Used for a workshop

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers base64.h Source File

base64.h

Go to the documentation of this file.
00001 /**
00002  * \file base64.h
00003  *
00004  * \brief RFC 1521 base64 encoding/decoding
00005  *
00006  *  Copyright (C) 2006-2013, Brainspark B.V.
00007  *
00008  *  This file is part of PolarSSL (http://www.polarssl.org)
00009  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
00010  *
00011  *  All rights reserved.
00012  *
00013  *  This program is free software; you can redistribute it and/or modify
00014  *  it under the terms of the GNU General Public License as published by
00015  *  the Free Software Foundation; either version 2 of the License, or
00016  *  (at your option) any later version.
00017  *
00018  *  This program is distributed in the hope that it will be useful,
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *  GNU General Public License for more details.
00022  *
00023  *  You should have received a copy of the GNU General Public License along
00024  *  with this program; if not, write to the Free Software Foundation, Inc.,
00025  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00026  */
00027 #ifndef POLARSSL_BASE64_H
00028 #define POLARSSL_BASE64_H
00029 
00030 #include <string.h>
00031 
00032 #define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL               -0x002A  /**< Output buffer too small. */
00033 #define POLARSSL_ERR_BASE64_INVALID_CHARACTER              -0x002C  /**< Invalid character in input. */
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 /**
00040  * \brief          Encode a buffer into base64 format
00041  *
00042  * \param dst      destination buffer
00043  * \param dlen     size of the buffer
00044  * \param src      source buffer
00045  * \param slen     amount of data to be encoded
00046  *
00047  * \return         0 if successful, or POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL.
00048  *                 *dlen is always updated to reflect the amount
00049  *                 of data that has (or would have) been written.
00050  *
00051  * \note           Call this function with *dlen = 0 to obtain the
00052  *                 required buffer size in *dlen
00053  */
00054 int base64_encode( unsigned char *dst, size_t *dlen,
00055                    const unsigned char *src, size_t slen );
00056 
00057 /**
00058  * \brief          Decode a base64-formatted buffer
00059  *
00060  * \param dst      destination buffer (can be NULL for checking size)
00061  * \param dlen     size of the buffer
00062  * \param src      source buffer
00063  * \param slen     amount of data to be decoded
00064  *
00065  * \return         0 if successful, POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
00066  *                 POLARSSL_ERR_BASE64_INVALID_CHARACTER if the input data is
00067  *                 not correct. *dlen is always updated to reflect the amount
00068  *                 of data that has (or would have) been written.
00069  *
00070  * \note           Call this function with *dst = NULL or *dlen = 0 to obtain
00071  *                 the required buffer size in *dlen
00072  */
00073 int base64_decode( unsigned char *dst, size_t *dlen,
00074                    const unsigned char *src, size_t slen );
00075 
00076 /**
00077  * \brief          Checkup routine
00078  *
00079  * \return         0 if successful, or 1 if the test failed
00080  */
00081 int base64_self_test( int verbose );
00082 
00083 #ifdef __cplusplus
00084 }
00085 #endif
00086 
00087 #endif /* base64.h */
00088 
00089