openssl 3.3.3 → 4.0.2
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 +3 -0
- data/History.md +111 -0
- data/README.md +12 -11
- data/ext/openssl/extconf.rb +30 -70
- data/ext/openssl/openssl_missing.h +0 -210
- data/ext/openssl/ossl.c +295 -304
- data/ext/openssl/ossl.h +13 -9
- data/ext/openssl/ossl_asn1.c +598 -406
- data/ext/openssl/ossl_asn1.h +15 -1
- data/ext/openssl/ossl_bio.c +8 -4
- data/ext/openssl/ossl_bn.c +286 -291
- data/ext/openssl/ossl_cipher.c +257 -209
- data/ext/openssl/ossl_cipher.h +10 -1
- data/ext/openssl/ossl_config.c +1 -6
- data/ext/openssl/ossl_digest.c +74 -43
- data/ext/openssl/ossl_digest.h +9 -1
- data/ext/openssl/ossl_engine.c +39 -103
- data/ext/openssl/ossl_hmac.c +30 -36
- data/ext/openssl/ossl_kdf.c +42 -53
- data/ext/openssl/ossl_ns_spki.c +27 -32
- data/ext/openssl/ossl_ocsp.c +208 -236
- data/ext/openssl/ossl_pkcs12.c +26 -26
- data/ext/openssl/ossl_pkcs7.c +175 -145
- data/ext/openssl/ossl_pkey.c +102 -158
- data/ext/openssl/ossl_pkey.h +99 -100
- data/ext/openssl/ossl_pkey_dh.c +31 -68
- data/ext/openssl/ossl_pkey_dsa.c +15 -54
- data/ext/openssl/ossl_pkey_ec.c +180 -238
- data/ext/openssl/ossl_pkey_rsa.c +56 -103
- data/ext/openssl/ossl_provider.c +0 -5
- data/ext/openssl/ossl_rand.c +7 -14
- data/ext/openssl/ossl_ssl.c +535 -384
- data/ext/openssl/ossl_ssl.h +8 -8
- data/ext/openssl/ossl_ssl_session.c +93 -97
- data/ext/openssl/ossl_ts.c +78 -124
- data/ext/openssl/ossl_x509.c +9 -28
- data/ext/openssl/ossl_x509attr.c +33 -54
- data/ext/openssl/ossl_x509cert.c +70 -101
- data/ext/openssl/ossl_x509crl.c +78 -89
- data/ext/openssl/ossl_x509ext.c +43 -64
- data/ext/openssl/ossl_x509name.c +64 -90
- data/ext/openssl/ossl_x509req.c +55 -62
- data/ext/openssl/ossl_x509revoked.c +28 -42
- data/ext/openssl/ossl_x509store.c +36 -54
- data/lib/openssl/buffering.rb +30 -24
- data/lib/openssl/digest.rb +1 -1
- data/lib/openssl/pkey.rb +71 -49
- data/lib/openssl/ssl.rb +12 -79
- data/lib/openssl/version.rb +2 -1
- data/lib/openssl/x509.rb +9 -0
- data/lib/openssl.rb +9 -6
- metadata +1 -3
- data/ext/openssl/openssl_missing.c +0 -41
- data/lib/openssl/asn1.rb +0 -188
data/ext/openssl/ossl_x509.c
CHANGED
|
@@ -13,7 +13,8 @@ VALUE mX509;
|
|
|
13
13
|
|
|
14
14
|
#define DefX509Const(x) rb_define_const(mX509, #x, INT2NUM(X509_##x))
|
|
15
15
|
#define DefX509Default(x,i) \
|
|
16
|
-
|
|
16
|
+
rb_define_const(mX509, "DEFAULT_" #x, \
|
|
17
|
+
rb_obj_freeze(rb_str_new_cstr(X509_get_default_##i())))
|
|
17
18
|
|
|
18
19
|
ASN1_TIME *
|
|
19
20
|
ossl_x509_time_adjust(ASN1_TIME *s, VALUE time)
|
|
@@ -29,10 +30,6 @@ ossl_x509_time_adjust(ASN1_TIME *s, VALUE time)
|
|
|
29
30
|
void
|
|
30
31
|
Init_ossl_x509(void)
|
|
31
32
|
{
|
|
32
|
-
#if 0
|
|
33
|
-
mOSSL = rb_define_module("OpenSSL");
|
|
34
|
-
#endif
|
|
35
|
-
|
|
36
33
|
mX509 = rb_define_module_under(mOSSL, "X509");
|
|
37
34
|
|
|
38
35
|
Init_ossl_x509attr();
|
|
@@ -48,9 +45,7 @@ Init_ossl_x509(void)
|
|
|
48
45
|
|
|
49
46
|
/* Certificate verification error code */
|
|
50
47
|
DefX509Const(V_OK);
|
|
51
|
-
#if defined(X509_V_ERR_UNSPECIFIED) /* 1.0.1r, 1.0.2f, 1.1.0 */
|
|
52
48
|
DefX509Const(V_ERR_UNSPECIFIED);
|
|
53
|
-
#endif
|
|
54
49
|
DefX509Const(V_ERR_UNABLE_TO_GET_ISSUER_CERT);
|
|
55
50
|
DefX509Const(V_ERR_UNABLE_TO_GET_CRL);
|
|
56
51
|
DefX509Const(V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE);
|
|
@@ -104,10 +99,10 @@ Init_ossl_x509(void)
|
|
|
104
99
|
DefX509Const(V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX);
|
|
105
100
|
DefX509Const(V_ERR_UNSUPPORTED_NAME_SYNTAX);
|
|
106
101
|
DefX509Const(V_ERR_CRL_PATH_VALIDATION_ERROR);
|
|
107
|
-
#if defined(X509_V_ERR_PATH_LOOP)
|
|
102
|
+
#if defined(X509_V_ERR_PATH_LOOP) /* OpenSSL 1.1.0, missing in LibreSSL */
|
|
108
103
|
DefX509Const(V_ERR_PATH_LOOP);
|
|
109
104
|
#endif
|
|
110
|
-
#if defined(X509_V_ERR_SUITE_B_INVALID_VERSION)
|
|
105
|
+
#if defined(X509_V_ERR_SUITE_B_INVALID_VERSION) /* OpenSSL 1.1.0, missing in LibreSSL */
|
|
111
106
|
DefX509Const(V_ERR_SUITE_B_INVALID_VERSION);
|
|
112
107
|
DefX509Const(V_ERR_SUITE_B_INVALID_ALGORITHM);
|
|
113
108
|
DefX509Const(V_ERR_SUITE_B_INVALID_CURVE);
|
|
@@ -118,27 +113,21 @@ Init_ossl_x509(void)
|
|
|
118
113
|
DefX509Const(V_ERR_HOSTNAME_MISMATCH);
|
|
119
114
|
DefX509Const(V_ERR_EMAIL_MISMATCH);
|
|
120
115
|
DefX509Const(V_ERR_IP_ADDRESS_MISMATCH);
|
|
121
|
-
#if defined(X509_V_ERR_DANE_NO_MATCH)
|
|
116
|
+
#if defined(X509_V_ERR_DANE_NO_MATCH) /* OpenSSL 1.1.0, missing in LibreSSL */
|
|
122
117
|
DefX509Const(V_ERR_DANE_NO_MATCH);
|
|
123
118
|
#endif
|
|
124
|
-
#if defined(X509_V_ERR_EE_KEY_TOO_SMALL)
|
|
125
119
|
DefX509Const(V_ERR_EE_KEY_TOO_SMALL);
|
|
126
120
|
DefX509Const(V_ERR_CA_KEY_TOO_SMALL);
|
|
127
121
|
DefX509Const(V_ERR_CA_MD_TOO_WEAK);
|
|
128
|
-
#endif
|
|
129
|
-
#if defined(X509_V_ERR_INVALID_CALL)
|
|
130
122
|
DefX509Const(V_ERR_INVALID_CALL);
|
|
131
|
-
#endif
|
|
132
|
-
#if defined(X509_V_ERR_STORE_LOOKUP)
|
|
133
123
|
DefX509Const(V_ERR_STORE_LOOKUP);
|
|
134
|
-
#
|
|
135
|
-
#if defined(X509_V_ERR_NO_VALID_SCTS)
|
|
124
|
+
#if defined(X509_V_ERR_NO_VALID_SCTS) /* OpenSSL 1.1.0, missing in LibreSSL */
|
|
136
125
|
DefX509Const(V_ERR_NO_VALID_SCTS);
|
|
137
126
|
#endif
|
|
138
|
-
#if defined(X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION)
|
|
127
|
+
#if defined(X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION) /* OpenSSL 1.1.0, missing in LibreSSL */
|
|
139
128
|
DefX509Const(V_ERR_PROXY_SUBJECT_NAME_VIOLATION);
|
|
140
129
|
#endif
|
|
141
|
-
#if defined(X509_V_ERR_OCSP_VERIFY_NEEDED)
|
|
130
|
+
#if defined(X509_V_ERR_OCSP_VERIFY_NEEDED) /* OpenSSL 1.1.1, missing in LibreSSL */
|
|
142
131
|
DefX509Const(V_ERR_OCSP_VERIFY_NEEDED);
|
|
143
132
|
DefX509Const(V_ERR_OCSP_VERIFY_FAILED);
|
|
144
133
|
DefX509Const(V_ERR_OCSP_CERT_UNKNOWN);
|
|
@@ -189,17 +178,13 @@ Init_ossl_x509(void)
|
|
|
189
178
|
* certificate chain, search the Store first for the issuer certificate.
|
|
190
179
|
* Enabled by default in OpenSSL >= 1.1.0. */
|
|
191
180
|
DefX509Const(V_FLAG_TRUSTED_FIRST);
|
|
192
|
-
#if defined(X509_V_FLAG_SUITEB_128_LOS_ONLY)
|
|
181
|
+
#if defined(X509_V_FLAG_SUITEB_128_LOS_ONLY) /* OpenSSL 1.1.0, missing in LibreSSL */
|
|
193
182
|
/* Set by Store#flags= and StoreContext#flags=.
|
|
194
183
|
* Enables Suite B 128 bit only mode. */
|
|
195
184
|
DefX509Const(V_FLAG_SUITEB_128_LOS_ONLY);
|
|
196
|
-
#endif
|
|
197
|
-
#if defined(X509_V_FLAG_SUITEB_192_LOS)
|
|
198
185
|
/* Set by Store#flags= and StoreContext#flags=.
|
|
199
186
|
* Enables Suite B 192 bit only mode. */
|
|
200
187
|
DefX509Const(V_FLAG_SUITEB_192_LOS);
|
|
201
|
-
#endif
|
|
202
|
-
#if defined(X509_V_FLAG_SUITEB_128_LOS)
|
|
203
188
|
/* Set by Store#flags= and StoreContext#flags=.
|
|
204
189
|
* Enables Suite B 128 bit mode allowing 192 bit algorithms. */
|
|
205
190
|
DefX509Const(V_FLAG_SUITEB_128_LOS);
|
|
@@ -207,17 +192,13 @@ Init_ossl_x509(void)
|
|
|
207
192
|
/* Set by Store#flags= and StoreContext#flags=.
|
|
208
193
|
* Allows partial chains if at least one certificate is in trusted store. */
|
|
209
194
|
DefX509Const(V_FLAG_PARTIAL_CHAIN);
|
|
210
|
-
#if defined(X509_V_FLAG_NO_ALT_CHAINS)
|
|
211
195
|
/* Set by Store#flags= and StoreContext#flags=. Suppresses searching for
|
|
212
196
|
* a alternative chain. No effect in OpenSSL >= 1.1.0. */
|
|
213
197
|
DefX509Const(V_FLAG_NO_ALT_CHAINS);
|
|
214
|
-
#endif
|
|
215
|
-
#if defined(X509_V_FLAG_NO_CHECK_TIME)
|
|
216
198
|
/* Set by Store#flags= and StoreContext#flags=. Suppresses checking the
|
|
217
199
|
* validity period of certificates and CRLs. No effect when the current
|
|
218
200
|
* time is explicitly set by Store#time= or StoreContext#time=. */
|
|
219
201
|
DefX509Const(V_FLAG_NO_CHECK_TIME);
|
|
220
|
-
#endif
|
|
221
202
|
|
|
222
203
|
/* Set by Store#purpose=. SSL/TLS client. */
|
|
223
204
|
DefX509Const(PURPOSE_SSL_CLIENT);
|
data/ext/openssl/ossl_x509attr.c
CHANGED
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
TypedData_Wrap_Struct((klass), &ossl_x509attr_type, 0)
|
|
14
14
|
#define SetX509Attr(obj, attr) do { \
|
|
15
15
|
if (!(attr)) { \
|
|
16
|
-
|
|
16
|
+
ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
|
|
17
17
|
} \
|
|
18
18
|
RTYPEDDATA_DATA(obj) = (attr); \
|
|
19
19
|
} while (0)
|
|
20
20
|
#define GetX509Attr(obj, attr) do { \
|
|
21
21
|
TypedData_Get_Struct((obj), X509_ATTRIBUTE, &ossl_x509attr_type, (attr)); \
|
|
22
22
|
if (!(attr)) { \
|
|
23
|
-
|
|
23
|
+
ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
|
|
24
24
|
} \
|
|
25
25
|
} while (0)
|
|
26
26
|
|
|
@@ -39,7 +39,7 @@ ossl_x509attr_free(void *ptr)
|
|
|
39
39
|
static const rb_data_type_t ossl_x509attr_type = {
|
|
40
40
|
"OpenSSL/X509/ATTRIBUTE",
|
|
41
41
|
{
|
|
42
|
-
|
|
42
|
+
0, ossl_x509attr_free,
|
|
43
43
|
},
|
|
44
44
|
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
|
|
45
45
|
};
|
|
@@ -54,15 +54,10 @@ ossl_x509attr_new(const X509_ATTRIBUTE *attr)
|
|
|
54
54
|
VALUE obj;
|
|
55
55
|
|
|
56
56
|
obj = NewX509Attr(cX509Attr);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
new = X509_ATTRIBUTE_dup((X509_ATTRIBUTE *)attr);
|
|
62
|
-
}
|
|
63
|
-
if (!new) {
|
|
64
|
-
ossl_raise(eX509AttrError, NULL);
|
|
65
|
-
}
|
|
57
|
+
/* OpenSSL 1.1.1 takes a non-const pointer */
|
|
58
|
+
new = X509_ATTRIBUTE_dup((X509_ATTRIBUTE *)attr);
|
|
59
|
+
if (!new)
|
|
60
|
+
ossl_raise(eX509AttrError, "X509_ATTRIBUTE_dup");
|
|
66
61
|
SetX509Attr(obj, new);
|
|
67
62
|
|
|
68
63
|
return obj;
|
|
@@ -89,7 +84,7 @@ ossl_x509attr_alloc(VALUE klass)
|
|
|
89
84
|
|
|
90
85
|
obj = NewX509Attr(klass);
|
|
91
86
|
if (!(attr = X509_ATTRIBUTE_new()))
|
|
92
|
-
|
|
87
|
+
ossl_raise(eX509AttrError, NULL);
|
|
93
88
|
SetX509Attr(obj, attr);
|
|
94
89
|
|
|
95
90
|
return obj;
|
|
@@ -108,15 +103,15 @@ ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
108
103
|
|
|
109
104
|
GetX509Attr(self, attr);
|
|
110
105
|
if(rb_scan_args(argc, argv, "11", &oid, &value) == 1){
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
106
|
+
oid = ossl_to_der_if_possible(oid);
|
|
107
|
+
StringValue(oid);
|
|
108
|
+
p = (unsigned char *)RSTRING_PTR(oid);
|
|
109
|
+
x = d2i_X509_ATTRIBUTE(&attr, &p, RSTRING_LEN(oid));
|
|
110
|
+
DATA_PTR(self) = attr;
|
|
111
|
+
if(!x){
|
|
112
|
+
ossl_raise(eX509AttrError, NULL);
|
|
113
|
+
}
|
|
114
|
+
return self;
|
|
120
115
|
}
|
|
121
116
|
rb_funcall(self, rb_intern("oid="), 1, oid);
|
|
122
117
|
rb_funcall(self, rb_intern("value="), 1, value);
|
|
@@ -124,6 +119,7 @@ ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
124
119
|
return self;
|
|
125
120
|
}
|
|
126
121
|
|
|
122
|
+
/* :nodoc: */
|
|
127
123
|
static VALUE
|
|
128
124
|
ossl_x509attr_initialize_copy(VALUE self, VALUE other)
|
|
129
125
|
{
|
|
@@ -135,7 +131,7 @@ ossl_x509attr_initialize_copy(VALUE self, VALUE other)
|
|
|
135
131
|
|
|
136
132
|
attr_new = X509_ATTRIBUTE_dup(attr_other);
|
|
137
133
|
if (!attr_new)
|
|
138
|
-
|
|
134
|
+
ossl_raise(eX509AttrError, "X509_ATTRIBUTE_dup");
|
|
139
135
|
|
|
140
136
|
SetX509Attr(self, attr_new);
|
|
141
137
|
X509_ATTRIBUTE_free(attr);
|
|
@@ -159,8 +155,8 @@ ossl_x509attr_set_oid(VALUE self, VALUE oid)
|
|
|
159
155
|
obj = OBJ_txt2obj(s, 0);
|
|
160
156
|
if(!obj) ossl_raise(eX509AttrError, NULL);
|
|
161
157
|
if (!X509_ATTRIBUTE_set1_object(attr, obj)) {
|
|
162
|
-
|
|
163
|
-
|
|
158
|
+
ASN1_OBJECT_free(obj);
|
|
159
|
+
ossl_raise(eX509AttrError, "X509_ATTRIBUTE_set1_object");
|
|
164
160
|
}
|
|
165
161
|
ASN1_OBJECT_free(obj);
|
|
166
162
|
|
|
@@ -169,29 +165,18 @@ ossl_x509attr_set_oid(VALUE self, VALUE oid)
|
|
|
169
165
|
|
|
170
166
|
/*
|
|
171
167
|
* call-seq:
|
|
172
|
-
* attr.oid
|
|
168
|
+
* attr.oid -> string
|
|
169
|
+
*
|
|
170
|
+
* Returns the OID of the attribute. Returns the short name or the dotted
|
|
171
|
+
* decimal notation.
|
|
173
172
|
*/
|
|
174
173
|
static VALUE
|
|
175
174
|
ossl_x509attr_get_oid(VALUE self)
|
|
176
175
|
{
|
|
177
176
|
X509_ATTRIBUTE *attr;
|
|
178
|
-
const ASN1_OBJECT *oid;
|
|
179
|
-
BIO *out;
|
|
180
|
-
VALUE ret;
|
|
181
|
-
int nid;
|
|
182
177
|
|
|
183
178
|
GetX509Attr(self, attr);
|
|
184
|
-
|
|
185
|
-
if ((nid = OBJ_obj2nid(oid)) != NID_undef)
|
|
186
|
-
ret = rb_str_new2(OBJ_nid2sn(nid));
|
|
187
|
-
else{
|
|
188
|
-
if (!(out = BIO_new(BIO_s_mem())))
|
|
189
|
-
ossl_raise(eX509AttrError, NULL);
|
|
190
|
-
i2a_ASN1_OBJECT(out, (ASN1_OBJECT *)oid);
|
|
191
|
-
ret = ossl_membio2str(out);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return ret;
|
|
179
|
+
return ossl_asn1obj_to_string(X509_ATTRIBUTE_get0_object(attr));
|
|
195
180
|
}
|
|
196
181
|
|
|
197
182
|
/*
|
|
@@ -252,21 +237,21 @@ ossl_x509attr_get_value(VALUE self)
|
|
|
252
237
|
GetX509Attr(self, attr);
|
|
253
238
|
/* there is no X509_ATTRIBUTE_get0_set() :( */
|
|
254
239
|
if (!(sk = sk_ASN1_TYPE_new_null()))
|
|
255
|
-
|
|
240
|
+
ossl_raise(eX509AttrError, "sk_new");
|
|
256
241
|
|
|
257
242
|
count = X509_ATTRIBUTE_count(attr);
|
|
258
243
|
for (i = 0; i < count; i++)
|
|
259
244
|
sk_ASN1_TYPE_push(sk, (ASN1_TYPE *)X509_ATTRIBUTE_get0_type(attr, i));
|
|
260
245
|
|
|
261
246
|
if ((len = i2d_ASN1_SET_ANY(sk, NULL)) <= 0) {
|
|
262
|
-
|
|
263
|
-
|
|
247
|
+
sk_ASN1_TYPE_free(sk);
|
|
248
|
+
ossl_raise(eX509AttrError, NULL);
|
|
264
249
|
}
|
|
265
250
|
str = rb_str_new(0, len);
|
|
266
251
|
p = (unsigned char *)RSTRING_PTR(str);
|
|
267
252
|
if (i2d_ASN1_SET_ANY(sk, &p) <= 0) {
|
|
268
|
-
|
|
269
|
-
|
|
253
|
+
sk_ASN1_TYPE_free(sk);
|
|
254
|
+
ossl_raise(eX509AttrError, NULL);
|
|
270
255
|
}
|
|
271
256
|
ossl_str_adjust(str, p);
|
|
272
257
|
sk_ASN1_TYPE_free(sk);
|
|
@@ -288,11 +273,11 @@ ossl_x509attr_to_der(VALUE self)
|
|
|
288
273
|
|
|
289
274
|
GetX509Attr(self, attr);
|
|
290
275
|
if((len = i2d_X509_ATTRIBUTE(attr, NULL)) <= 0)
|
|
291
|
-
|
|
276
|
+
ossl_raise(eX509AttrError, NULL);
|
|
292
277
|
str = rb_str_new(0, len);
|
|
293
278
|
p = (unsigned char *)RSTRING_PTR(str);
|
|
294
279
|
if(i2d_X509_ATTRIBUTE(attr, &p) <= 0)
|
|
295
|
-
|
|
280
|
+
ossl_raise(eX509AttrError, NULL);
|
|
296
281
|
ossl_str_adjust(str, p);
|
|
297
282
|
|
|
298
283
|
return str;
|
|
@@ -304,12 +289,6 @@ ossl_x509attr_to_der(VALUE self)
|
|
|
304
289
|
void
|
|
305
290
|
Init_ossl_x509attr(void)
|
|
306
291
|
{
|
|
307
|
-
#if 0
|
|
308
|
-
mOSSL = rb_define_module("OpenSSL");
|
|
309
|
-
eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
|
|
310
|
-
mX509 = rb_define_module_under(mOSSL, "X509");
|
|
311
|
-
#endif
|
|
312
|
-
|
|
313
292
|
eX509AttrError = rb_define_class_under(mX509, "AttributeError", eOSSLError);
|
|
314
293
|
|
|
315
294
|
cX509Attr = rb_define_class_under(mX509, "Attribute", rb_cObject);
|