File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -591,6 +591,13 @@ BIGNUM_2c(mod_sqr)
591
591
return obj; \
592
592
}
593
593
594
+ /*
595
+ * Document-method: OpenSSL::BN#mod_sqrt
596
+ * call-seq:
597
+ * bn.mod_sqrt(bn2) => aBN
598
+ */
599
+ BIGNUM_2cr (mod_sqrt )
600
+
594
601
/*
595
602
* call-seq:
596
603
* bn.mod_inverse(bn2) => aBN
@@ -1237,6 +1244,7 @@ Init_ossl_bn(void)
1237
1244
rb_define_method (cBN , "mod_sub" , ossl_bn_mod_sub , 2 );
1238
1245
rb_define_method (cBN , "mod_mul" , ossl_bn_mod_mul , 2 );
1239
1246
rb_define_method (cBN , "mod_sqr" , ossl_bn_mod_sqr , 1 );
1247
+ rb_define_method (cBN , "mod_sqrt" , ossl_bn_mod_sqrt , 1 );
1240
1248
rb_define_method (cBN , "**" , ossl_bn_exp , 1 );
1241
1249
rb_define_method (cBN , "mod_exp" , ossl_bn_mod_exp , 2 );
1242
1250
rb_define_method (cBN , "gcd" , ossl_bn_gcd , 1 );
Original file line number Diff line number Diff line change @@ -174,6 +174,12 @@ def test_mod_sqr
174
174
assert_equal ( 0 , 59 . to_bn . mod_sqr ( 59 ) )
175
175
end
176
176
177
+ def test_mod_sqrt
178
+ assert_equal ( 3 , 4 . to_bn . mod_sqrt ( 5 ) )
179
+ assert_equal ( 0 , 5 . to_bn . mod_sqrt ( 5 ) )
180
+ assert_raise ( OpenSSL ::BNError ) { 3 . to_bn . mod_sqrt ( 5 ) }
181
+ end
182
+
177
183
def test_mod_inverse
178
184
assert_equal ( 2 , 3 . to_bn . mod_inverse ( 5 ) )
179
185
assert_raise ( OpenSSL ::BNError ) { 3 . to_bn . mod_inverse ( 6 ) }
You can’t perform that action at this time.
0 commit comments