gsasl  1.10.0
About: GNU SASL is an implementation of the Simple Authentication and Security Layer (SASL). Development version.
  Fossies Dox: gsasl-1.10.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

base64.c File Reference
#include <config.h>
#include "base64.h"
#include <stdlib.h>
#include <limits.h>
#include <string.h>
Include dependency graph for base64.c:

Go to the source code of this file.

Macros

#define B64(_)
 
#define uchar_in_range(c)   ((c) <= 255)
 
#define return_false
 

Functions

static unsigned char to_uchar (char ch)
 
static void base64_encode_fast (const char *in, size_t inlen, char *out)
 
void base64_encode (const char *in, size_t inlen, char *out, size_t outlen)
 
size_t base64_encode_alloc (const char *in, size_t inlen, char **out)
 
signed char isbase64 (char ch)
 
void base64_decode_ctx_init (struct base64_decode_context *ctx)
 
static char * get_4 (struct base64_decode_context *ctx, char const **in, char const *in_end, size_t *n_non_newline)
 
static signed char decode_4 (char const *in, size_t inlen, char **outp, size_t *outleft)
 
signed char base64_decode_ctx (struct base64_decode_context *ctx, const char *in, size_t inlen, char *out, size_t *outlen)
 
signed char base64_decode_alloc_ctx (struct base64_decode_context *ctx, const char *in, size_t inlen, char **out, size_t *outlen)
 

Variables

static const char b64c [64]
 
static const signed char b64 [0x100]
 

Macro Definition Documentation

◆ B64

#define B64 (   _)

Definition at line 185 of file base64.c.

◆ return_false

#define return_false
Value:
do \
{ \
*outp = out; \
return false; \
} \
while (false)

Definition at line 388 of file base64.c.

◆ uchar_in_range

#define uchar_in_range (   c)    ((c) <= 255)

Definition at line 322 of file base64.c.

Function Documentation

◆ base64_decode_alloc_ctx()

signed char base64_decode_alloc_ctx ( struct base64_decode_context ctx,
const char *  in,
size_t  inlen,
char **  out,
size_t outlen 
)

Definition at line 579 of file base64.c.

References base64_decode_ctx(), and NULL.

◆ base64_decode_ctx()

signed char base64_decode_ctx ( struct base64_decode_context ctx,
const char *  in,
size_t  inlen,
char *  out,
size_t outlen 
)

Definition at line 488 of file base64.c.

References decode_4(), get_4(), base64_decode_context::i, and NULL.

Referenced by base64_decode_alloc_ctx().

◆ base64_decode_ctx_init()

void base64_decode_ctx_init ( struct base64_decode_context ctx)

Definition at line 336 of file base64.c.

References base64_decode_context::i.

◆ base64_encode()

void base64_encode ( const char *  in,
size_t  inlen,
char *  out,
size_t  outlen 
)

Definition at line 88 of file base64.c.

References b64c, base64_encode_fast(), and to_uchar().

Referenced by base64_encode_alloc().

◆ base64_encode_alloc()

size_t base64_encode_alloc ( const char *  in,
size_t  inlen,
char **  out 
)

Definition at line 145 of file base64.c.

References base64_encode(), BASE64_LENGTH, and NULL.

Referenced by gsasl_base64_to().

◆ base64_encode_fast()

static void base64_encode_fast ( const char *  in,
size_t  inlen,
char *  out 
)
static

Definition at line 69 of file base64.c.

References b64c, and to_uchar().

Referenced by base64_encode().

◆ decode_4()

static signed char decode_4 ( char const *  in,
size_t  inlen,
char **  outp,
size_t outleft 
)
static

Definition at line 403 of file base64.c.

References b64, isbase64(), return_false, and to_uchar().

Referenced by base64_decode_ctx().

◆ get_4()

static char* get_4 ( struct base64_decode_context ctx,
char const **  in,
char const *  in_end,
size_t n_non_newline 
)
static

Definition at line 349 of file base64.c.

References base64_decode_context::buf, c, base64_decode_context::i, memchr(), NULL, and p.

Referenced by base64_decode_ctx().

◆ isbase64()

signed char isbase64 ( char  ch)

Definition at line 329 of file base64.c.

References b64, to_uchar(), and uchar_in_range.

Referenced by decode_4().

◆ to_uchar()

static unsigned char to_uchar ( char  ch)
static

Definition at line 57 of file base64.c.

Referenced by base64_encode(), base64_encode_fast(), decode_4(), and isbase64().

Variable Documentation

◆ b64

const signed char b64[0x100]
static

Definition at line 252 of file base64.c.

Referenced by decode_4(), extract_serverkey(), and isbase64().

◆ b64c

const char b64c[64]
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

Definition at line 62 of file base64.c.

Referenced by base64_encode(), and base64_encode_fast().