aboutsummaryrefslogtreecommitdiffstats
path: root/server/resty/openssl/include/crypto.lua
blob: 6ca1f0801a57c1e51538bc2976fd6a977b97462c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local ffi = require "ffi"
local C = ffi.C

local OPENSSL_10 = require("resty.openssl.version").OPENSSL_10
local OPENSSL_11_OR_LATER = require("resty.openssl.version").OPENSSL_11_OR_LATER

local OPENSSL_free
if OPENSSL_10 then
  ffi.cdef [[
    void CRYPTO_free(void *ptr);
  ]]
  OPENSSL_free = C.CRYPTO_free
elseif OPENSSL_11_OR_LATER then
  ffi.cdef [[
    void CRYPTO_free(void *ptr, const char *file, int line);
  ]]
  OPENSSL_free = function(ptr)
    -- file and line is for debuggin only, since we can't know the c file info
    -- the macro is expanded, just ignore this
    C.CRYPTO_free(ptr, "", 0)
  end
end

ffi.cdef [[
  int FIPS_mode(void);
  int FIPS_mode_set(int ONOFF);
]]

return {
  OPENSSL_free = OPENSSL_free,
}