Skip to content

Commit

Permalink
refactor(*): remove unused cdefs
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed Nov 1, 2023
1 parent d3351ac commit 77e944a
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 42 deletions.
1 change: 1 addition & 0 deletions lib/resty/openssl/digest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function _M.new(typ, properties)
else
if OPENSSL_3X then
algo = C.EVP_MD_fetch(ctx_lib.get_libctx(), typ or 'sha1', properties)
ffi_gc(algo, C.EVP_MD_free)
else
algo = C.EVP_get_digestbyname(typ or 'sha1')
end
Expand Down
2 changes: 1 addition & 1 deletion lib/resty/openssl/include/bio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ ffi.cdef [[
BIO *BIO_new(const BIO_METHOD *type);
int BIO_free(BIO *a);
const BIO_METHOD *BIO_s_mem(void);
int BIO_read(BIO *b, void *data, int dlen);
// int BIO_read(BIO *b, void *data, int dlen);
]]
2 changes: 1 addition & 1 deletion lib/resty/openssl/include/bn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ffi.cdef(
void BN_free(BIGNUM *a);
BN_CTX *BN_CTX_new(void);
void BN_CTX_init(BN_CTX *c);
// void BN_CTX_init(BN_CTX *c);
void BN_CTX_free(BN_CTX *c);
BIGNUM *BN_dup(const BIGNUM *a);
Expand Down
3 changes: 1 addition & 2 deletions lib/resty/openssl/include/ec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ ffi.cdef [[
void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag);
void EC_GROUP_set_point_conversion_form(EC_GROUP *group,
point_conversion_form_t form);
void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
// void EC_GROUP_set_curve_name(EC_GROUP *group, int nid);
int EC_GROUP_get_curve_name(const EC_GROUP *group);


void EC_GROUP_free(EC_GROUP *group);

BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *,
Expand Down
14 changes: 7 additions & 7 deletions lib/resty/openssl/include/evp/cipher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ local OPENSSL_3X = require("resty.openssl.version").OPENSSL_3X

ffi.cdef [[
EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c);
// int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c);
void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *c);

int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);

const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);
const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
int *outl, const unsigned char *in, int inl);
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
int *outl, const unsigned char *in, int inl);
// int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
// int *outl, const unsigned char *in, int inl);
// int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
// int *outl, const unsigned char *in, int inl);


int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,
Expand Down Expand Up @@ -62,8 +62,8 @@ if OPENSSL_3X then
void EVP_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx,
fake_openssl_cipher_provided_list_fn*,
void *arg);
int EVP_CIPHER_up_ref(EVP_CIPHER *cipher);
void EVP_CIPHER_free(EVP_CIPHER *cipher);
// int EVP_CIPHER_up_ref(EVP_CIPHER *cipher);
// void EVP_CIPHER_free(EVP_CIPHER *cipher);

const char *EVP_CIPHER_get0_name(const EVP_CIPHER *cipher);

Expand Down
2 changes: 1 addition & 1 deletion lib/resty/openssl/include/evp/kdf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if OPENSSL_3X then
void EVP_KDF_do_all_provided(OSSL_LIB_CTX *libctx,
fake_openssl_kdf_provided_list_fn*,
void *arg);
int EVP_KDF_up_ref(EVP_KDF *kdf);
// int EVP_KDF_up_ref(EVP_KDF *kdf);
void EVP_KDF_free(EVP_KDF *kdf);

