diff options
author | 2023-04-14 11:59:32 +0000 | |
---|---|---|
committer | 2023-04-14 11:59:32 +0000 | |
commit | d68841d9f75636575cd778838a8ceea5fd5aada3 (patch) | |
tree | 778c84203ed9bfa4dc1c8234e4e2cf60da6ebd8c /server/resty/openssl/include/bn.lua | |
parent | 42af09588f1f839b9ab36356f02f34c89559bcfa (diff) |
Upload ui
Issue-ID: PORTAL-1084
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Change-Id: Id0c94859a775094e67b0bb9c91ca5e776a08c068
Diffstat (limited to 'server/resty/openssl/include/bn.lua')
-rw-r--r-- | server/resty/openssl/include/bn.lua | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/server/resty/openssl/include/bn.lua b/server/resty/openssl/include/bn.lua new file mode 100644 index 0000000..93d2dda --- /dev/null +++ b/server/resty/openssl/include/bn.lua @@ -0,0 +1,77 @@ +local ffi = require "ffi" + +require "resty.openssl.include.ossl_typ" +local OPENSSL_3X = require("resty.openssl.version").OPENSSL_3X + +local BN_ULONG +if ffi.abi('64bit') then + BN_ULONG = 'unsigned long long' +else -- 32bit + BN_ULONG = 'unsigned int' +end + +ffi.cdef( +[[ + BIGNUM *BN_new(void); + void BN_free(BIGNUM *a); + + BN_CTX *BN_CTX_new(void); + void BN_CTX_init(BN_CTX *c); + void BN_CTX_free(BN_CTX *c); + + BIGNUM *BN_dup(const BIGNUM *a); + int BN_add_word(BIGNUM *a, ]] .. BN_ULONG ..[[ w); + int BN_set_word(BIGNUM *a, ]] .. BN_ULONG ..[[ w); + ]] .. BN_ULONG ..[[ BN_get_word(BIGNUM *a); + int BN_num_bits(const BIGNUM *a); + BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret); + int BN_hex2bn(BIGNUM **a, const char *str); + int BN_dec2bn(BIGNUM **a, const char *str); + int BN_bn2bin(const BIGNUM *a, unsigned char *to); + char *BN_bn2hex(const BIGNUM *a); + char *BN_bn2dec(const BIGNUM *a); + + void BN_set_negative(BIGNUM *a, int n); + int BN_is_negative(const BIGNUM *a); + + int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); + int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); + int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); + int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx); + int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d, + BN_CTX *ctx); + int BN_mod_add(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, + BN_CTX *ctx); + int BN_mod_sub(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, + BN_CTX *ctx); + int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, + BN_CTX *ctx); + int BN_mod_sqr(BIGNUM *ret, BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); + int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx); + int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx); + int BN_gcd(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); + + int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); + int BN_rshift(BIGNUM *r, BIGNUM *a, int n); + + int BN_cmp(BIGNUM *a, BIGNUM *b); + int BN_ucmp(BIGNUM *a, BIGNUM *b); + + // openssl >= 1.1 only + int BN_is_zero(BIGNUM *a); + int BN_is_one(BIGNUM *a); + int BN_is_word(BIGNUM *a, ]] .. BN_ULONG ..[[ w); + int BN_is_odd(BIGNUM *a); + + int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb); + int BN_generate_prime_ex(BIGNUM *ret,int bits,int safe, const BIGNUM *add, + const BIGNUM *rem, BN_GENCB *cb); +]] +) + +if OPENSSL_3X then + ffi.cdef [[ + int BN_check_prime(const BIGNUM *p, BN_CTX *ctx, BN_GENCB *cb); + ]] +end
\ No newline at end of file |