aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorBen Toews <benjamin.toews@gmail.com>2022-10-17 07:30:30 -0600
committerKazuki Yamaguchi <k@rhe.jp>2022-10-17 23:38:34 +0900
commite037731c9f840b0c74eb68a808a109fdef3c6d5e (patch)
treebd1e7b5a00130db0993167e81df9f052896e5626 /ext
parentf6bf5e2c5f07a0e99a6f3dbc29035f911a4e477f (diff)
downloadruby-e037731c9f840b0c74eb68a808a109fdef3c6d5e.tar.gz
[ruby/openssl] define BIGNUM_2cr macro for BN function that takes context and
returns a BN https://github.com/ruby/openssl/commit/4d0971c51c
Diffstat (limited to 'ext')
-rw-r--r--ext/openssl/ossl_bn.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
index 56fa0ec302..7eb1bc79a5 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -577,22 +577,25 @@ BIGNUM_2c(gcd)
*/
BIGNUM_2c(mod_sqr)
+#define BIGNUM_2cr(func) \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
+ VALUE obj; \
+ GetBN(self, bn1); \
+ obj = NewBN(rb_obj_class(self)); \
+ if (!(result = BN_##func(NULL, bn1, bn2, ossl_bn_ctx))) \
+ ossl_raise(eBNError, NULL); \
+ SetBN(obj, result); \
+ return obj; \
+ }
+
/*
* call-seq:
* bn.mod_inverse(bn2) => aBN
*/
-static VALUE
-ossl_bn_mod_inverse(VALUE self, VALUE other)
-{
- BIGNUM *bn1, *bn2 = GetBNPtr(other), *result;
- VALUE obj;
- GetBN(self, bn1);
- obj = NewBN(rb_obj_class(self));
- if (!(result = BN_mod_inverse(NULL, bn1, bn2, ossl_bn_ctx)))
- ossl_raise(eBNError, "BN_mod_inverse");
- SetBN(obj, result);
- return obj;
-}
+BIGNUM_2cr(mod_inverse)
/*
* call-seq: