summaryrefslogtreecommitdiffstats
path: root/server/resty/openssl/include/rand.lua
blob: 90f44c1ca330596fec818bd07c425218460c11bd (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
local ffi = require "ffi"

require "resty.openssl.include.ossl_typ"
local OPENSSL_3X = require("resty.openssl.version").OPENSSL_3X
local BORINGSSL = require("resty.openssl.version").BORINGSSL

if BORINGSSL then
  ffi.cdef [[
    int RAND_bytes(uint8_t *buf, size_t num);
    int RAND_priv_bytes(uint8_t *buf, size_t num);
  ]]
elseif OPENSSL_3X then
  ffi.cdef [[
    int RAND_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num,
                      unsigned int strength);
    int RAND_priv_bytes_ex(OSSL_LIB_CTX *ctx, unsigned char *buf, size_t num,
                      unsigned int strength);
  ]]
else
  ffi.cdef [[
    int RAND_bytes(unsigned char *buf, int num);
    int RAND_priv_bytes(unsigned char *buf, int num);
  ]]
end