libwebsockets
Lightweight C library for HTML5 websockets
|
Data Structures | |
struct | lws_genhash_ctx |
struct | lws_genhmac_ctx |
Macros | |
#define | LWS_GENHASH_LARGEST 64 |
Functions | |
LWS_VISIBLE LWS_EXTERN size_t LWS_WARN_UNUSED_RESULT | lws_genhash_size (enum lws_genhash_types type) |
LWS_VISIBLE LWS_EXTERN size_t LWS_WARN_UNUSED_RESULT | lws_genhmac_size (enum lws_genhmac_types type) |
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT | lws_genhash_init (struct lws_genhash_ctx *ctx, enum lws_genhash_types 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) |
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT | lws_genhmac_init (struct lws_genhmac_ctx *ctx, enum lws_genhmac_types type, const uint8_t *key, size_t key_len) |
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT | lws_genhmac_update (struct lws_genhmac_ctx *ctx, const void *in, size_t len) |
LWS_VISIBLE LWS_EXTERN int | lws_genhmac_destroy (struct lws_genhmac_ctx *ctx, void *result) |
Lws provides generic hash / digest accessors that abstract the ones provided by whatever tls library you are linking against.
It lets you use the same code if you build against mbedtls or OpenSSL for example.
LWS_VISIBLE LWS_EXTERN int lws_genhash_destroy | ( | struct lws_genhash_ctx * | ctx, |
void * | result | ||
) |
#include <include/libwebsockets/lws-genhash.h>
lws_genhash_destroy() - copy out the result digest and destroy the ctx
ctx | your struct lws_genhash_ctx |
result | NULL, 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_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_genhash_init | ( | struct lws_genhash_ctx * | ctx, |
enum lws_genhash_types | type | ||
) |
#include <include/libwebsockets/lws-genhash.h>
lws_genhash_init() - prepare your struct lws_genhash_ctx for use
ctx | your struct lws_genhash_ctx |
type | one of LWS_GENHASH_TYPE_... |
Initializes the hash context for the type you requested
LWS_VISIBLE LWS_EXTERN size_t LWS_WARN_UNUSED_RESULT lws_genhash_size | ( | enum lws_genhash_types | type | ) |
#include <include/libwebsockets/lws-genhash.h>
lws_genhash_size() - get hash size in bytes
type | one of LWS_GENHASH_TYPE_... |
Returns number of bytes in this type of hash
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_genhash_update | ( | struct lws_genhash_ctx * | ctx, |
const void * | in, | ||
size_t | len | ||
) |
#include <include/libwebsockets/lws-genhash.h>
lws_genhash_update() - digest len bytes of the buffer starting at in
ctx | your struct lws_genhash_ctx |
in | start of the bytes to digest |
len | count of bytes to digest |
Updates the state of your hash context to reflect digesting len bytes from in
LWS_VISIBLE LWS_EXTERN int lws_genhmac_destroy | ( | struct lws_genhmac_ctx * | ctx, |
void * | result | ||
) |
#include <include/libwebsockets/lws-genhash.h>
lws_genhmac_destroy() - copy out the result digest and destroy the ctx
ctx | your struct lws_genhmac_ctx |
result | NULL, 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_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_genhmac_init | ( | struct lws_genhmac_ctx * | ctx, |
enum lws_genhmac_types | type, | ||
const uint8_t * | key, | ||
size_t | key_len | ||
) |
#include <include/libwebsockets/lws-genhash.h>
lws_genhmac_init() - prepare your struct lws_genhmac_ctx for use
ctx | your struct lws_genhmac_ctx |
type | one of LWS_GENHMAC_TYPE_... |
key | pointer to the start of the HMAC key |
key_len | length of the HMAC key |
Initializes the hash context for the type you requested
If the return is nonzero, it failed and there is nothing needing to be destroyed.
LWS_VISIBLE LWS_EXTERN size_t LWS_WARN_UNUSED_RESULT lws_genhmac_size | ( | enum lws_genhmac_types | type | ) |
#include <include/libwebsockets/lws-genhash.h>
lws_genhmac_size() - get hash size in bytes
type | one of LWS_GENHASH_TYPE_... |
Returns number of bytes in this type of hmac
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_genhmac_update | ( | struct lws_genhmac_ctx * | ctx, |
const void * | in, | ||
size_t | len | ||
) |
#include <include/libwebsockets/lws-genhash.h>
lws_genhmac_update() - digest len bytes of the buffer starting at in
ctx | your struct lws_genhmac_ctx |
in | start of the bytes to digest |
len | count of bytes to digest |
Updates the state of your hash context to reflect digesting len bytes from in
If the return is nonzero, it failed and needs destroying.