Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"en-US,en;q\u003d0.5", "gen_ut":1702155506, "reponame":"libwebsockets", "desc":"libwebsockets lightweight C networking library", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets", "f":3, "items": [ {"schema":"libjg2-1", "cid":"786e21b8e67d9669442b113ef271177f", "oid":{ "oid": "cfa9d88e073533f7505853b6ed9e34ee80d8310f", "alias": [ "refs/heads/main"]},"blobname": "include/libwebsockets/lws-genhash.h", "blob": "/*\n * libwebsockets - small server side websockets and web server implementation\n *\n * Copyright (C) 2010 - 2019 Andy Green \u003candy@warmcat.com\u003e\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \u0022Software\u0022), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \u0022AS IS\u0022, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/*! \u005cdefgroup generichash Generic Hash\n * ## Generic Hash related functions\n *\n * Lws provides generic hash / digest accessors that abstract the ones\n * provided by whatever tls library you are linking against.\n *\n * It lets you use the same code if you build against mbedtls or OpenSSL\n * for example.\n */\n///@{\n\nenum lws_genhash_types {\n\tLWS_GENHASH_TYPE_UNKNOWN,\n\tLWS_GENHASH_TYPE_MD5,\n\tLWS_GENHASH_TYPE_SHA1,\n\tLWS_GENHASH_TYPE_SHA256,\n\tLWS_GENHASH_TYPE_SHA384,\n\tLWS_GENHASH_TYPE_SHA512,\n};\n\nenum lws_genhmac_types {\n\tLWS_GENHMAC_TYPE_UNKNOWN,\n\tLWS_GENHMAC_TYPE_SHA256,\n\tLWS_GENHMAC_TYPE_SHA384,\n\tLWS_GENHMAC_TYPE_SHA512,\n};\n\n#define LWS_GENHASH_LARGEST 64\n\nstruct lws_genhash_ctx {\n uint8_t type;\n#if defined(LWS_WITH_MBEDTLS)\n union {\n\t\tmbedtls_md5_context md5;\n \tmbedtls_sha1_context sha1;\n\t\tmbedtls_sha256_context sha256;\n\t\tmbedtls_sha512_context sha512; /* 384 also uses this */\n\t\tconst mbedtls_md_info_t *hmac;\n } u;\n#else\n const EVP_MD *evp_type;\n EVP_MD_CTX *mdctx;\n#endif\n};\n\nstruct lws_genhmac_ctx {\n uint8_t type;\n#if defined(LWS_WITH_MBEDTLS)\n\tconst mbedtls_md_info_t *hmac;\n\tmbedtls_md_context_t ctx;\n#else\n\tconst EVP_MD *evp_type;\n\n#if defined(LWS_HAVE_EVP_PKEY_new_raw_private_key)\n\tEVP_MD_CTX *ctx;\n\tEVP_PKEY *key;\n#else\n#if defined(LWS_HAVE_HMAC_CTX_new)\n HMAC_CTX *ctx;\n#else\n HMAC_CTX ctx;\n#endif\n#endif\n\n#endif\n};\n\n/** lws_genhash_size() - get hash size in bytes\n *\n * \u005cparam type:\tone of LWS_GENHASH_TYPE_...\n *\n * Returns number of bytes in this type of hash, if the hash type is unknown, it\n * will return 0.\n */\nLWS_VISIBLE LWS_EXTERN size_t LWS_WARN_UNUSED_RESULT\nlws_genhash_size(enum lws_genhash_types type);\n\n/** lws_genhmac_size() - get hash size in bytes\n *\n * \u005cparam type:\tone of LWS_GENHASH_TYPE_...\n *\n * Returns number of bytes in this type of hmac, if the hmac type is unknown, it\n * will return 0.\n */\nLWS_VISIBLE LWS_EXTERN size_t LWS_WARN_UNUSED_RESULT\nlws_genhmac_size(enum lws_genhmac_types type);\n\n/** lws_genhash_init() - prepare your struct lws_genhash_ctx for use\n *\n * \u005cparam ctx: your struct lws_genhash_ctx\n * \u005cparam type:\tone of LWS_GENHASH_TYPE_...\n *\n * Initializes the hash context for the type you requested\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_genhash_init(struct lws_genhash_ctx *ctx, enum lws_genhash_types type);\n\n/** lws_genhash_update() - digest len bytes of the buffer starting at in\n *\n * \u005cparam ctx: your struct lws_genhash_ctx\n * \u005cparam in: start of the bytes to digest\n * \u005cparam len: count of bytes to digest\n *\n * Updates the state of your hash context to reflect digesting len bytes from in\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_genhash_update(struct lws_genhash_ctx *ctx, const void *in, size_t len);\n\n/** lws_genhash_destroy() - copy out the result digest and destroy the ctx\n *\n * \u005cparam ctx: your struct lws_genhash_ctx\n * \u005cparam result: NULL, or where to copy the result hash\n *\n * Finalizes the hash and copies out the digest. Destroys any allocations such\n * that ctx can safely go out of scope after calling this.\n *\n * NULL result is supported so that you can destroy the ctx cleanly on error\n * conditions, where there is no valid result.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genhash_destroy(struct lws_genhash_ctx *ctx, void *result);\n\n/** lws_genhmac_init() - prepare your struct lws_genhmac_ctx for use\n *\n * \u005cparam ctx: your struct lws_genhmac_ctx\n * \u005cparam type:\tone of LWS_GENHMAC_TYPE_...\n * \u005cparam key: pointer to the start of the HMAC key\n * \u005cparam key_len: length of the HMAC key\n *\n * Initializes the hash context for the type you requested\n *\n * If the return is nonzero, it failed and there is nothing needing to be\n * destroyed.\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_genhmac_init(struct lws_genhmac_ctx *ctx, enum lws_genhmac_types type,\n\t\t const uint8_t *key, size_t key_len);\n\n/** lws_genhmac_update() - digest len bytes of the buffer starting at in\n *\n * \u005cparam ctx: your struct lws_genhmac_ctx\n * \u005cparam in: start of the bytes to digest\n * \u005cparam len: count of bytes to digest\n *\n * Updates the state of your hash context to reflect digesting len bytes from in\n *\n * If the return is nonzero, it failed and needs destroying.\n */\nLWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT\nlws_genhmac_update(struct lws_genhmac_ctx *ctx, const void *in, size_t len);\n\n/** lws_genhmac_destroy() - copy out the result digest and destroy the ctx\n *\n * \u005cparam ctx: your struct lws_genhmac_ctx\n * \u005cparam result: NULL, or where to copy the result hash\n *\n * Finalizes the hash and copies out the digest. Destroys any allocations such\n * that ctx can safely go out of scope after calling this.\n *\n * NULL result is supported so that you can destroy the ctx cleanly on error\n * conditions, where there is no valid result.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genhmac_destroy(struct lws_genhmac_ctx *ctx, void *result);\n///@}\n","s":{"c":1702112639,"u": 553}} ],"g": 9212,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "7d0a"}