const char *EVP_KDF_get0_name(const EVP_KDF *kdf);
Expand Down
2 changes: 1 addition & 1 deletion lib/resty/openssl/include/evp/mac.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ffi.cdef [[
void EVP_MAC_do_all_provided(OSSL_LIB_CTX *libctx,
fake_openssl_mac_provided_list_fn*,
void *arg);
int EVP_MAC_up_ref(EVP_MAC *mac);
// int EVP_MAC_up_ref(EVP_MAC *mac);
void EVP_MAC_free(EVP_MAC *mac);

const char *EVP_MAC_get0_name(const EVP_MAC *mac);
Expand Down
2 changes: 1 addition & 1 deletion lib/resty/openssl/include/evp/md.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if OPENSSL_3X then
void EVP_MD_do_all_provided(OSSL_LIB_CTX *libctx,
fake_openssl_md_provided_list_fn*,
void *arg);
int EVP_MD_up_ref(EVP_MD *md);
// int EVP_MD_up_ref(EVP_MD *md);
void EVP_MD_free(EVP_MD *md);

const char *EVP_MD_get0_name(const EVP_MD *md);
Expand Down
6 changes: 3 additions & 3 deletions lib/resty/openssl/include/evp/pkey.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ ffi.cdef [[
int cmd, int p1, void *p2);
// TODO replace EVP_PKEY_CTX_ctrl with EVP_PKEY_CTX_ctrl_str to reduce
// some hardcoded macros
int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
const char *value);
// int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
// const char *value);
int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);
int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
unsigned char *out, size_t *outlen,
Expand Down Expand Up @@ -106,7 +106,7 @@ if OPENSSL_3X then
int EVP_PKEY_CTX_set_dh_paramgen_prime_len(EVP_PKEY_CTX *ctx, int pbits);

const OSSL_PROVIDER *EVP_PKEY_get0_provider(const EVP_PKEY *key);
const OSSL_PROVIDER *EVP_PKEY_CTX_get0_provider(const EVP_PKEY_CTX *ctx);
// const OSSL_PROVIDER *EVP_PKEY_CTX_get0_provider(const EVP_PKEY_CTX *ctx);

const OSSL_PARAM *EVP_PKEY_settable_params(const EVP_PKEY *pkey);
int EVP_PKEY_set_params(EVP_PKEY *pkey, OSSL_PARAM params[]);
Expand Down
2 changes: 1 addition & 1 deletion lib/resty/openssl/include/param.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ffi.cdef [[
OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf);
OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf,
size_t bsize);
OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf);
// OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf);
OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf,
size_t bsize);
OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf,
Expand Down
4 changes: 2 additions & 2 deletions lib/resty/openssl/include/ssl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local OPENSSL_3X = require("resty.openssl.version").OPENSSL_3X
ffi.cdef [[
// SSL_METHOD
typedef struct ssl_method_st SSL_METHOD;
const SSL_METHOD *TLS_method(void);
// const SSL_METHOD *TLS_method(void);
const SSL_METHOD *TLS_server_method(void);

// SSL_CIPHER
Expand Down Expand Up @@ -52,7 +52,7 @@ ffi.cdef [[
long SSL_get_options(SSL *ssl);

/*STACK_OF(SSL_CIPHER)*/ OPENSSL_STACK *SSL_get_ciphers(const SSL *ssl);
/*STACK_OF(SSL_CIPHER)*/ OPENSSL_STACK *SSL_CTX_get_ciphers(const SSL_CTX *ctx);
// /*STACK_OF(SSL_CIPHER)*/ OPENSSL_STACK *SSL_CTX_get_ciphers(const SSL_CTX *ctx);
OPENSSL_STACK *SSL_get_peer_cert_chain(const SSL *ssl);

typedef int (*verify_callback)(int preverify_ok, X509_STORE_CTX *x509_ctx);
Expand Down
2 changes: 1 addition & 1 deletion lib/resty/openssl/include/stack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ffi.cdef [[
void *OPENSSL_sk_value(const OPENSSL_STACK *, int);
OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st);
void OPENSSL_sk_free(OPENSSL_STACK *);
void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc);
// void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc);

typedef void (*OPENSSL_sk_freefunc)(void *);
typedef void *(*OPENSSL_sk_copyfunc)(const void *);
Expand Down
4 changes: 2 additions & 2 deletions lib/resty/openssl/include/x509/crl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ffi.cdef [[
int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc);
int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos);
void *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx);
// void *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx);

int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md);
int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r);
Expand All @@ -31,7 +31,7 @@ ffi.cdef [[

int X509_CRL_get0_by_serial(X509_CRL *crl,
X509_REVOKED **ret, ASN1_INTEGER *serial);
int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);
// int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x);

//STACK_OF(X509_REVOKED)
OPENSSL_STACK *X509_CRL_get_REVOKED(X509_CRL *crl);
Expand Down
11 changes: 5 additions & 6 deletions lib/resty/openssl/include/x509/csr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@ ffi.cdef [[

int X509_REQ_set_version(X509_REQ *x, long version);

int X509_REQ_get_attr_count(const X509_REQ *req);

int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc);
X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc);
int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos);

int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);
void X509_ATTRIBUTE_free(X509_ATTRIBUTE *a);
int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);
// int X509_REQ_get_attr_count(const X509_REQ *req);
// int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos);
X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc);

int *X509_REQ_get_extension_nids(void);
// int *X509_REQ_get_extension_nids(void);

