@@ -792,64 +792,64 @@ BIGNUM_SELF_SHIFT(lshift)
792
792
*/
793
793
BIGNUM_SELF_SHIFT (rshift )
794
794
795
- #define BIGNUM_RAND (func ) \
796
- static VALUE \
797
- ossl_bn_s_ ##func (int argc, VALUE *argv, VALUE klass) \
798
- { \
799
- BIGNUM *result; \
800
- int bottom = 0, top = 0, b; \
801
- VALUE bits, fill, odd, obj; \
802
- \
803
- switch (rb_scan_args(argc, argv, "12", &bits, &fill, &odd)) { \
804
- case 3: \
805
- bottom = (odd == Qtrue) ? 1 : 0; \
806
- /* FALLTHROUGH */ \
807
- case 2 : \
808
- top = NUM2INT (fill ); \
809
- } \
810
- b = NUM2INT (bits ); \
811
- obj = NewBN (klass ); \
812
- if (!(result = BN_new ())) { \
813
- ossl_raise (eBNError , NULL ); \
814
- } \
815
- if (BN_ ##func (result, b, top, bottom) <= 0) { \
816
- BN_free(result); \
817
- ossl_raise(eBNError, NULL); \
818
- } \
819
- SetBN(obj, result); \
820
- return obj; \
821
- }
822
-
823
795
/*
824
- * Document-method: OpenSSL::BN.rand
825
- * BN.rand(bits [, fill [, odd]]) -> aBN
796
+ * call-seq:
797
+ * BN.rand(bits [, fill [, odd]]) -> aBN
798
+ *
799
+ * Generates a cryptographically strong pseudo-random number of +bits+.
800
+ *
801
+ * See also the man page BN_rand(3).
826
802
*/
827
- BIGNUM_RAND (rand )
828
-
829
- #define BIGNUM_RAND_RANGE (func ) \
830
- static VALUE \
831
- ossl_bn_s_##func##_range(VALUE klass, VALUE range) \
832
- { \
833
- BIGNUM *bn = GetBNPtr(range), *result; \
834
- VALUE obj = NewBN(klass); \
835
- if (!(result = BN_new())) { \
836
- ossl_raise(eBNError, NULL); \
837
- } \
838
- if (BN_##func##_range(result, bn) <= 0) { \
839
- BN_free(result); \
840
- ossl_raise(eBNError, NULL); \
841
- } \
842
- SetBN(obj, result); \
843
- return obj; \
803
+ static VALUE
804
+ ossl_bn_s_rand (int argc , VALUE * argv , VALUE klass )
805
+ {
806
+ BIGNUM * result ;
807
+ int bottom = 0 , top = 0 , b ;
808
+ VALUE bits , fill , odd , obj ;
809
+
810
+ switch (rb_scan_args (argc , argv , "12" , & bits , & fill , & odd )) {
811
+ case 3 :
812
+ bottom = (odd == Qtrue ) ? 1 : 0 ;
813
+ /* FALLTHROUGH */
814
+ case 2 :
815
+ top = NUM2INT (fill );
816
+ }
817
+ b = NUM2INT (bits );
818
+ obj = NewBN (klass );
819
+ if (!(result = BN_new ())) {
820
+ ossl_raise (eBNError , "BN_new" );
821
+ }
822
+ if (BN_rand (result , b , top , bottom ) <= 0 ) {
823
+ BN_free (result );
824
+ ossl_raise (eBNError , "BN_rand" );
844
825
}
826
+ SetBN (obj , result );
827
+ return obj ;
828
+ }
845
829
846
830
/*
847
- * Document-method: OpenSSL::BN.rand_range
848
831
* call-seq:
849
- * BN.rand_range(range) -> aBN
832
+ * BN.rand_range(range) -> aBN
850
833
*
834
+ * Generates a cryptographically strong pseudo-random number in the range
835
+ * 0...+range+.
836
+ *
837
+ * See also the man page BN_rand_range(3).
851
838
*/
852
- BIGNUM_RAND_RANGE (rand )
839
+ static VALUE
840
+ ossl_bn_s_rand_range (VALUE klass , VALUE range )
841
+ {
842
+ BIGNUM * bn = GetBNPtr (range ), * result ;
843
+ VALUE obj = NewBN (klass );
844
+ if (!(result = BN_new ()))
845
+ ossl_raise (eBNError , "BN_new" );
846
+ if (BN_rand_range (result , bn ) <= 0 ) {
847
+ BN_free (result );
848
+ ossl_raise (eBNError , "BN_rand_range" );
849
+ }
850
+ SetBN (obj , result );
851
+ return obj ;
852
+ }
853
853
854
854
/*
855
855
* call-seq:
0 commit comments