base64.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 1998-2001, 2003-2005, 2007, 2009, 2013-2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: base64.c,v 1.34 2009/10/21 23:48:05 tbox Exp $ */
/*! \file */
#include <config.h>
#define RETERR(x) do { \
isc_result_t _r = (x); \
if (_r != ISC_R_SUCCESS) \
return (_r); \
} while (0)
/*@{*/
/*!
* sure where they should go. -- bwelling
*/
static isc_result_t
static isc_result_t
static const char base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
/*@}*/
{
char buf[5];
unsigned int loops = 0;
if (wordlength < 4)
wordlength = 4;
loops++;
{
loops = 0;
}
}
}
return (ISC_R_SUCCESS);
}
/*%
* State of a base64 decoding process in progress.
*/
typedef struct {
int length; /*%< Desired length of binary data or -1 */
int digits; /*%< Number of buffered base64 digits */
int val[4];
static inline void
{
}
static inline isc_result_t
const char *s;
return (ISC_R_BADBASE64);
return (ISC_R_BADBASE64);
int n;
unsigned char buf[3];
return (ISC_R_BADBASE64);
return (ISC_R_BADBASE64);
/*
* Check that bits that should be zero are.
*/
return (ISC_R_BADBASE64);
/*
* We don't need to test for ctx->val[2] != 64 as
* the bottom two bits of 64 are zero.
*/
return (ISC_R_BADBASE64);
if (n != 3) {
}
return (ISC_R_BADBASE64);
else
}
}
return (ISC_R_SUCCESS);
}
static inline isc_result_t
return (ISC_R_UNEXPECTEDEND);
return (ISC_R_BADBASE64);
return (ISC_R_SUCCESS);
}
unsigned int i;
if (length > 0)
else
break;
}
return (ISC_R_SUCCESS);
}
for (;;) {
int c = *cstr++;
if (c == '\0')
break;
if (c == ' ' || c == '\t' || c == '\n' || c== '\r')
continue;
}
return (ISC_R_SUCCESS);
}
static isc_result_t
unsigned int l;
return (ISC_R_NOSPACE);
isc_buffer_add(target, l);
return (ISC_R_SUCCESS);
}
static isc_result_t
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}