libwebsockets
Lightweight C library for HTML5 websockets
SHA and B64 helpers

Data Structures

struct  lws_b64state
 

Functions

LWS_VISIBLE LWS_EXTERN unsigned char * lws_SHA1 (const unsigned char *d, size_t n, unsigned char *md)
 
LWS_VISIBLE LWS_EXTERN int lws_b64_encode_string (const char *in, int in_len, char *out, int out_size)
 
LWS_VISIBLE LWS_EXTERN int lws_b64_encode_string_url (const char *in, int in_len, char *out, int out_size)
 
LWS_VISIBLE LWS_EXTERN int lws_b64_decode_string (const char *in, char *out, int out_size)
 
LWS_VISIBLE LWS_EXTERN int lws_b64_decode_string_len (const char *in, int in_len, char *out, int out_size)
 
LWS_VISIBLE LWS_EXTERN void lws_b64_decode_state_init (struct lws_b64state *state)
 
LWS_VISIBLE LWS_EXTERN int lws_b64_decode_stateful (struct lws_b64state *s, const char *in, size_t *in_len, uint8_t *out, size_t *out_size, int final)
 

Detailed Description

SHA and B64 helpers

These provide SHA-1 and B64 helper apis


Data Structure Documentation

◆ lws_b64state

struct lws_b64state

Definition at line 98 of file lws-sha1-base64.h.

+ Collaboration diagram for lws_b64state:
Data Fields
unsigned char quad[4]
size_t done
size_t len
int i
int c

Function Documentation

◆ lws_SHA1()

LWS_VISIBLE LWS_EXTERN unsigned char* lws_SHA1 ( const unsigned char *  d,
size_t  n,
unsigned char *  md 
)

#include <include/libwebsockets/lws-sha1-base64.h>

lws_SHA1(): make a SHA-1 digest of a buffer

Parameters
dincoming buffer
nlength of incoming buffer
mdbuffer for message digest (must be >= 20 bytes)

Reduces any size buffer into a 20-byte SHA-1 hash.

◆ lws_b64_encode_string()

LWS_VISIBLE LWS_EXTERN int lws_b64_encode_string ( const char *  in,
int  in_len,
char *  out,
int  out_size 
)

#include <include/libwebsockets/lws-sha1-base64.h>

lws_b64_encode_string(): encode a string into base 64

Parameters
inincoming buffer
in_lenlength of incoming buffer
outresult buffer
out_sizelength of result buffer

Encodes a string using b64

◆ lws_b64_encode_string_url()

LWS_VISIBLE LWS_EXTERN int lws_b64_encode_string_url ( const char *  in,
int  in_len,
char *  out,
int  out_size 
)

#include <include/libwebsockets/lws-sha1-base64.h>

lws_b64_encode_string_url(): encode a string into base 64

Parameters
inincoming buffer
in_lenlength of incoming buffer
outresult buffer
out_sizelength of result buffer

Encodes a string using b64 with the "URL" variant (+ -> -, and / -> _)

◆ lws_b64_decode_string()

LWS_VISIBLE LWS_EXTERN int lws_b64_decode_string ( const char *  in,
char *  out,
int  out_size 
)

#include <include/libwebsockets/lws-sha1-base64.h>

lws_b64_decode_string(): decode a string from base 64

Parameters
inincoming buffer
outresult buffer
out_sizelength of result buffer

Decodes a NUL-terminated string using b64

Returns used length of output buffer

◆ lws_b64_decode_string_len()

LWS_VISIBLE LWS_EXTERN int lws_b64_decode_string_len ( const char *  in,
int  in_len,
char *  out,
int  out_size 
)

#include <include/libwebsockets/lws-sha1-base64.h>

lws_b64_decode_string_len(): decode a string from base 64

Parameters
inincoming buffer
in_lenlength of incoming buffer
outresult buffer
out_sizelength of result buffer

Decodes a range of chars using b64

Returns used length of output buffer

◆ lws_b64_decode_state_init()

LWS_VISIBLE LWS_EXTERN void lws_b64_decode_state_init ( struct lws_b64state state)

◆ lws_b64_decode_stateful()

LWS_VISIBLE LWS_EXTERN int lws_b64_decode_stateful ( struct lws_b64state s,
const char *  in,
size_t *  in_len,
uint8_t out,
size_t *  out_size,
int  final 
)