@@ -397,7 +397,7 @@ ossl_bn_is_negative(VALUE self)
397
397
if (!(result = BN_new())) { \
398
398
ossl_raise(eBNError, NULL); \
399
399
} \
400
- if (! BN_##func(result, bn, ossl_bn_ctx)) { \
400
+ if (BN_##func(result, bn, ossl_bn_ctx) <= 0 ) { \
401
401
BN_free(result); \
402
402
ossl_raise(eBNError, NULL); \
403
403
} \
@@ -423,7 +423,7 @@ BIGNUM_1c(sqr)
423
423
if (!(result = BN_new())) { \
424
424
ossl_raise(eBNError, NULL); \
425
425
} \
426
- if (! BN_##func(result, bn1, bn2)) { \
426
+ if (BN_##func(result, bn1, bn2) <= 0 ) { \
427
427
BN_free(result); \
428
428
ossl_raise(eBNError, NULL); \
429
429
} \
@@ -456,7 +456,7 @@ BIGNUM_2(sub)
456
456
if (!(result = BN_new())) { \
457
457
ossl_raise(eBNError, NULL); \
458
458
} \
459
- if (! BN_##func(result, bn1, bn2, ossl_bn_ctx)) { \
459
+ if (BN_##func(result, bn1, bn2, ossl_bn_ctx) <= 0 ) { \
460
460
BN_free(result); \
461
461
ossl_raise(eBNError, NULL); \
462
462
} \
@@ -500,11 +500,21 @@ BIGNUM_2c(gcd)
500
500
BIGNUM_2c (mod_sqr )
501
501
502
502
/*
503
- * Document-method: OpenSSL::BN#mod_inverse
504
503
* call-seq:
505
- * bn.mod_inverse(bn2) => aBN
504
+ * bn.mod_inverse(bn2) => aBN
506
505
*/
507
- BIGNUM_2c (mod_inverse )
506
+ static VALUE
507
+ ossl_bn_mod_inverse (VALUE self , VALUE other )
508
+ {
509
+ BIGNUM * bn1 , * bn2 = GetBNPtr (other ), * result ;
510
+ VALUE obj ;
511
+ GetBN (self , bn1 );
512
+ obj = NewBN (rb_obj_class (self ));
513
+ if (!(result = BN_mod_inverse (NULL , bn1 , bn2 , ossl_bn_ctx )))
514
+ ossl_raise (eBNError , "BN_mod_inverse" );
515
+ SetBN (obj , result );
516
+ return obj ;
517
+ }
508
518
509
519
/*
510
520
* call-seq:
@@ -553,7 +563,7 @@ ossl_bn_div(VALUE self, VALUE other)
553
563
if (!(result = BN_new())) { \
554
564
ossl_raise(eBNError, NULL); \
555
565
} \
556
- if (! BN_##func(result, bn1, bn2, bn3, ossl_bn_ctx)) { \
566
+ if (BN_##func(result, bn1, bn2, bn3, ossl_bn_ctx) <= 0 ) { \
557
567
BN_free(result); \
558
568
ossl_raise(eBNError, NULL); \
559
569
} \
@@ -595,7 +605,7 @@ BIGNUM_3c(mod_exp)
595
605
{ \
596
606
BIGNUM *bn; \
597
607
GetBN(self, bn); \
598
- if (! BN_##func(bn, NUM2INT(bit))) { \
608
+ if (BN_##func(bn, NUM2INT(bit)) <= 0 ) { \
599
609
ossl_raise(eBNError, NULL); \
600
610
} \
601
611
return self; \
@@ -655,7 +665,7 @@ ossl_bn_is_bit_set(VALUE self, VALUE bit)
655
665
if (!(result = BN_new())) { \
656
666
ossl_raise(eBNError, NULL); \
657
667
} \
658
- if (! BN_##func(result, bn, b)) { \
668
+ if (BN_##func(result, bn, b) <= 0 ) { \
659
669
BN_free(result); \
660
670
ossl_raise(eBNError, NULL); \
661
671
} \
@@ -685,7 +695,7 @@ BIGNUM_SHIFT(rshift)
685
695
int b; \
686
696
b = NUM2INT(bits); \
687
697
GetBN(self, bn); \
688
- if (! BN_##func(bn, bn, b)) \
698
+ if (BN_##func(bn, bn, b) <= 0 ) \
689
699
ossl_raise(eBNError, NULL); \
690
700
return self; \
691
701
}
@@ -724,7 +734,7 @@ BIGNUM_SELF_SHIFT(rshift)
724
734
if (!(result = BN_new ())) { \
725
735
ossl_raise (eBNError , NULL ); \
726
736
} \
727
- if (! BN_ ##func (result, b, top, bottom)) { \
737
+ if (BN_ ##func (result, b, top, bottom) <= 0 ) { \
728
738
BN_free(result); \
729
739
ossl_raise(eBNError, NULL); \
730
740
} \
@@ -753,7 +763,7 @@ BIGNUM_RAND(pseudo_rand)
753
763
if (!(result = BN_new())) { \
754
764
ossl_raise(eBNError, NULL); \
755
765
} \
756
- if (! BN_##func##_range(result, bn)) { \
766
+ if (BN_##func##_range(result, bn) <= 0 ) { \
757
767
BN_free(result); \
758
768
ossl_raise(eBNError, NULL); \
759
769
} \
0 commit comments