int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md);
int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r);
Expand All @@ -54,7 +53,7 @@ ffi.cdef [[

if OPENSSL_3X then
ffi.cdef [[
int X509_REQ_verify_ex(X509_REQ *a, EVP_PKEY *pkey, OSSL_LIB_CTX *libctx,
const char *propq);
// int X509_REQ_verify_ex(X509_REQ *a, EVP_PKEY *pkey, OSSL_LIB_CTX *libctx,
// const char *propq);
]]
end
2 changes: 1 addition & 1 deletion lib/resty/openssl/include/x509/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ffi.cdef [[
int X509_get_signature_nid(const X509 *x);

unsigned char *X509_alias_get0(X509 *x, int *len);
unsigned char *X509_keyid_get0(X509 *x, int *len);
// unsigned char *X509_keyid_get0(X509 *x, int *len);
int X509_check_private_key(X509 *x, EVP_PKEY *k);

int X509_up_ref(X509 *a);
Expand Down
20 changes: 10 additions & 10 deletions lib/resty/openssl/include/x509_vfy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ local OPENSSL_3X = require("resty.openssl.version").OPENSSL_3X
ffi.cdef [[
X509_STORE *X509_STORE_new(void);
void X509_STORE_free(X509_STORE *v);
/* int X509_STORE_lock(X509_STORE *ctx);
int X509_STORE_unlock(X509_STORE *ctx);
int X509_STORE_up_ref(X509_STORE *v);
// int X509_STORE_lock(X509_STORE *ctx);
// int X509_STORE_unlock(X509_STORE *ctx);
// int X509_STORE_up_ref(X509_STORE *v);
// STACK_OF(X509_OBJECT)
OPENSSL_STACK *X509_STORE_get0_objects(X509_STORE *v);*/
// OPENSSL_STACK *X509_STORE_get0_objects(X509_STORE *v);

int X509_STORE_add_cert(X509_STORE *ctx, X509 *x);
int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x);
Expand All @@ -35,10 +35,10 @@ ffi.cdef [[

void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags);

int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);
// int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose);

// STACK_OF(X509_CRL)
void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, OPENSSL_STACK *sk);
// void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, OPENSSL_STACK *sk);

int X509_PURPOSE_get_by_sname(char *sname);
X509_PURPOSE *X509_PURPOSE_get0(int idx);
Expand Down Expand Up @@ -89,10 +89,10 @@ if OPENSSL_3X then

int X509_STORE_set_default_paths_ex(X509_STORE *ctx, OSSL_LIB_CTX *libctx,
const char *propq);
/* int X509_STORE_load_file_ex(X509_STORE *ctx, const char *file,
OSSL_LIB_CTX *libctx, const char *propq);
int X509_STORE_load_store_ex(X509_STORE *ctx, const char *uri,
OSSL_LIB_CTX *libctx, const char *propq); */
// int X509_STORE_load_file_ex(X509_STORE *ctx, const char *file,
// OSSL_LIB_CTX *libctx, const char *propq);
// int X509_STORE_load_store_ex(X509_STORE *ctx, const char *uri,
// OSSL_LIB_CTX *libctx, const char *propq);
int X509_STORE_load_locations_ex(X509_STORE *ctx, const char *file,
const char *dir, OSSL_LIB_CTX *libctx,
const char *propq);
Expand Down
4 changes: 2 additions & 2 deletions lib/resty/openssl/include/x509v3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ ffi.cdef [[

X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid,
const char *value);
X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name,
const char *value);
// X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name,
// const char *value);
int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag,
int indent);

Expand Down
1 change: 1 addition & 0 deletions lib/resty/openssl/kdf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ function _M.new(typ, properties)
if algo == nil then
return nil, format_error(string.format("mac.new: invalid mac type \"%s\"", typ))
end
ffi_gc(algo, C.EVP_KDF_free)

local ctx = C.EVP_KDF_CTX_new(algo)
if ctx == nil then
Expand Down
1 change: 1 addition & 0 deletions lib/resty/openssl/mac.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function _M.new(key, typ, cipher, digest, properties)
if algo == nil then
return nil, format_error(string.format("mac.new: invalid mac type \"%s\"", typ))
end
ffi_gc(algo, C.EVP_MAC_free)

local ctx = C.EVP_MAC_CTX_new(algo)
if ctx == nil then
Expand Down

0 comments on commit 77e944a

Please sign in to comment.