Fix.
[gnutls.git] / lib / x509_b64.h
blob539bec4202fcb0c1b8941637f474685bff4b4b3e
1 /*
2 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GNUTLS.
8 * The GNUTLS library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 * USA
25 int _gnutls_base64_encode (const uint8_t * data, size_t data_size,
26 uint8_t ** result);
27 int _gnutls_fbase64_encode (const char *msg, const uint8_t * data,
28 int data_size, uint8_t ** result);
29 int _gnutls_base64_decode (const uint8_t * data, size_t data_size,
30 uint8_t ** result);
31 int _gnutls_fbase64_decode (const char *header, const uint8_t * data,
32 size_t data_size, uint8_t ** result);
34 #define B64SIZE( data_size) ((data_size%3==0)?((data_size*4)/3):(4+((data_size/3)*4)))
36 /* The size for B64 encoding + newlines plus header
39 #define HEADSIZE( hsize) \
40 sizeof("-----BEGIN ")-1+sizeof("-----")-1+ \
41 sizeof("\n-----END ")-1+sizeof("-----\n")-1+hsize+hsize
43 #define B64FSIZE( hsize, dsize) \
44 (B64SIZE(dsize) + HEADSIZE(hsize) + /*newlines*/ \
45 B64SIZE(dsize)/64 + (((B64SIZE(dsize) % 64) > 0) ? 1 : 0))