libwebsockets
Lightweight C library for HTML5 websockets
hash

Data Structures

struct  lws_genhash_ctx
 

Functions

LWS_VISIBLE LWS_EXTERN size_t LWS_WARN_UNUSED_RESULT lws_genhash_size (int type)
 
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_genhash_init (struct lws_genhash_ctx *ctx, int type)
 
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_genhash_update (struct lws_genhash_ctx *ctx, const void *in, size_t len)
 
LWS_VISIBLE LWS_EXTERN int lws_genhash_destroy (struct lws_genhash_ctx *ctx, void *result)
 

Detailed Description

Generic Hash related functions

Lws provides generic hash / digest accessors that abstract the ones provided by whatever OpenSSL library you are linking against.

It lets you use the same code if you build against mbedtls or OpenSSL for example.

Function Documentation

◆ lws_genhash_destroy()

LWS_VISIBLE LWS_EXTERN int lws_genhash_destroy ( struct lws_genhash_ctx ctx,
void *  result 
)

#include <lib/libwebsockets.h>

lws_genhash_destroy() - copy out the result digest and destroy the ctx

Parameters
ctxyour struct lws_genhash_ctx
resultNULL, or where to copy the result hash

Finalizes the hash and copies out the digest. Destroys any allocations such that ctx can safely go out of scope after calling this.

NULL result is supported so that you can destroy the ctx cleanly on error conditions, where there is no valid result.

◆ lws_genhash_init()

LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_genhash_init ( struct lws_genhash_ctx ctx,
int  type 
)

#include <lib/libwebsockets.h>

lws_genhash_init() - prepare your struct lws_genhash_ctx for use

Parameters
ctxyour struct lws_genhash_ctx
typeone of LWS_GENHASH_TYPE_...

Initializes the hash context for the type you requested

◆ lws_genhash_size()

LWS_VISIBLE LWS_EXTERN size_t LWS_WARN_UNUSED_RESULT lws_genhash_size ( int  type)

#include <lib/libwebsockets.h>

lws_genhash_size() - get hash size in bytes

Parameters
typeone of LWS_GENHASH_TYPE_...

Returns number of bytes in this type of hash

◆ lws_genhash_update()

LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_genhash_update ( struct lws_genhash_ctx ctx,
const void *  in,
size_t  len 
)

#include <lib/libwebsockets.h>

lws_genhash_update() - digest len bytes of the buffer starting at in

Parameters
ctxyour struct lws_genhash_ctx
instart of the bytes to digest
lencount of bytes to digest

Updates the state of your hash context to reflect digesting len bytes from in