{"id":47,"date":"2024-03-31T19:38:15","date_gmt":"2024-03-31T11:38:15","guid":{"rendered":"http:\/\/175.178.247.106\/?p=47"},"modified":"2025-03-04T20:03:50","modified_gmt":"2025-03-04T12:03:50","slug":"lua%e8%84%9a%e6%9c%ac%e5%8a%a0%e5%af%86%ef%bc%88%e4%b8%80%ef%bc%89","status":"publish","type":"post","link":"http:\/\/175.178.247.106\/index.php\/2024\/03\/31\/lua%e8%84%9a%e6%9c%ac%e5%8a%a0%e5%af%86%ef%bc%88%e4%b8%80%ef%bc%89\/","title":{"rendered":"Lua\u811a\u672c\u52a0\u5bc6\uff08\u4e00\uff09"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"hi8Y9\">\u9700\u6c42\u80cc\u666f\uff1a<\/h2>\n\n\n\n<p id=\"u95cd24ce\">\u57fa\u4e8e Nginx \u5f00\u53d1\u7684\u670d\u52a1\u5668\uff0c\u4e1a\u52a1\u903b\u8f91\u4f7f\u7528\u4e86 Lua \u811a\u672c\u8fdb\u884c\u7f16\u7a0b\u3002\u6253\u5305\u90e8\u7f72\u5230\u73b0\u573a\u7684\u65f6\u5019\uff0c\u4e1a\u52a1\u4ee3\u7801\u5b8c\u5168\u66b4\u9732\uff0c\u5b89\u88c5\u5305\u6d41\u8f6c\u8fc7\u7a0b\u4e2d\uff0c\u4e5f\u5bb9\u6613\u6cc4\u9732\uff0c\u66b4\u9732 Lua \u811a\u672c\u7684\u4e1a\u52a1\u903b\u8f91\u3002<\/p>\n\n\n\n<p id=\"u162e07f2\">\u5b89\u5168\u8d77\u89c1\uff0c\u5bf9 Lua \u811a\u672c\u8fdb\u884c\u52a0\u5bc6\uff0c\u540c\u65f6\u8ba9 Nginx \u540c\u65f6\u652f\u6301\u52a0\u8f7d\u52a0\u5bc6\u548c\u975e\u52a0\u5bc6\u7684 Lua \u811a\u672c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"aucOZ\">Nginx \u5bf9 Lua \u7684\u652f\u6301<\/h2>\n\n\n\n<p id=\"u737bdb6e\">nginx \u4e3a\u4e86\u652f\u6301 lua\uff0c\u9700\u8981\u8981\u6709 lua \u6a21\u5757\uff0c<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/openresty\/lua-nginx-module\/archive\/refs\/tags\/v0.10.22.tar.gz\">https:\/\/github.com\/openresty\/lua-nginx-module\/archive\/refs\/tags\/v0.10.22.tar.gz<\/a><\/p>\n\n\n\n<p id=\"uc419de69\">\u6709\u4e86 lua \u6a21\u5757\u6211\u4eec\u8fd8\u9700\u8981\u5b89\u88c5 luajit \u5e93\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Ej9uP\">\u6e90\u7801\u5206\u6790<\/h2>\n\n\n\n<p id=\"u60007ab6\">Lua \u811a\u672c\u7684\u52a0\u8f7d\u662f\u5728 LuaJIT \u4e2d\u5b9e\u73b0\uff0clua \u6a21\u5757\u53ea\u662f\u4f1a\u8c03\u7528 C \u7684\u4e00\u4e9b\u63a5\u53e3\u3002\u6240\u4ee5\u8981\u5b9e\u73b0\u52a0\u5bc6\uff0c\u5219\u9700\u8981\u66f4\u6539 LuaJIT \u4e2d\u7684\u63a5\u53e3\u3002<\/p>\n\n\n\n<p id=\"ucfc6dd75\">LuaJIT \u52a0\u8f7d lua \u811a\u672c\u5e76\u4e0d\u662f\u4e00\u6b21\u6027\u52a0\u8f7d\u6587\u4ef6\uff0c\u800c\u662f\u4f1a\u8c03\u7528 getc\uff0cungetc\uff0c\u4ee5\u53ca fread \u51fd\u6570\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre id=\"i0E3I\" class=\"wp-block-code\"><code>ngx_int_t\nngx_http_lua_clfactory_loadfile(lua_State *L, const char *filename)\n{\n    int                         c, status, readstatus;\n    ngx_flag_t                  sharp;\n\n    ngx_http_lua_clfactory_file_ctx_t        lf;\n\n    \/* index of filename on the stack *\/\n    int                         fname_index;\n\n    sharp = 0;\n    fname_index = lua_gettop(L) + 1;\n\n    lf.extraline = 0;\n    lf.file_type = NGX_LUA_TEXT_FILE;\n\n#ifndef OPENRESTY_LUAJIT\n    lf.begin_code.ptr = CLFACTORY_BEGIN_CODE;\n    lf.begin_code_len = CLFACTORY_BEGIN_SIZE;\n    lf.end_code.ptr = CLFACTORY_END_CODE;\n    lf.end_code_len = CLFACTORY_END_SIZE;\n#endif\n\n    lua_pushfstring(L, \"@%s\", filename);\n\n    lf.f = fopen(filename, \"r\");\n    if (lf.f == NULL) {\n        return ngx_http_lua_clfactory_errfile(L, \"open\", fname_index);\n    }\n\n    c = getc(lf.f);\n\n    if (c == '#') {  \/* Unix exec. file? *\/\n        lf.extraline = 1;\n\n        while ((c = getc(lf.f)) != EOF &amp;&amp; c != '\\n') {\n            \/* skip first line *\/\n        }\n\n        if (c == '\\n') {\n            c = getc(lf.f);\n        }\n\n        sharp = 1;\n    }\n\n    if (c == LUA_SIGNATURE&#91;0] &amp;&amp; filename) {  \/* binary file? *\/\n        lf.f = freopen(filename, \"rb\", lf.f);  \/* reopen in binary mode *\/\n\n        if (lf.f == NULL) {\n            return ngx_http_lua_clfactory_errfile(L, \"reopen\", fname_index);\n        }\n\n        \/* check whether lib jit exists *\/\n        luaL_findtable(L, LUA_REGISTRYINDEX, \"_LOADED\", 1);\n        lua_getfield(L, -1, \"jit\");  \/* get _LOADED&#91;\"jit\"] *\/\n\n        if (lua_istable(L, -1)) {\n            lf.file_type = NGX_LUA_BT_LJ;\n\n        } else {\n            lf.file_type = NGX_LUA_BT_LUA;\n        }\n\n        lua_pop(L, 2);\n\n        \/*\n         * Loading bytecode with an extra header is disabled for security\n         * reasons. This may circumvent the usual check for bytecode vs.\n         * Lua code by looking at the first char. Since this is a potential\n         * security violation no attempt is made to echo the chunkname either.\n         *\/\n        if (lf.file_type == NGX_LUA_BT_LJ &amp;&amp; sharp) {\n\n            if (filename) {\n                fclose(lf.f);  \/* close file (even in case of errors) *\/\n            }\n\n            filename = lua_tostring(L, fname_index) + 1;\n            lua_pushfstring(L, \"bad byte-code header in %s\", filename);\n            lua_remove(L, fname_index);\n\n            return LUA_ERRFILE;\n        }\n\n        while ((c = getc(lf.f)) != EOF &amp;&amp; c != LUA_SIGNATURE&#91;0]) {\n            \/* skip eventual `#!...' *\/\n        }\n\n#ifndef OPENRESTY_LUAJIT\n        status = ngx_http_lua_clfactory_bytecode_prepare(L, &amp;lf, fname_index);\n\n        if (status != 0) {\n            return status;\n        }\n#endif\n\n        lf.extraline = 0;\n    }\n\n#ifndef OPENRESTY_LUAJIT\n    if (lf.file_type == NGX_LUA_TEXT_FILE) {\n        ungetc(c, lf.f);\n    }\n\n    lf.sent_begin = lf.sent_end = 0;\n\n#else\n    ungetc(c, lf.f);\n#endif\n    status = lua_load(L, ngx_http_lua_clfactory_getF, &amp;lf,\n                      lua_tostring(L, -1));\n\n    readstatus = ferror(lf.f);\n\n    if (filename) {\n        fclose(lf.f);  \/* close file (even in case of errors) *\/\n    }\n\n    if (readstatus) {\n        lua_settop(L, fname_index);  \/* ignore results from `lua_load' *\/\n        return ngx_http_lua_clfactory_errfile(L, \"read\", fname_index);\n    }\n\n    lua_remove(L, fname_index);\n\n    return status;\n}<\/code><\/pre>\n\n\n\n<p id=\"u38b8e7fd\">c = getc(lf.f);<\/p>\n\n\n\n<p id=\"ueb51f68c\">ungetc(c, lf.f);<\/p>\n\n\n\n<p id=\"u5de891a8\">\u540e\u9762\u518d\u8c03\u7528 lua_load\uff0c\u6587\u4ef6\u8bfb\u53d6\u7684\u56de\u8c03\u51fd\u6570\u4e3angx_http_lua_clfactory_getF\u3002<\/p>\n\n\n\n<pre id=\"BGigI\" class=\"wp-block-code\"><code>status = lua_load(L, ngx_http_lua_clfactory_getF, &amp;lf,\n                      lua_tostring(L, -1));<\/code><\/pre>\n\n\n\n<p id=\"u70303694\">ngx_http_lua_clfactory_getF<\/p>\n\n\n\n<pre id=\"yCy7t\" class=\"wp-block-code\"><code>static const char *\nngx_http_lua_clfactory_getF(lua_State *L, void *ud, size_t *size)\n{\n#ifndef OPENRESTY_LUAJIT\n    char                        *buf;\n#endif\n    size_t                       num;\n\n    ngx_http_lua_clfactory_file_ctx_t        *lf;\n\n    lf = (ngx_http_lua_clfactory_file_ctx_t *) ud;\n\n    if (lf-&gt;extraline) {\n        lf-&gt;extraline = 0;\n        *size = 1;\n        return \"\\n\";\n    }\n\n#ifndef OPENRESTY_LUAJIT\n    if (lf-&gt;sent_begin == 0) {\n        lf-&gt;sent_begin = 1;\n        *size = lf-&gt;begin_code_len;\n\n        if (lf-&gt;file_type == NGX_LUA_TEXT_FILE) {\n            buf = lf-&gt;begin_code.ptr;\n\n        } else {\n            buf = lf-&gt;begin_code.str;\n        }\n\n        return buf;\n    }\n#endif \/* OPENRESTY_LUAJIT *\/\n\n    num = fread(lf-&gt;buff, 1, sizeof(lf-&gt;buff), lf-&gt;f);\n\n    dd(\"fread returned %d\", (int) num);\n\n    if (num == 0) {\n#ifndef OPENRESTY_LUAJIT\n        if (lf-&gt;sent_end == 0) {\n            lf-&gt;sent_end = 1;\n            *size = lf-&gt;end_code_len;\n\n            if (lf-&gt;file_type == NGX_LUA_BT_LUA) {\n                buf = lf-&gt;end_code.str;\n\n            } else {\n                buf = lf-&gt;end_code.ptr;\n            }\n\n            return buf;\n        }\n#endif \/* OPENRESTY_LUAJIT *\/\n\n        *size = 0;\n        return NULL;\n    }\n\n#ifndef OPENRESTY_LUAJIT\n    if (lf-&gt;file_type == NGX_LUA_BT_LJ) {\n        \/* skip the footer(\\x00) in luajit *\/\n\n        lf-&gt;rest_len -= num;\n\n        if (lf-&gt;rest_len == 0) {\n            if (--num == 0 &amp;&amp; lf-&gt;sent_end == 0) {\n                lf-&gt;sent_end = 1;\n                buf = lf-&gt;end_code.ptr;\n                *size = lf-&gt;end_code_len;\n\n                return buf;\n            }\n        }\n    }\n#endif \/* OPENRESTY_LUAJIT *\/\n\n    *size = num;\n    return lf-&gt;buff;\n}<\/code><\/pre>\n\n\n\n<p id=\"uf86cad3f\">ngx_http_lua_clfactory_getF \u4e2d\u4f7f\u7528\u5230\u4e86 fread\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ux9m4\">\u521d\u6b65\u7ed3\u8bba<\/h2>\n\n\n\n<p id=\"u1166d082\">\u6240\u4ee5\u603b\u7ed3\u8d77\u6765\uff0c\u6211\u4eec\u8981 hook \u6389 getc\uff0cungetc\u4ee5\u53ca fread \u51fd\u6570\uff0c\u8fd9\u91cc\u7684 hook \u5c31\u662f\u6362\u6389 getc, ungetc \u4ee5\u53ca fread \u51fd\u6570\uff0c\u529f\u80fd\u4e0d\u53d8\uff0c\u53ea\u662f\u64cd\u4f5c\u7684\u662f\u52a0\u5bc6\u6587\u4ef6\uff0c\u8fd4\u56de\u7684\u662f\u660e\u6587\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"yrKvX\">\u52a0\u5bc6\u7b97\u6cd5\u7684\u9009\u62e9<\/h2>\n\n\n\n<p id=\"ubf251127\">\u8bfb\u53d6\u52a0\u5bc6\u6587\u4ef6\u6bcf\u6b21\u7684\u5b57\u8282\u6570\u90fd\u662f\u4e0d\u56fa\u5b9a\u7684\uff0c\u6240\u4ee5\u53ea\u80fd\u9009\u62e9\u6d41\u52a0\u5bc6\u7b97\u6cd5\u3002<\/p>\n\n\n\n<p id=\"ue5a77368\">\u8fd9\u91cc\u9009\u62e9 CBC \u52a0\u5bc6\u7b97\u6cd5\uff0cCBC \u52a0\u5bc6\uff0c\u5f53\u524d\u52a0\u5bc6\u7684\u7ed3\u679c\u548c\u524d\u4e00\u4e2a\u5757\u6709\u5173\u7cfb\uff0c\u8fd9\u6837\u5c31\u89c4\u907f\u4e86\u7528\u7edf\u8ba1\u7684\u65b9\u6cd5\u731c\u51fa\u660e\u6587\u3002<\/p>\n\n\n\n<p id=\"u5058d27b\">CBC \u7b97\u6cd5<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"lArDV\">CBC\uff08Cipher Block Chaining\uff09\u7b97\u6cd5\u4ecb\u7ecd<\/h3>\n\n\n\n<p id=\"ub5e9a30b\">**CBC\uff08Cipher Block Chaining\uff09**\u662f\u4e00\u79cd\u5e38\u7528\u7684\u5206\u7ec4\u5bc6\u7801\u52a0\u5bc6\u6a21\u5f0f\uff0c\u5b83\u901a\u8fc7\u5c06\u6bcf\u4e2a\u660e\u6587\u5757\u4e0e\u524d\u4e00\u4e2a\u52a0\u5bc6\u540e\u7684\u5bc6\u6587\u5757\u8fdb\u884c\u201c\u94fe\u5f0f\u201d\u64cd\u4f5c\uff0c\u4ece\u800c\u589e\u52a0\u52a0\u5bc6\u7684\u590d\u6742\u6027\u548c\u5b89\u5168\u6027\u3002CBC\u6a21\u5f0f\u662f\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\u4e2d\u7684\u4e00\u79cd\u5e38\u89c1\u5de5\u4f5c\u6a21\u5f0f\uff0c\u901a\u5e38\u4e0e\u5206\u7ec4\u5bc6\u7801\uff08\u5982 AES\u3001DES\uff09\u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"jxhsL\">\u5de5\u4f5c\u539f\u7406<\/h3>\n\n\n\n<p id=\"u9aba39a7\">\u5728 CBC \u6a21\u5f0f\u4e2d\uff0c\u660e\u6587\u6570\u636e\u88ab\u5212\u5206\u4e3a\u56fa\u5b9a\u5927\u5c0f\u7684\u5757\uff08\u4f8b\u5982 128 \u4f4d\uff09\u3002\u6bcf\u4e2a\u5757\u4f1a\u7ecf\u8fc7\u4ee5\u4e0b\u5904\u7406\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u521d\u59cb\u5316\u5411\u91cf\uff08IV\uff09<\/strong>\uff1a\u9996\u5148\uff0cCBC \u6a21\u5f0f\u9700\u8981\u4e00\u4e2a\u968f\u673a\u751f\u6210\u7684\u521d\u59cb\u5316\u5411\u91cf\uff08IV\uff09\u3002IV \u7684\u5927\u5c0f\u4e0e\u5206\u7ec4\u5bc6\u7801\u7684\u5757\u5927\u5c0f\u4e00\u81f4\uff08\u4f8b\u5982\uff0cAES \u7684\u5757\u5927\u5c0f\u4e3a 128 \u4f4d\uff09\u3002IV \u5728\u52a0\u5bc6\u8fc7\u7a0b\u4e2d\u4e0e\u660e\u6587\u7684\u7b2c\u4e00\u4e2a\u5757\u8fdb\u884c\u5f02\u6216\uff08XOR\uff09\u64cd\u4f5c\u3002<\/li>\n\n\n\n<li><strong>\u94fe\u5f0f\u5f02\u6216\u52a0\u5bc6<\/strong>\uff1a\u52a0\u5bc6\u8fc7\u7a0b\u4e2d\u7684\u6bcf\u4e2a\u5757\u90fd\u4f9d\u8d56\u4e8e\u524d\u4e00\u4e2a\u5bc6\u6587\u5757\u3002\u5bf9\u4e8e\u7b2c\u4e00\u4e2a\u660e\u6587\u5757\uff0c\u9996\u5148\u5c06\u5176\u4e0e IV \u8fdb\u884c\u5f02\u6216\u64cd\u4f5c\uff0c\u7136\u540e\u5bf9\u7ed3\u679c\u8fdb\u884c\u52a0\u5bc6\uff0c\u5f97\u5230\u7b2c\u4e00\u4e2a\u5bc6\u6587\u5757\u3002\u5bf9\u4e8e\u540e\u7eed\u7684\u6bcf\u4e2a\u660e\u6587\u5757\uff0c\u90fd\u4f1a\u5c06\u5f53\u524d\u7684\u660e\u6587\u5757\u4e0e\u524d\u4e00\u4e2a\u5bc6\u6587\u5757\u8fdb\u884c\u5f02\u6216\u64cd\u4f5c\uff0c\u7136\u540e\u518d\u52a0\u5bc6\uff0c\u5f97\u5230\u5bf9\u5e94\u7684\u5bc6\u6587\u5757\u3002\u5177\u4f53\u6765\u8bf4\uff1a<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7b2c\u4e00\u4e2a\u5bc6\u6587\u5757\uff1a<code>C1 = E(IV \u2295 P1)<\/code> \uff08\u5176\u4e2d <code>P1<\/code> \u662f\u7b2c\u4e00\u4e2a\u660e\u6587\u5757\uff0c<code>E()<\/code> \u8868\u793a\u52a0\u5bc6\u64cd\u4f5c\uff0c<code>IV<\/code> \u662f\u521d\u59cb\u5316\u5411\u91cf\uff09<\/li>\n\n\n\n<li>\u7b2c\u4e8c\u4e2a\u5bc6\u6587\u5757\uff1a<code>C2 = E(C1 \u2295 P2)<\/code><\/li>\n\n\n\n<li>\u7b2c\u4e09\u4e2a\u5bc6\u6587\u5757\uff1a<code>C3 = E(C2 \u2295 P3)<\/code><\/li>\n\n\n\n<li>\u4ee5\u6b64\u7c7b\u63a8\u2026<\/li>\n<\/ul>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u89e3\u5bc6\u8fc7\u7a0b<\/strong>\uff1a\u89e3\u5bc6\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528\u76f8\u540c\u7684\u5bc6\u94a5\u548c IV\u3002\u89e3\u5bc6\u7684\u8fc7\u7a0b\u53cd\u5411\u8fdb\u884c\uff0c\u5373\u5148\u89e3\u5bc6\u5bc6\u6587\u5757\uff0c\u7136\u540e\u5c06\u89e3\u5bc6\u540e\u7684\u7ed3\u679c\u4e0e\u524d\u4e00\u4e2a\u5bc6\u6587\u5757\u5f02\u6216\uff0c\u6062\u590d\u51fa\u539f\u59cb\u7684\u660e\u6587\u6570\u636e\u3002<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7b2c\u4e00\u4e2a\u660e\u6587\u5757\uff1a<code>P1 = D(C1) \u2295 IV<\/code><\/li>\n\n\n\n<li>\u7b2c\u4e8c\u4e2a\u660e\u6587\u5757\uff1a<code>P2 = D(C2) \u2295 C1<\/code><\/li>\n\n\n\n<li>\u7b2c\u4e09\u4e2a\u660e\u6587\u5757\uff1a<code>P3 = D(C3) \u2295 C2<\/code><\/li>\n\n\n\n<li>\u4ee5\u6b64\u7c7b\u63a8\u2026<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"yEdmm\">\u7279\u70b9\u548c\u4f18\u7f3a\u70b9<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"QSKGu\">\u4f18\u70b9\uff1a<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5b89\u5168\u6027<\/strong>\uff1a\u7531\u4e8e CBC \u6a21\u5f0f\u6d89\u53ca\u5230\u5c06\u6bcf\u4e2a\u660e\u6587\u5757\u4e0e\u524d\u4e00\u4e2a\u5bc6\u6587\u5757\u8fdb\u884c\u5f02\u6216\u64cd\u4f5c\uff0c\u8fd9\u4f7f\u5f97\u76f8\u540c\u7684\u660e\u6587\u5728\u4e0d\u540c\u7684\u52a0\u5bc6\u8fc7\u7a0b\u4e2d\u4f1a\u751f\u6210\u4e0d\u540c\u7684\u5bc6\u6587\uff08\u5373\u4f7f\u4f7f\u7528\u76f8\u540c\u7684\u5bc6\u94a5\uff09\u3002\u56e0\u6b64\uff0cCBC \u80fd\u591f\u9632\u6b62\u201c\u76f8\u540c\u660e\u6587\u4ea7\u751f\u76f8\u540c\u5bc6\u6587\u201d\u7684\u653b\u51fb\uff08\u5373\u201c\u9891\u7387\u5206\u6790\u201d\u653b\u51fb\uff09\u3002<\/li>\n\n\n\n<li><strong>\u6297\u91cd\u653e\u653b\u51fb<\/strong>\uff1a\u7531\u4e8e\u5bc6\u6587\u5757\u7684\u52a0\u5bc6\u4f9d\u8d56\u4e8e\u524d\u4e00\u4e2a\u5757\u7684\u5bc6\u6587\uff0c\u56e0\u6b64\u5373\u4f7f\u6709\u91cd\u653e\u653b\u51fb\uff0c\u653b\u51fb\u8005\u4e5f\u65e0\u6cd5\u4f2a\u9020\u6709\u6548\u7684\u5bc6\u6587\u5757\u3002<\/li>\n\n\n\n<li><strong>\u5206\u7ec4\u52a0\u5bc6<\/strong>\uff1a\u53ef\u4ee5\u5c06\u660e\u6587\u5206\u5272\u6210\u56fa\u5b9a\u5927\u5c0f\u7684\u5757\u8fdb\u884c\u52a0\u5bc6\uff0c\u8fd9\u5bf9\u4e8e\u4e00\u4e9b\u6570\u636e\u683c\u5f0f\uff08\u5982\u6587\u4ef6\u52a0\u5bc6\uff09\u975e\u5e38\u65b9\u4fbf\u3002<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"XqRkk\">\u7f3a\u70b9\uff1a<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u521d\u59cb\u5316\u5411\u91cf\uff08IV\uff09\u95ee\u9898<\/strong>\uff1aIV \u7684\u968f\u673a\u6027\u548c\u4fdd\u5bc6\u6027\u81f3\u5173\u91cd\u8981\u3002\u5982\u679c IV \u91cd\u590d\u6216\u88ab\u6cc4\u9732\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u52a0\u5bc6\u8fc7\u7a0b\u4e2d\u7684\u5b89\u5168\u6027\u95ee\u9898\u3002\u56e0\u6b64\uff0cIV \u901a\u5e38\u9700\u8981\u968f\u673a\u751f\u6210\uff0c\u5e76\u4e14\u5fc5\u987b\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u4e0e\u5bc6\u6587\u4e00\u540c\u53d1\u9001\u3002<\/li>\n\n\n\n<li><strong>\u5e76\u884c\u5316\u96be\u5ea6<\/strong>\uff1aCBC \u6a21\u5f0f\u5728\u52a0\u5bc6\u548c\u89e3\u5bc6\u8fc7\u7a0b\u4e2d\u90fd\u4f9d\u8d56\u4e8e\u524d\u4e00\u4e2a\u5bc6\u6587\u5757\u7684\u8f93\u51fa\uff0c\u8fd9\u4f7f\u5f97 CBC \u6a21\u5f0f\u4e0d\u5bb9\u6613\u5e76\u884c\u5904\u7406\uff08\u8fd9\u5728\u786c\u4ef6\u6216\u591a\u6838\u5904\u7406\u5668\u4e0a\u662f\u4e00\u4e2a\u95ee\u9898\uff09\u3002\u6bcf\u4e2a\u5757\u7684\u52a0\u5bc6\u5fc5\u987b\u7b49\u5f85\u524d\u4e00\u4e2a\u5757\u7684\u52a0\u5bc6\u7ed3\u679c\uff0c\u56e0\u6b64\u4e0d\u80fd\u9ad8\u6548\u5730\u5e76\u884c\u5316\u3002<\/li>\n\n\n\n<li><strong>\u586b\u5145\u95ee\u9898<\/strong>\uff1a\u7531\u4e8e\u660e\u6587\u7684\u957f\u5ea6\u901a\u5e38\u4e0d\u662f\u5757\u7684\u6574\u6570\u500d\uff0c\u6240\u4ee5\u9700\u8981\u8fdb\u884c\u586b\u5145\u64cd\u4f5c\uff0c\u53ef\u80fd\u5bfc\u81f4\u989d\u5916\u7684\u5b58\u50a8\u548c\u5904\u7406\u5f00\u9500\u3002<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"u9d3O\">\u5e94\u7528\u573a\u666f\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u52a0\u5bc6\u6587\u4ef6<\/strong>\uff1aCBC \u6a21\u5f0f\u901a\u5e38\u7528\u4e8e\u6587\u4ef6\u52a0\u5bc6\uff0c\u56e0\u4e3a\u5b83\u80fd\u5904\u7406\u957f\u6570\u636e\u6d41\uff0c\u5e76\u4e14\u907f\u514d\u76f8\u540c\u6570\u636e\u4ea7\u751f\u76f8\u540c\u5bc6\u6587\u3002<\/li>\n\n\n\n<li><strong>SSL\/TLS<\/strong>\uff1a\u5728\u4e00\u4e9b\u7f51\u7edc\u5b89\u5168\u534f\u8bae\uff08\u5982 SSL\/TLS\uff09\u4e2d\uff0c\u4e5f\u4f7f\u7528 CBC \u6a21\u5f0f\u6765\u52a0\u5bc6\u4f20\u8f93\u7684\u6570\u636e\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u5e93\u52a0\u5bc6<\/strong>\uff1a\u5728\u52a0\u5bc6\u6570\u636e\u5e93\u5185\u5bb9\u65f6\uff0cCBC \u6a21\u5f0f\u5e38\u5e38\u7528\u4e8e\u4fdd\u62a4\u5b58\u50a8\u7684\u654f\u611f\u6570\u636e\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"fIo6A\">\u5b89\u5168\u6027<\/h3>\n\n\n\n<p id=\"ua8157f67\">\u867d\u7136 CBC \u662f\u4e00\u79cd\u6709\u6548\u7684\u52a0\u5bc6\u6a21\u5f0f\uff0c\u4f46\u5b83\u4e5f\u6709\u4e00\u4e9b\u6f5c\u5728\u7684\u653b\u51fb\u65b9\u5f0f\uff0c\u5c24\u5176\u662f<strong>IV\u7ba1\u7406\u4e0d\u5f53<\/strong>\u3002\u653b\u51fb\u8005\u5982\u679c\u77e5\u9053 IV \u6216\u8005\u4e24\u4e2a\u5bc6\u6587\u5757\u7684 IV \u533a\u5206\u4e0d\u6e05\u695a\uff0c\u53ef\u80fd\u4f1a\u8fdb\u884c\u7279\u5b9a\u7684\u653b\u51fb\uff08\u4f8b\u5982\uff0c\u4fee\u6539\u5bc6\u6587\u3001\u91cd\u653e\u653b\u51fb\u7b49\uff09\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528 CBC \u65f6\uff0c\u5fc5\u987b\u5c0f\u5fc3\u5904\u7406 IV\uff0c\u786e\u4fdd\u6bcf\u6b21\u52a0\u5bc6\u4f7f\u7528\u4e0d\u540c\u7684\u968f\u673a IV\uff0c\u5e76\u4e14 IV \u548c\u5bc6\u6587\u4e00\u8d77\u53d1\u9001\u3002<\/p>\n\n\n\n<p id=\"ua5c329db\">\u53e6\u5916\uff0c\u4f7f\u7528 CBC \u65f6\u8fd8\u8981\u6ce8\u610f\u586b\u5145\u95ee\u9898\u3002\u5e38\u89c1\u7684\u586b\u5145\u65b9\u6cd5\u5305\u62ec PKCS#7\uff0c\u76ee\u7684\u662f\u786e\u4fdd\u660e\u6587\u7684\u957f\u5ea6\u662f\u5757\u5927\u5c0f\u7684\u6574\u6570\u500d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"tLIh2\"><\/h3>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9700\u6c42\u80cc\u666f\uff1a \u57fa\u4e8e Nginx \u5f00\u53d1\u7684\u670d\u52a1\u5668\uff0c\u4e1a\u52a1\u903b\u8f91\u4f7f\u7528\u4e86 Lua \u811a\u672c\u8fdb\u884c\u7f16\u7a0b\u3002\u6253\u5305\u90e8\u7f72\u5230\u73b0\u573a\u7684\u65f6\u5019\uff0c\u4e1a\u52a1\u4ee3\u7801\u5b8c\u5168\u66b4\u9732\uff0c\u5b89\u88c5\u5305\u6d41\u8f6c\u8fc7\u7a0b\u4e2d\uff0c\u4e5f\u5bb9\u6613\u6cc4\u9732\uff0c\u66b4\u9732 L&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"http:\/\/175.178.247.106\/index.php\/2024\/03\/31\/lua%e8%84%9a%e6%9c%ac%e5%8a%a0%e5%af%86%ef%bc%88%e4%b8%80%ef%bc%89\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-15"],"_links":{"self":[{"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":3,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"predecessor-version":[{"id":51,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/posts\/47\/revisions\/51"}],"wp:attachment":[{"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/175.178.247.106\/index.php\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}