amyrprv opened a new issue, #10163:
URL: https://github.com/apache/apisix/issues/10163

   ### Description
   
   I created a custom plugin and I want to encrypt one property of the request 
body. I figured out that it requires `lua-openssl ` package from Luarocks which 
is not present in the current rockspec dependency tree. I there any way to 
perform AES-128-GCM encryption in Lua without any dependency? I am running 
Apisix from the official docker image. 
   
   ```
   local ffi         = require("ffi")
   local openssl     = require("resty.openssl")
   
   local function encrypt(key, src)
       
       openssl.rand_load()
       local iv = openssl.random(12)
   
       local cipher = openssl.get_cipher("AES-128-GCM")
       local ctx = openssl.evp_encrypt_init(key, iv, cipher, true)
   
       local cipherText, tag = ctx:final(src)
   
       if #cipherText ~= #src + 16 then
           core.log.error("Invalid cipher text length")
       end
   
       local message = ffi.new("char[?]", 12 + #src + 16)
       ffi.copy(message, iv, 12)
       ffi.copy(message + 12, cipherText, #cipherText)
   
       return ffi.string(message, 12 + #src + 16)
   end
   ```
   
   ### Environment
   
   - APISIX version (run `apisix version`): 3.5
   - Operating system (run `uname -a`): Linux c518c369b311 
5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 
x86_64 x86_64 GNU/Linux
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`): nginx 
version: openresty/1.21.4.2
   - etcd version, if relevant (run `curl 
http://127.0.0.1:9090/v1/server_info`):
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `luarocks --version`):
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to