File tree Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Expand file tree Collapse file tree 1 file changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -577,22 +577,25 @@ BIGNUM_2c(gcd)
577577 */
578578BIGNUM_2c (mod_sqr )
579579
580+ #define BIGNUM_2cr (func ) \
581+ static VALUE \
582+ ossl_bn_ ##func (VALUE self, VALUE other) \
583+ { \
584+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
585+ VALUE obj; \
586+ GetBN(self, bn1); \
587+ obj = NewBN(rb_obj_class(self)); \
588+ if (!(result = BN_##func(NULL, bn1, bn2, ossl_bn_ctx))) \
589+ ossl_raise(eBNError, NULL); \
590+ SetBN(obj, result); \
591+ return obj; \
592+ }
593+
580594/*
581595 * call-seq:
582596 * bn.mod_inverse(bn2) => aBN
583597 */
584- static VALUE
585- ossl_bn_mod_inverse (VALUE self , VALUE other )
586- {
587- BIGNUM * bn1 , * bn2 = GetBNPtr (other ), * result ;
588- VALUE obj ;
589- GetBN (self , bn1 );
590- obj = NewBN (rb_obj_class (self ));
591- if (!(result = BN_mod_inverse (NULL , bn1 , bn2 , ossl_bn_ctx )))
592- ossl_raise (eBNError , "BN_mod_inverse" );
593- SetBN (obj , result );
594- return obj ;
595- }
598+ BIGNUM_2cr (mod_inverse )
596599
597600/*
598601 * call-seq:
You can’t perform that action at this time.
0 commit comments