openssl 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +180 -29
- data/History.md +114 -1
- data/README.md +11 -7
- data/ext/openssl/extconf.rb +7 -9
- data/ext/openssl/openssl_missing.c +1 -1
- data/ext/openssl/openssl_missing.h +1 -1
- data/ext/openssl/ossl.c +7 -9
- data/ext/openssl/ossl.h +12 -8
- data/ext/openssl/ossl_asn1.c +65 -261
- data/ext/openssl/ossl_asn1.h +1 -19
- data/ext/openssl/ossl_bio.c +1 -1
- data/ext/openssl/ossl_bio.h +1 -1
- data/ext/openssl/ossl_bn.c +12 -12
- data/ext/openssl/ossl_bn.h +1 -2
- data/ext/openssl/ossl_cipher.c +24 -9
- data/ext/openssl/ossl_cipher.h +1 -4
- data/ext/openssl/ossl_config.c +10 -9
- data/ext/openssl/ossl_config.h +1 -1
- data/ext/openssl/ossl_digest.c +39 -20
- data/ext/openssl/ossl_digest.h +1 -4
- data/ext/openssl/ossl_engine.c +3 -3
- data/ext/openssl/ossl_engine.h +1 -4
- data/ext/openssl/ossl_hmac.c +3 -3
- data/ext/openssl/ossl_hmac.h +1 -4
- data/ext/openssl/ossl_kdf.c +5 -5
- data/ext/openssl/ossl_ns_spki.c +8 -8
- data/ext/openssl/ossl_ns_spki.h +1 -5
- data/ext/openssl/ossl_ocsp.c +8 -8
- data/ext/openssl/ossl_ocsp.h +1 -8
- data/ext/openssl/ossl_pkcs12.c +54 -3
- data/ext/openssl/ossl_pkcs12.h +1 -4
- data/ext/openssl/ossl_pkcs7.c +79 -22
- data/ext/openssl/ossl_pkcs7.h +2 -22
- data/ext/openssl/ossl_pkey.c +1 -1
- data/ext/openssl/ossl_pkey.h +3 -14
- data/ext/openssl/ossl_pkey_dh.c +2 -2
- data/ext/openssl/ossl_pkey_dsa.c +2 -2
- data/ext/openssl/ossl_pkey_ec.c +6 -6
- data/ext/openssl/ossl_pkey_rsa.c +2 -2
- data/ext/openssl/ossl_provider.c +1 -1
- data/ext/openssl/ossl_rand.c +3 -3
- data/ext/openssl/ossl_rand.h +1 -4
- data/ext/openssl/ossl_ssl.c +71 -52
- data/ext/openssl/ossl_ssl.h +1 -1
- data/ext/openssl/ossl_ts.c +73 -15
- data/ext/openssl/ossl_ts.h +1 -1
- data/ext/openssl/ossl_x509.c +1 -1
- data/ext/openssl/ossl_x509.h +1 -20
- data/ext/openssl/ossl_x509attr.c +25 -26
- data/ext/openssl/ossl_x509cert.c +42 -3
- data/ext/openssl/ossl_x509crl.c +8 -4
- data/ext/openssl/ossl_x509ext.c +3 -3
- data/ext/openssl/ossl_x509name.c +3 -3
- data/ext/openssl/ossl_x509req.c +8 -4
- data/ext/openssl/ossl_x509revoked.c +2 -2
- data/ext/openssl/ossl_x509store.c +16 -11
- data/lib/openssl/asn1.rb +188 -0
- data/lib/openssl/bn.rb +1 -1
- data/lib/openssl/buffering.rb +24 -9
- data/lib/openssl/cipher.rb +1 -1
- data/lib/openssl/digest.rb +1 -1
- data/lib/openssl/marshal.rb +1 -1
- data/lib/openssl/ssl.rb +67 -4
- data/lib/openssl/version.rb +1 -1
- data/lib/openssl/x509.rb +6 -6
- data/lib/openssl.rb +2 -1
- metadata +6 -4
- /data/{LICENSE.txt → COPYING} +0 -0
data/ext/openssl/ossl_asn1.c
CHANGED
@@ -5,13 +5,12 @@
|
|
5
5
|
*/
|
6
6
|
/*
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
8
|
-
* (See the file '
|
8
|
+
* (See the file 'COPYING'.)
|
9
9
|
*/
|
10
10
|
#include "ossl.h"
|
11
11
|
|
12
12
|
static VALUE ossl_asn1_decode0(unsigned char **pp, long length, long *offset,
|
13
13
|
int depth, int yield, long *num_read);
|
14
|
-
static VALUE ossl_asn1_initialize(int argc, VALUE *argv, VALUE self);
|
15
14
|
|
16
15
|
/*
|
17
16
|
* DATE conversion
|
@@ -158,38 +157,33 @@ asn1integer_to_num_i(VALUE arg)
|
|
158
157
|
#define ossl_asn1_get_tag_class(o) rb_attr_get((o),sivTAG_CLASS)
|
159
158
|
#define ossl_asn1_get_indefinite_length(o) rb_attr_get((o),sivINDEFINITE_LENGTH)
|
160
159
|
|
161
|
-
#define ossl_asn1_set_value(o,v) rb_ivar_set((o),sivVALUE,(v))
|
162
|
-
#define ossl_asn1_set_tag(o,v) rb_ivar_set((o),sivTAG,(v))
|
163
|
-
#define ossl_asn1_set_tagging(o,v) rb_ivar_set((o),sivTAGGING,(v))
|
164
|
-
#define ossl_asn1_set_tag_class(o,v) rb_ivar_set((o),sivTAG_CLASS,(v))
|
165
160
|
#define ossl_asn1_set_indefinite_length(o,v) rb_ivar_set((o),sivINDEFINITE_LENGTH,(v))
|
166
161
|
|
167
162
|
VALUE mASN1;
|
168
163
|
VALUE eASN1Error;
|
169
164
|
|
170
165
|
VALUE cASN1Data;
|
171
|
-
VALUE cASN1Primitive;
|
172
|
-
VALUE cASN1Constructive;
|
173
|
-
|
174
|
-
VALUE cASN1EndOfContent;
|
175
|
-
VALUE cASN1Boolean; /* BOOLEAN */
|
176
|
-
VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
|
177
|
-
VALUE cASN1BitString; /* BIT STRING */
|
178
|
-
VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
|
179
|
-
VALUE cASN1NumericString, cASN1PrintableString;
|
180
|
-
VALUE cASN1T61String, cASN1VideotexString;
|
181
|
-
VALUE cASN1IA5String, cASN1GraphicString;
|
182
|
-
VALUE cASN1ISO64String, cASN1GeneralString;
|
183
|
-
VALUE cASN1UniversalString, cASN1BMPString;
|
184
|
-
VALUE cASN1Null; /* NULL */
|
185
|
-
VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
|
186
|
-
VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
|
187
|
-
VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
|
166
|
+
static VALUE cASN1Primitive;
|
167
|
+
static VALUE cASN1Constructive;
|
168
|
+
|
169
|
+
static VALUE cASN1EndOfContent;
|
170
|
+
static VALUE cASN1Boolean; /* BOOLEAN */
|
171
|
+
static VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
|
172
|
+
static VALUE cASN1BitString; /* BIT STRING */
|
173
|
+
static VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
|
174
|
+
static VALUE cASN1NumericString, cASN1PrintableString;
|
175
|
+
static VALUE cASN1T61String, cASN1VideotexString;
|
176
|
+
static VALUE cASN1IA5String, cASN1GraphicString;
|
177
|
+
static VALUE cASN1ISO64String, cASN1GeneralString;
|
178
|
+
static VALUE cASN1UniversalString, cASN1BMPString;
|
179
|
+
static VALUE cASN1Null; /* NULL */
|
180
|
+
static VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
|
181
|
+
static VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
|
182
|
+
static VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
|
188
183
|
|
189
184
|
static VALUE sym_IMPLICIT, sym_EXPLICIT;
|
190
185
|
static VALUE sym_UNIVERSAL, sym_APPLICATION, sym_CONTEXT_SPECIFIC, sym_PRIVATE;
|
191
186
|
static ID sivVALUE, sivTAG, sivTAG_CLASS, sivTAGGING, sivINDEFINITE_LENGTH, sivUNUSED_BITS;
|
192
|
-
static ID id_each;
|
193
187
|
|
194
188
|
/*
|
195
189
|
* Ruby to ASN1 converters
|
@@ -503,7 +497,7 @@ static VALUE class_tag_map;
|
|
503
497
|
|
504
498
|
static int ossl_asn1_default_tag(VALUE obj);
|
505
499
|
|
506
|
-
ASN1_TYPE*
|
500
|
+
static ASN1_TYPE *
|
507
501
|
ossl_asn1_get_asn1type(VALUE obj)
|
508
502
|
{
|
509
503
|
ASN1_TYPE *ret;
|
@@ -638,35 +632,6 @@ ossl_asn1_class2sym(int tc)
|
|
638
632
|
return sym_UNIVERSAL;
|
639
633
|
}
|
640
634
|
|
641
|
-
/*
|
642
|
-
* call-seq:
|
643
|
-
* OpenSSL::ASN1::ASN1Data.new(value, tag, tag_class) => ASN1Data
|
644
|
-
*
|
645
|
-
* _value_: Please have a look at Constructive and Primitive to see how Ruby
|
646
|
-
* types are mapped to ASN.1 types and vice versa.
|
647
|
-
*
|
648
|
-
* _tag_: An Integer indicating the tag number.
|
649
|
-
*
|
650
|
-
* _tag_class_: A Symbol indicating the tag class. Please cf. ASN1 for
|
651
|
-
* possible values.
|
652
|
-
*
|
653
|
-
* == Example
|
654
|
-
* asn1_int = OpenSSL::ASN1Data.new(42, 2, :UNIVERSAL) # => Same as OpenSSL::ASN1::Integer.new(42)
|
655
|
-
* tagged_int = OpenSSL::ASN1Data.new(42, 0, :CONTEXT_SPECIFIC) # implicitly 0-tagged INTEGER
|
656
|
-
*/
|
657
|
-
static VALUE
|
658
|
-
ossl_asn1data_initialize(VALUE self, VALUE value, VALUE tag, VALUE tag_class)
|
659
|
-
{
|
660
|
-
if(!SYMBOL_P(tag_class))
|
661
|
-
ossl_raise(eASN1Error, "invalid tag class");
|
662
|
-
ossl_asn1_set_tag(self, tag);
|
663
|
-
ossl_asn1_set_value(self, value);
|
664
|
-
ossl_asn1_set_tag_class(self, tag_class);
|
665
|
-
ossl_asn1_set_indefinite_length(self, Qfalse);
|
666
|
-
|
667
|
-
return self;
|
668
|
-
}
|
669
|
-
|
670
635
|
static VALUE
|
671
636
|
to_der_internal(VALUE self, int constructed, int indef_len, VALUE body)
|
672
637
|
{
|
@@ -795,20 +760,19 @@ int_ossl_asn1_decode0_prim(unsigned char **pp, long length, long hlen, int tag,
|
|
795
760
|
if (tc == sym_UNIVERSAL &&
|
796
761
|
tag < ossl_asn1_info_size && ossl_asn1_info[tag].klass) {
|
797
762
|
VALUE klass = *ossl_asn1_info[tag].klass;
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
ossl_asn1_initialize(4, args, asn1data);
|
763
|
+
if (tag == V_ASN1_EOC)
|
764
|
+
asn1data = rb_funcall(cASN1EndOfContent, rb_intern("new"), 0);
|
765
|
+
else {
|
766
|
+
VALUE args[4] = { value, INT2NUM(tag), Qnil, tc };
|
767
|
+
asn1data = rb_funcallv_public(klass, rb_intern("new"), 4, args);
|
768
|
+
}
|
805
769
|
if(tag == V_ASN1_BIT_STRING){
|
806
770
|
rb_ivar_set(asn1data, sivUNUSED_BITS, LONG2NUM(flag));
|
807
771
|
}
|
808
772
|
}
|
809
773
|
else {
|
810
|
-
|
811
|
-
|
774
|
+
VALUE args[3] = { value, INT2NUM(tag), tc };
|
775
|
+
asn1data = rb_funcallv_public(cASN1Data, rb_intern("new"), 3, args);
|
812
776
|
}
|
813
777
|
|
814
778
|
return asn1data;
|
@@ -842,20 +806,20 @@ int_ossl_asn1_decode0_cons(unsigned char **pp, long max_len, long length,
|
|
842
806
|
}
|
843
807
|
|
844
808
|
if (tc == sym_UNIVERSAL) {
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
809
|
+
if (tag == V_ASN1_SEQUENCE) {
|
810
|
+
VALUE args[4] = { ary, INT2NUM(tag), Qnil, tc };
|
811
|
+
asn1data = rb_funcallv_public(cASN1Sequence, rb_intern("new"), 4, args);
|
812
|
+
} else if (tag == V_ASN1_SET) {
|
813
|
+
VALUE args[4] = { ary, INT2NUM(tag), Qnil, tc };
|
814
|
+
asn1data = rb_funcallv_public(cASN1Set, rb_intern("new"), 4, args);
|
815
|
+
} else {
|
816
|
+
VALUE args[4] = { ary, INT2NUM(tag), Qnil, tc };
|
817
|
+
asn1data = rb_funcallv_public(cASN1Constructive, rb_intern("new"), 4, args);
|
818
|
+
}
|
855
819
|
}
|
856
820
|
else {
|
857
|
-
|
858
|
-
|
821
|
+
VALUE args[3] = {ary, INT2NUM(tag), tc};
|
822
|
+
asn1data = rb_funcallv_public(cASN1Data, rb_intern("new"), 3, args);
|
859
823
|
}
|
860
824
|
|
861
825
|
if (indefinite)
|
@@ -1048,83 +1012,6 @@ ossl_asn1_decode_all(VALUE self, VALUE obj)
|
|
1048
1012
|
return ary;
|
1049
1013
|
}
|
1050
1014
|
|
1051
|
-
/*
|
1052
|
-
* call-seq:
|
1053
|
-
* OpenSSL::ASN1::Primitive.new(value [, tag, tagging, tag_class ]) => Primitive
|
1054
|
-
*
|
1055
|
-
* _value_: is mandatory.
|
1056
|
-
*
|
1057
|
-
* _tag_: optional, may be specified for tagged values. If no _tag_ is
|
1058
|
-
* specified, the UNIVERSAL tag corresponding to the Primitive sub-class
|
1059
|
-
* is used by default.
|
1060
|
-
*
|
1061
|
-
* _tagging_: may be used as an encoding hint to encode a value either
|
1062
|
-
* explicitly or implicitly, see ASN1 for possible values.
|
1063
|
-
*
|
1064
|
-
* _tag_class_: if _tag_ and _tagging_ are +nil+ then this is set to
|
1065
|
-
* +:UNIVERSAL+ by default. If either _tag_ or _tagging_ are set then
|
1066
|
-
* +:CONTEXT_SPECIFIC+ is used as the default. For possible values please
|
1067
|
-
* cf. ASN1.
|
1068
|
-
*
|
1069
|
-
* == Example
|
1070
|
-
* int = OpenSSL::ASN1::Integer.new(42)
|
1071
|
-
* zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT)
|
1072
|
-
* private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE)
|
1073
|
-
*/
|
1074
|
-
static VALUE
|
1075
|
-
ossl_asn1_initialize(int argc, VALUE *argv, VALUE self)
|
1076
|
-
{
|
1077
|
-
VALUE value, tag, tagging, tag_class;
|
1078
|
-
int default_tag;
|
1079
|
-
|
1080
|
-
rb_scan_args(argc, argv, "13", &value, &tag, &tagging, &tag_class);
|
1081
|
-
default_tag = ossl_asn1_default_tag(self);
|
1082
|
-
|
1083
|
-
if (default_tag == -1 || argc > 1) {
|
1084
|
-
if(NIL_P(tag))
|
1085
|
-
ossl_raise(eASN1Error, "must specify tag number");
|
1086
|
-
if(!NIL_P(tagging) && !SYMBOL_P(tagging))
|
1087
|
-
ossl_raise(eASN1Error, "invalid tagging method");
|
1088
|
-
if(NIL_P(tag_class)) {
|
1089
|
-
if (NIL_P(tagging))
|
1090
|
-
tag_class = sym_UNIVERSAL;
|
1091
|
-
else
|
1092
|
-
tag_class = sym_CONTEXT_SPECIFIC;
|
1093
|
-
}
|
1094
|
-
if(!SYMBOL_P(tag_class))
|
1095
|
-
ossl_raise(eASN1Error, "invalid tag class");
|
1096
|
-
}
|
1097
|
-
else{
|
1098
|
-
tag = INT2NUM(default_tag);
|
1099
|
-
tagging = Qnil;
|
1100
|
-
tag_class = sym_UNIVERSAL;
|
1101
|
-
}
|
1102
|
-
ossl_asn1_set_tag(self, tag);
|
1103
|
-
ossl_asn1_set_value(self, value);
|
1104
|
-
ossl_asn1_set_tagging(self, tagging);
|
1105
|
-
ossl_asn1_set_tag_class(self, tag_class);
|
1106
|
-
ossl_asn1_set_indefinite_length(self, Qfalse);
|
1107
|
-
if (default_tag == V_ASN1_BIT_STRING)
|
1108
|
-
rb_ivar_set(self, sivUNUSED_BITS, INT2FIX(0));
|
1109
|
-
|
1110
|
-
return self;
|
1111
|
-
}
|
1112
|
-
|
1113
|
-
static VALUE
|
1114
|
-
ossl_asn1eoc_initialize(VALUE self) {
|
1115
|
-
VALUE tag, tagging, tag_class, value;
|
1116
|
-
tag = INT2FIX(0);
|
1117
|
-
tagging = Qnil;
|
1118
|
-
tag_class = sym_UNIVERSAL;
|
1119
|
-
value = rb_str_new("", 0);
|
1120
|
-
ossl_asn1_set_tag(self, tag);
|
1121
|
-
ossl_asn1_set_value(self, value);
|
1122
|
-
ossl_asn1_set_tagging(self, tagging);
|
1123
|
-
ossl_asn1_set_tag_class(self, tag_class);
|
1124
|
-
ossl_asn1_set_indefinite_length(self, Qfalse);
|
1125
|
-
return self;
|
1126
|
-
}
|
1127
|
-
|
1128
1015
|
static VALUE
|
1129
1016
|
ossl_asn1eoc_to_der(VALUE self)
|
1130
1017
|
{
|
@@ -1163,9 +1050,12 @@ ossl_asn1prim_to_der(VALUE self)
|
|
1163
1050
|
rb_jump_tag(state);
|
1164
1051
|
}
|
1165
1052
|
p0 = p1 = (unsigned char *)RSTRING_PTR(str);
|
1166
|
-
i2d_ASN1_TYPE(asn1, &p0)
|
1053
|
+
if (i2d_ASN1_TYPE(asn1, &p0) < 0) {
|
1054
|
+
ASN1_TYPE_free(asn1);
|
1055
|
+
ossl_raise(eASN1Error, "i2d_ASN1_TYPE");
|
1056
|
+
}
|
1167
1057
|
ASN1_TYPE_free(asn1);
|
1168
|
-
|
1058
|
+
ossl_str_adjust(str, p0);
|
1169
1059
|
|
1170
1060
|
/* Strip header since to_der_internal() wants only the payload */
|
1171
1061
|
j = ASN1_get_object((const unsigned char **)&p1, &bodylen, &tag, &tc, alllen);
|
@@ -1213,27 +1103,6 @@ ossl_asn1cons_to_der(VALUE self)
|
|
1213
1103
|
return to_der_internal(self, 1, indef_len, str);
|
1214
1104
|
}
|
1215
1105
|
|
1216
|
-
/*
|
1217
|
-
* call-seq:
|
1218
|
-
* asn1_ary.each { |asn1| block } => asn1_ary
|
1219
|
-
*
|
1220
|
-
* Calls the given block once for each element in self, passing that element
|
1221
|
-
* as parameter _asn1_. If no block is given, an enumerator is returned
|
1222
|
-
* instead.
|
1223
|
-
*
|
1224
|
-
* == Example
|
1225
|
-
* asn1_ary.each do |asn1|
|
1226
|
-
* puts asn1
|
1227
|
-
* end
|
1228
|
-
*/
|
1229
|
-
static VALUE
|
1230
|
-
ossl_asn1cons_each(VALUE self)
|
1231
|
-
{
|
1232
|
-
rb_block_call(ossl_asn1_get_value(self), id_each, 0, 0, 0, 0);
|
1233
|
-
|
1234
|
-
return self;
|
1235
|
-
}
|
1236
|
-
|
1237
1106
|
/*
|
1238
1107
|
* call-seq:
|
1239
1108
|
* OpenSSL::ASN1::ObjectId.register(object_id, short_name, long_name)
|
@@ -1298,30 +1167,6 @@ ossl_asn1obj_get_ln(VALUE self)
|
|
1298
1167
|
return ret;
|
1299
1168
|
}
|
1300
1169
|
|
1301
|
-
/*
|
1302
|
-
* call-seq:
|
1303
|
-
* oid == other_oid => true or false
|
1304
|
-
*
|
1305
|
-
* Returns +true+ if _other_oid_ is the same as _oid_
|
1306
|
-
*/
|
1307
|
-
static VALUE
|
1308
|
-
ossl_asn1obj_eq(VALUE self, VALUE other)
|
1309
|
-
{
|
1310
|
-
VALUE valSelf, valOther;
|
1311
|
-
int nidSelf, nidOther;
|
1312
|
-
|
1313
|
-
valSelf = ossl_asn1_get_value(self);
|
1314
|
-
valOther = ossl_asn1_get_value(other);
|
1315
|
-
|
1316
|
-
if ((nidSelf = OBJ_txt2nid(StringValueCStr(valSelf))) == NID_undef)
|
1317
|
-
ossl_raise(eASN1Error, "OBJ_txt2nid");
|
1318
|
-
|
1319
|
-
if ((nidOther = OBJ_txt2nid(StringValueCStr(valOther))) == NID_undef)
|
1320
|
-
ossl_raise(eASN1Error, "OBJ_txt2nid");
|
1321
|
-
|
1322
|
-
return nidSelf == nidOther ? Qtrue : Qfalse;
|
1323
|
-
}
|
1324
|
-
|
1325
1170
|
static VALUE
|
1326
1171
|
asn1obj_get_oid_i(VALUE vobj)
|
1327
1172
|
{
|
@@ -1366,9 +1211,28 @@ ossl_asn1obj_get_oid(VALUE self)
|
|
1366
1211
|
return str;
|
1367
1212
|
}
|
1368
1213
|
|
1214
|
+
/*
|
1215
|
+
* call-seq:
|
1216
|
+
* oid == other_oid => true or false
|
1217
|
+
*
|
1218
|
+
* Returns +true+ if _other_oid_ is the same as _oid_.
|
1219
|
+
*/
|
1220
|
+
static VALUE
|
1221
|
+
ossl_asn1obj_eq(VALUE self, VALUE other)
|
1222
|
+
{
|
1223
|
+
VALUE oid1, oid2;
|
1224
|
+
|
1225
|
+
if (!rb_obj_is_kind_of(other, cASN1ObjectId))
|
1226
|
+
return Qfalse;
|
1227
|
+
|
1228
|
+
oid1 = ossl_asn1obj_get_oid(self);
|
1229
|
+
oid2 = ossl_asn1obj_get_oid(other);
|
1230
|
+
return rb_str_equal(oid1, oid2);
|
1231
|
+
}
|
1232
|
+
|
1369
1233
|
#define OSSL_ASN1_IMPL_FACTORY_METHOD(klass) \
|
1370
1234
|
static VALUE ossl_asn1_##klass(int argc, VALUE *argv, VALUE self)\
|
1371
|
-
{ return
|
1235
|
+
{ return rb_funcallv_public(cASN1##klass, rb_intern("new"), argc, argv); }
|
1372
1236
|
|
1373
1237
|
OSSL_ASN1_IMPL_FACTORY_METHOD(Boolean)
|
1374
1238
|
OSSL_ASN1_IMPL_FACTORY_METHOD(Integer)
|
@@ -1654,42 +1518,6 @@ Init_ossl_asn1(void)
|
|
1654
1518
|
* puts int2.value # => 1
|
1655
1519
|
*/
|
1656
1520
|
cASN1Data = rb_define_class_under(mASN1, "ASN1Data", rb_cObject);
|
1657
|
-
/*
|
1658
|
-
* Carries the value of a ASN.1 type.
|
1659
|
-
* Please confer Constructive and Primitive for the mappings between
|
1660
|
-
* ASN.1 data types and Ruby classes.
|
1661
|
-
*/
|
1662
|
-
rb_attr(cASN1Data, rb_intern("value"), 1, 1, 0);
|
1663
|
-
/*
|
1664
|
-
* An Integer representing the tag number of this ASN1Data. Never +nil+.
|
1665
|
-
*/
|
1666
|
-
rb_attr(cASN1Data, rb_intern("tag"), 1, 1, 0);
|
1667
|
-
/*
|
1668
|
-
* A Symbol representing the tag class of this ASN1Data. Never +nil+.
|
1669
|
-
* See ASN1Data for possible values.
|
1670
|
-
*/
|
1671
|
-
rb_attr(cASN1Data, rb_intern("tag_class"), 1, 1, 0);
|
1672
|
-
/*
|
1673
|
-
* Never +nil+. A boolean value indicating whether the encoding uses
|
1674
|
-
* indefinite length (in the case of parsing) or whether an indefinite
|
1675
|
-
* length form shall be used (in the encoding case).
|
1676
|
-
* In DER, every value uses definite length form. But in scenarios where
|
1677
|
-
* large amounts of data need to be transferred it might be desirable to
|
1678
|
-
* have some kind of streaming support available.
|
1679
|
-
* For example, huge OCTET STRINGs are preferably sent in smaller-sized
|
1680
|
-
* chunks, each at a time.
|
1681
|
-
* This is possible in BER by setting the length bytes of an encoding
|
1682
|
-
* to zero and by this indicating that the following value will be
|
1683
|
-
* sent in chunks. Indefinite length encodings are always constructed.
|
1684
|
-
* The end of such a stream of chunks is indicated by sending a EOC
|
1685
|
-
* (End of Content) tag. SETs and SEQUENCEs may use an indefinite length
|
1686
|
-
* encoding, but also primitive types such as e.g. OCTET STRINGS or
|
1687
|
-
* BIT STRINGS may leverage this functionality (cf. ITU-T X.690).
|
1688
|
-
*/
|
1689
|
-
rb_attr(cASN1Data, rb_intern("indefinite_length"), 1, 1, 0);
|
1690
|
-
rb_define_alias(cASN1Data, "infinite_length", "indefinite_length");
|
1691
|
-
rb_define_alias(cASN1Data, "infinite_length=", "indefinite_length=");
|
1692
|
-
rb_define_method(cASN1Data, "initialize", ossl_asn1data_initialize, 3);
|
1693
1521
|
rb_define_method(cASN1Data, "to_der", ossl_asn1data_to_der, 0);
|
1694
1522
|
|
1695
1523
|
/* Document-class: OpenSSL::ASN1::Primitive
|
@@ -1757,16 +1585,6 @@ Init_ossl_asn1(void)
|
|
1757
1585
|
* prim_zero_tagged_explicit = <class>.new(value, 0, :EXPLICIT)
|
1758
1586
|
*/
|
1759
1587
|
cASN1Primitive = rb_define_class_under(mASN1, "Primitive", cASN1Data);
|
1760
|
-
/*
|
1761
|
-
* May be used as a hint for encoding a value either implicitly or
|
1762
|
-
* explicitly by setting it either to +:IMPLICIT+ or to +:EXPLICIT+.
|
1763
|
-
* _tagging_ is not set when a ASN.1 structure is parsed using
|
1764
|
-
* OpenSSL::ASN1.decode.
|
1765
|
-
*/
|
1766
|
-
rb_attr(cASN1Primitive, rb_intern("tagging"), 1, 1, Qtrue);
|
1767
|
-
rb_undef_method(cASN1Primitive, "indefinite_length=");
|
1768
|
-
rb_undef_method(cASN1Primitive, "infinite_length=");
|
1769
|
-
rb_define_method(cASN1Primitive, "initialize", ossl_asn1_initialize, -1);
|
1770
1588
|
rb_define_method(cASN1Primitive, "to_der", ossl_asn1prim_to_der, 0);
|
1771
1589
|
|
1772
1590
|
/* Document-class: OpenSSL::ASN1::Constructive
|
@@ -1797,17 +1615,7 @@ Init_ossl_asn1(void)
|
|
1797
1615
|
* set = OpenSSL::ASN1::Set.new( [ int, str ] )
|
1798
1616
|
*/
|
1799
1617
|
cASN1Constructive = rb_define_class_under(mASN1,"Constructive", cASN1Data);
|
1800
|
-
rb_include_module(cASN1Constructive, rb_mEnumerable);
|
1801
|
-
/*
|
1802
|
-
* May be used as a hint for encoding a value either implicitly or
|
1803
|
-
* explicitly by setting it either to +:IMPLICIT+ or to +:EXPLICIT+.
|
1804
|
-
* _tagging_ is not set when a ASN.1 structure is parsed using
|
1805
|
-
* OpenSSL::ASN1.decode.
|
1806
|
-
*/
|
1807
|
-
rb_attr(cASN1Constructive, rb_intern("tagging"), 1, 1, Qtrue);
|
1808
|
-
rb_define_method(cASN1Constructive, "initialize", ossl_asn1_initialize, -1);
|
1809
1618
|
rb_define_method(cASN1Constructive, "to_der", ossl_asn1cons_to_der, 0);
|
1810
|
-
rb_define_method(cASN1Constructive, "each", ossl_asn1cons_each, 0);
|
1811
1619
|
|
1812
1620
|
#define OSSL_ASN1_DEFINE_CLASS(name, super) \
|
1813
1621
|
do{\
|
@@ -1856,13 +1664,10 @@ do{\
|
|
1856
1664
|
rb_define_alias(cASN1ObjectId, "short_name", "sn");
|
1857
1665
|
rb_define_alias(cASN1ObjectId, "long_name", "ln");
|
1858
1666
|
rb_define_method(cASN1ObjectId, "==", ossl_asn1obj_eq, 1);
|
1859
|
-
rb_attr(cASN1BitString, rb_intern("unused_bits"), 1, 1, 0);
|
1860
1667
|
|
1861
|
-
rb_define_method(cASN1EndOfContent, "initialize", ossl_asn1eoc_initialize, 0);
|
1862
1668
|
rb_define_method(cASN1EndOfContent, "to_der", ossl_asn1eoc_to_der, 0);
|
1863
1669
|
|
1864
1670
|
class_tag_map = rb_hash_new();
|
1865
|
-
rb_gc_register_mark_object(class_tag_map);
|
1866
1671
|
rb_hash_aset(class_tag_map, cASN1EndOfContent, INT2NUM(V_ASN1_EOC));
|
1867
1672
|
rb_hash_aset(class_tag_map, cASN1Boolean, INT2NUM(V_ASN1_BOOLEAN));
|
1868
1673
|
rb_hash_aset(class_tag_map, cASN1Integer, INT2NUM(V_ASN1_INTEGER));
|
@@ -1886,6 +1691,5 @@ do{\
|
|
1886
1691
|
rb_hash_aset(class_tag_map, cASN1GeneralString, INT2NUM(V_ASN1_GENERALSTRING));
|
1887
1692
|
rb_hash_aset(class_tag_map, cASN1UniversalString, INT2NUM(V_ASN1_UNIVERSALSTRING));
|
1888
1693
|
rb_hash_aset(class_tag_map, cASN1BMPString, INT2NUM(V_ASN1_BMPSTRING));
|
1889
|
-
|
1890
|
-
id_each = rb_intern_const("each");
|
1694
|
+
rb_define_const(mASN1, "CLASS_TAG_MAP", class_tag_map);
|
1891
1695
|
}
|
data/ext/openssl/ossl_asn1.h
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
*/
|
6
6
|
/*
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
8
|
-
* (See the file '
|
8
|
+
* (See the file 'COPYING'.)
|
9
9
|
*/
|
10
10
|
#if !defined(_OSSL_ASN1_H_)
|
11
11
|
#define _OSSL_ASN1_H_
|
@@ -38,24 +38,6 @@ extern VALUE mASN1;
|
|
38
38
|
extern VALUE eASN1Error;
|
39
39
|
|
40
40
|
extern VALUE cASN1Data;
|
41
|
-
extern VALUE cASN1Primitive;
|
42
|
-
extern VALUE cASN1Constructive;
|
43
|
-
|
44
|
-
extern VALUE cASN1Boolean; /* BOOLEAN */
|
45
|
-
extern VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
|
46
|
-
extern VALUE cASN1BitString; /* BIT STRING */
|
47
|
-
extern VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
|
48
|
-
extern VALUE cASN1NumericString, cASN1PrintableString;
|
49
|
-
extern VALUE cASN1T61String, cASN1VideotexString;
|
50
|
-
extern VALUE cASN1IA5String, cASN1GraphicString;
|
51
|
-
extern VALUE cASN1ISO64String, cASN1GeneralString;
|
52
|
-
extern VALUE cASN1UniversalString, cASN1BMPString;
|
53
|
-
extern VALUE cASN1Null; /* NULL */
|
54
|
-
extern VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
|
55
|
-
extern VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
|
56
|
-
extern VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
|
57
|
-
|
58
|
-
ASN1_TYPE *ossl_asn1_get_asn1type(VALUE);
|
59
41
|
|
60
42
|
void Init_ossl_asn1(void);
|
61
43
|
|
data/ext/openssl/ossl_bio.c
CHANGED
data/ext/openssl/ossl_bio.h
CHANGED
data/ext/openssl/ossl_bn.c
CHANGED
@@ -5,15 +5,11 @@
|
|
5
5
|
*/
|
6
6
|
/*
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
8
|
-
* (See the file '
|
8
|
+
* (See the file 'COPYING'.)
|
9
9
|
*/
|
10
10
|
/* modified by Michal Rokos <m.rokos@sh.cvut.cz> */
|
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
|
/*
|
@@ -53,7 +49,7 @@ VALUE cBN;
|
|
53
49
|
*
|
54
50
|
* Generic Error for all of OpenSSL::BN (big num)
|
55
51
|
*/
|
56
|
-
VALUE eBNError;
|
52
|
+
static VALUE eBNError;
|
57
53
|
|
58
54
|
/*
|
59
55
|
* Public
|
@@ -156,19 +152,19 @@ ossl_bn_value_ptr(volatile VALUE *ptr)
|
|
156
152
|
*/
|
157
153
|
|
158
154
|
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
159
|
-
void
|
155
|
+
static void
|
160
156
|
ossl_bn_ctx_free(void *ptr)
|
161
157
|
{
|
162
158
|
BN_CTX *ctx = (BN_CTX *)ptr;
|
163
159
|
BN_CTX_free(ctx);
|
164
160
|
}
|
165
161
|
|
166
|
-
struct rb_ractor_local_storage_type ossl_bn_ctx_key_type = {
|
162
|
+
static struct rb_ractor_local_storage_type ossl_bn_ctx_key_type = {
|
167
163
|
NULL, // mark
|
168
164
|
ossl_bn_ctx_free,
|
169
165
|
};
|
170
166
|
|
171
|
-
rb_ractor_local_key_t ossl_bn_ctx_key;
|
167
|
+
static rb_ractor_local_key_t ossl_bn_ctx_key;
|
172
168
|
|
173
169
|
BN_CTX *
|
174
170
|
ossl_bn_ctx_get(void)
|
@@ -244,7 +240,7 @@ ossl_bn_alloc(VALUE klass)
|
|
244
240
|
* number.
|
245
241
|
* - +10+ - Decimal number representation, with a leading '-' for a negative
|
246
242
|
* number.
|
247
|
-
* - +16+ -
|
243
|
+
* - +16+ - Hexadecimal number representation, with a leading '-' for a
|
248
244
|
* negative number.
|
249
245
|
*/
|
250
246
|
static VALUE
|
@@ -263,6 +259,7 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
|
|
263
259
|
ossl_raise(rb_eArgError, "invalid argument");
|
264
260
|
}
|
265
261
|
|
262
|
+
rb_check_frozen(self);
|
266
263
|
if (RB_INTEGER_TYPE_P(str)) {
|
267
264
|
GetBN(self, bn);
|
268
265
|
integer_to_bnptr(str, bn);
|
@@ -326,7 +323,7 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
|
|
326
323
|
* the bignum is ignored.
|
327
324
|
* - +10+ - Decimal number representation, with a leading '-' for a negative
|
328
325
|
* bignum.
|
329
|
-
* - +16+ -
|
326
|
+
* - +16+ - Hexadecimal number representation, with a leading '-' for a
|
330
327
|
* negative bignum.
|
331
328
|
*/
|
332
329
|
static VALUE
|
@@ -693,6 +690,7 @@ BIGNUM_3c(mod_exp)
|
|
693
690
|
ossl_bn_##func(VALUE self, VALUE bit) \
|
694
691
|
{ \
|
695
692
|
BIGNUM *bn; \
|
693
|
+
rb_check_frozen(self); \
|
696
694
|
GetBN(self, bn); \
|
697
695
|
if (BN_##func(bn, NUM2INT(bit)) <= 0) { \
|
698
696
|
ossl_raise(eBNError, NULL); \
|
@@ -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
|
}
|
data/ext/openssl/ossl_bn.h
CHANGED
@@ -5,13 +5,12 @@
|
|
5
5
|
*/
|
6
6
|
/*
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
8
|
-
* (See the file '
|
8
|
+
* (See the file 'COPYING'.)
|
9
9
|
*/
|
10
10
|
#if !defined(_OSSL_BN_H_)
|
11
11
|
#define _OSSL_BN_H_
|
12
12
|
|
13
13
|
extern VALUE cBN;
|
14
|
-
extern VALUE eBNError;
|
15
14
|
|
16
15
|
BN_CTX *ossl_bn_ctx_get(void);
|
17
16
|
#define ossl_bn_ctx ossl_bn_ctx_get()
|