Open prakharmishra opened 6 years ago
Same issue. I added logging here:
if C.EVP_DecryptFinal_ex(ctx, buf + out_len[0], tmp_len) == 0 then
ngx.log(ngx.STDERR, "aes3: " .. inspect(ffi_str(buf, 32)))
return nil
end
And looks like buf
contains decrypted text, but somewhy it returns 0.
OpenSSL says, that:
EVP_DecryptFinal() will return an error code if padding is enabled and the final block is not correctly formatted.
My issue was resolved with disabling padding:
local C = ffi.C
ffi.cdef[[
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad);
]]
-- ...
C.EVP_CIPHER_CTX_set_padding(encryptor._decrypt_ctx, 0)
There should be an API for #67
the same issue
Hello, I am not able to decrypt back what was encrypted using Crypto-JS in browser Javascript / NodeJS:
I can decrypt it in Java using:
Cipher.getInstance("AES/CBC/PKCS5Padding")
But, I getnil
when I try to do it with resty.aes. Here is the code:Could someone please help me with server side decryption?