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":1580271237, "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":"d83c7be82bfc66ab963c2d0d2a8d79ef", "oid":{ "oid": "00d206d2b27969cf83df45059058e34d37a47b49", "alias": [ "refs/heads/master"]},"blobname": "include/libwebsockets/lws-genaes.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 generic AES\n * ## Generic AES related functions\n *\n * Lws provides generic AES functions 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\n#if defined(LWS_WITH_MBEDTLS)\n#include \u003cmbedtls/aes.h\u003e\n#include \u003cmbedtls/gcm.h\u003e\n#endif\n\nenum enum_aes_modes {\n\tLWS_GAESM_CBC,\n\tLWS_GAESM_CFB128,\n\tLWS_GAESM_CFB8,\n\tLWS_GAESM_CTR,\n\tLWS_GAESM_ECB,\n\tLWS_GAESM_OFB,\n\tLWS_GAESM_XTS,\t\t/* care... requires double-length key */\n\tLWS_GAESM_GCM,\n\tLWS_GAESM_KW,\n};\n\nenum enum_aes_operation {\n\tLWS_GAESO_ENC,\n\tLWS_GAESO_DEC\n};\n\nenum enum_aes_padding {\n\tLWS_GAESP_NO_PADDING,\n\tLWS_GAESP_WITH_PADDING\n};\n\n/* include/libwebsockets/lws-jwk.h must be included before this */\n\n#define LWS_AES_BLOCKSIZE 128\n\nstruct lws_genaes_ctx {\n#if defined(LWS_WITH_MBEDTLS)\n\tunion {\n\t\tmbedtls_aes_context ctx;\n#if defined(MBEDTLS_CIPHER_MODE_XTS)\n\t\tmbedtls_aes_xts_context ctx_xts;\n#endif\n\t\tmbedtls_gcm_context ctx_gcm;\n\t} u;\n#else\n\tEVP_CIPHER_CTX *ctx;\n\tconst EVP_CIPHER *cipher;\n\tENGINE *engine;\n\tchar init;\n#endif\n\tunsigned char tag[16];\n\tstruct lws_gencrypto_keyelem *k;\n\tenum enum_aes_operation op;\n\tenum enum_aes_modes mode;\n\tenum enum_aes_padding padding;\n\tint taglen;\n\tchar underway;\n};\n\n/** lws_genaes_create() - Create RSA public decrypt context\n *\n * \u005cparam ctx: your struct lws_genaes_ctx\n * \u005cparam op: LWS_GAESO_ENC or LWS_GAESO_DEC\n * \u005cparam mode: one of LWS_GAESM_\n * \u005cparam el: struct prepared with key element data\n * \u005cparam padding: 0 \u003d no padding, 1 \u003d padding\n * \u005cparam engine: if openssl engine used, pass the pointer here\n *\n * Creates an RSA context with a public key associated with it, formed from\n * the key elements in \u005cp el.\n *\n * Returns 0 for OK or nonzero for error.\n *\n * This and related APIs operate identically with OpenSSL or mbedTLS backends.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genaes_create(struct lws_genaes_ctx *ctx, enum enum_aes_operation op,\n\t\t enum enum_aes_modes mode, struct lws_gencrypto_keyelem *el,\n\t\t enum enum_aes_padding padding, void *engine);\n\n/** lws_genaes_destroy() - Destroy genaes AES context\n *\n * \u005cparam ctx: your struct lws_genaes_ctx\n * \u005cparam tag: NULL, or, GCM-only: buffer to receive tag\n * \u005cparam tlen: 0, or, GCM-only: length of tag buffer\n *\n * Destroys any allocations related to \u005cp ctx.\n *\n * For GCM only, up to tlen bytes of tag buffer will be set on exit.\n *\n * This and related APIs operate identically with OpenSSL or mbedTLS backends.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genaes_destroy(struct lws_genaes_ctx *ctx, unsigned char *tag, size_t tlen);\n\n/** lws_genaes_crypt() - Encrypt or decrypt\n *\n * \u005cparam ctx: your struct lws_genaes_ctx\n * \u005cparam in: input plaintext or ciphertext\n * \u005cparam len: length of input (which is always length of output)\n * \u005cparam out: output plaintext or ciphertext\n * \u005cparam iv_or_nonce_ctr_or_data_unit_16: NULL, iv, nonce_ctr16, or data_unit16\n * \u005cparam stream_block_16: pointer to 16-byte stream block for CTR mode only\n * \u005cparam nc_or_iv_off: NULL or pointer to nc, or iv_off\n * \u005cparam taglen: length of tag\n *\n * Encrypts or decrypts using the AES mode set when the ctx was created.\n * The last three arguments have different meanings depending on the mode:\n *\n * \t\t\t KW CBC CFB128 CFB8 CTR ECB OFB XTS\n * iv_or_nonce_ct.._unit_16 : iv iv iv iv nonce NULL iv dataunt\n * stream_block_16\t : NULL NULL NULL NULL stream NULL NULL NULL\n * nc_or_iv_off\t\t : NULL NULL iv_off NULL nc_off NULL iv_off NULL\n *\n * For GCM:\n *\n * iv_or_nonce_ctr_or_data_unit_16 : iv\n * stream_block_16\t\t : pointer to tag\n * nc_or_iv_off\t\t\t : set pointed-to size_t to iv length\n * in\t\t\t\t : first call: additional data, subsequently\n *\t\t\t\t : input data\n * len\t\t\t\t : first call: add data length, subsequently\n *\t\t\t\t : input / output length\n *\n * The length of the optional arg is always 16 if used, regardless of the mode.\n *\n * Returns 0 for OK or nonzero for error.\n *\n * This and related APIs operate identically with OpenSSL or mbedTLS backends.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_genaes_crypt(struct lws_genaes_ctx *ctx, const uint8_t *in, size_t len,\n\t\t uint8_t *out,\n\t\t uint8_t *iv_or_nonce_ctr_or_data_unit_16,\n\t\t uint8_t *stream_block_16,\n\t\t size_t *nc_or_iv_off, int taglen);\n\n///@}\n","s":{"c":1580271237,"u": 327}} ],"g": 2892,"chitpc": 0,"ehitpc": 0, "indexed":0 }