|
10 | 10 | /* modified by Michal Rokos <[email protected]> */
|
11 | 11 | #include "ossl.h"
|
12 | 12 |
|
13 |
| -#ifdef HAVE_RB_EXT_RACTOR_SAFE |
14 |
| -#include <ruby/ractor.h> |
15 |
| -#endif |
16 |
| - |
17 | 13 | #define NewBN(klass) \
|
18 | 14 | TypedData_Wrap_Struct((klass), &ossl_bn_type, 0)
|
19 | 15 | #define SetBN(obj, bn) do { \
|
@@ -41,7 +37,7 @@ static const rb_data_type_t ossl_bn_type = {
|
41 | 37 | {
|
42 | 38 | 0, ossl_bn_free,
|
43 | 39 | },
|
44 |
| - 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED, |
| 40 | + 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE, |
45 | 41 | };
|
46 | 42 |
|
47 | 43 | /*
|
@@ -693,6 +689,7 @@ BIGNUM_3c(mod_exp)
|
693 | 689 | ossl_bn_##func(VALUE self, VALUE bit) \
|
694 | 690 | { \
|
695 | 691 | BIGNUM *bn; \
|
| 692 | + rb_check_frozen(self); \ |
696 | 693 | GetBN(self, bn); \
|
697 | 694 | if (BN_##func(bn, NUM2INT(bit)) <= 0) { \
|
698 | 695 | ossl_raise(eBNError, NULL); \
|
@@ -748,6 +745,7 @@ ossl_bn_is_bit_set(VALUE self, VALUE bit)
|
748 | 745 | BIGNUM *bn, *result; \
|
749 | 746 | int b; \
|
750 | 747 | VALUE obj; \
|
| 748 | + rb_check_frozen(self); \ |
751 | 749 | b = NUM2INT(bits); \
|
752 | 750 | GetBN(self, bn); \
|
753 | 751 | obj = NewBN(rb_obj_class(self)); \
|
@@ -782,6 +780,7 @@ BIGNUM_SHIFT(rshift)
|
782 | 780 | { \
|
783 | 781 | BIGNUM *bn; \
|
784 | 782 | int b; \
|
| 783 | + rb_check_frozen(self); \ |
785 | 784 | b = NUM2INT(bits); \
|
786 | 785 | GetBN(self, bn); \
|
787 | 786 | if (BN_##func(bn, bn, b) <= 0) \
|
@@ -1191,6 +1190,7 @@ ossl_bn_set_flags(VALUE self, VALUE arg)
|
1191 | 1190 | BIGNUM *bn;
|
1192 | 1191 | GetBN(self, bn);
|
1193 | 1192 |
|
| 1193 | + rb_check_frozen(self); |
1194 | 1194 | BN_set_flags(bn, NUM2INT(arg));
|
1195 | 1195 | return Qnil;
|
1196 | 1196 | }
|
|
0 commit comments