openssl 3.3.2 → 4.0.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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +3 -0
  3. data/History.md +85 -0
  4. data/README.md +12 -11
  5. data/ext/openssl/extconf.rb +30 -69
  6. data/ext/openssl/openssl_missing.h +0 -206
  7. data/ext/openssl/ossl.c +280 -301
  8. data/ext/openssl/ossl.h +15 -10
  9. data/ext/openssl/ossl_asn1.c +598 -406
  10. data/ext/openssl/ossl_asn1.h +15 -1
  11. data/ext/openssl/ossl_bio.c +3 -3
  12. data/ext/openssl/ossl_bn.c +286 -291
  13. data/ext/openssl/ossl_cipher.c +252 -203
  14. data/ext/openssl/ossl_cipher.h +10 -1
  15. data/ext/openssl/ossl_config.c +1 -6
  16. data/ext/openssl/ossl_digest.c +74 -43
  17. data/ext/openssl/ossl_digest.h +9 -1
  18. data/ext/openssl/ossl_engine.c +39 -103
  19. data/ext/openssl/ossl_hmac.c +30 -36
  20. data/ext/openssl/ossl_kdf.c +42 -53
  21. data/ext/openssl/ossl_ns_spki.c +31 -37
  22. data/ext/openssl/ossl_ocsp.c +214 -241
  23. data/ext/openssl/ossl_pkcs12.c +26 -26
  24. data/ext/openssl/ossl_pkcs7.c +175 -145
  25. data/ext/openssl/ossl_pkey.c +162 -178
  26. data/ext/openssl/ossl_pkey.h +99 -99
  27. data/ext/openssl/ossl_pkey_dh.c +31 -68
  28. data/ext/openssl/ossl_pkey_dsa.c +15 -54
  29. data/ext/openssl/ossl_pkey_ec.c +179 -237
  30. data/ext/openssl/ossl_pkey_rsa.c +56 -103
  31. data/ext/openssl/ossl_provider.c +0 -7
  32. data/ext/openssl/ossl_rand.c +7 -14
  33. data/ext/openssl/ossl_ssl.c +478 -353
  34. data/ext/openssl/ossl_ssl.h +8 -8
  35. data/ext/openssl/ossl_ssl_session.c +93 -97
  36. data/ext/openssl/ossl_ts.c +81 -127
  37. data/ext/openssl/ossl_x509.c +9 -28
  38. data/ext/openssl/ossl_x509attr.c +33 -54
  39. data/ext/openssl/ossl_x509cert.c +69 -100
  40. data/ext/openssl/ossl_x509crl.c +78 -89
  41. data/ext/openssl/ossl_x509ext.c +45 -66
  42. data/ext/openssl/ossl_x509name.c +63 -88
  43. data/ext/openssl/ossl_x509req.c +55 -62
  44. data/ext/openssl/ossl_x509revoked.c +27 -41
  45. data/ext/openssl/ossl_x509store.c +38 -56
  46. data/lib/openssl/buffering.rb +30 -24
  47. data/lib/openssl/digest.rb +1 -1
  48. data/lib/openssl/pkey.rb +71 -49
  49. data/lib/openssl/ssl.rb +12 -79
  50. data/lib/openssl/version.rb +2 -1
  51. data/lib/openssl/x509.rb +9 -0
  52. data/lib/openssl.rb +9 -6
  53. metadata +1 -3
  54. data/ext/openssl/openssl_missing.c +0 -40
  55. data/lib/openssl/asn1.rb +0 -188
@@ -11,17 +11,17 @@
11
11
  #define _OSSL_SSL_H_
12
12
 
13
13
  #define GetSSL(obj, ssl) do { \
14
- TypedData_Get_Struct((obj), SSL, &ossl_ssl_type, (ssl)); \
15
- if (!(ssl)) { \
16
- ossl_raise(rb_eRuntimeError, "SSL is not initialized"); \
17
- } \
14
+ TypedData_Get_Struct((obj), SSL, &ossl_ssl_type, (ssl)); \
15
+ if (!(ssl)) { \
16
+ ossl_raise(rb_eRuntimeError, "SSL is not initialized"); \
17
+ } \
18
18
  } while (0)
19
19
 
20
20
  #define GetSSLSession(obj, sess) do { \
21
- TypedData_Get_Struct((obj), SSL_SESSION, &ossl_ssl_session_type, (sess)); \
22
- if (!(sess)) { \
23
- ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
24
- } \
21
+ TypedData_Get_Struct((obj), SSL_SESSION, &ossl_ssl_session_type, (sess)); \
22
+ if (!(sess)) { \
23
+ ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
24
+ } \
25
25
  } while (0)
26
26
 
27
27
  extern const rb_data_type_t ossl_ssl_type;
@@ -17,14 +17,14 @@ ossl_ssl_session_free(void *ptr)
17
17
  const rb_data_type_t ossl_ssl_session_type = {
18
18
  "OpenSSL/SSL/Session",
19
19
  {
20
- 0, ossl_ssl_session_free,
20
+ 0, ossl_ssl_session_free,
21
21
  },
22
22
  0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
23
23
  };
24
24
 
25
25
  static VALUE ossl_ssl_session_alloc(VALUE klass)
26
26
  {
27
- return TypedData_Wrap_Struct(klass, &ossl_ssl_session_type, NULL);
27
+ return TypedData_Wrap_Struct(klass, &ossl_ssl_session_type, NULL);
28
28
  }
29
29
 
30
30
  /*
@@ -69,6 +69,7 @@ ossl_ssl_session_initialize(VALUE self, VALUE arg1)
69
69
  return self;
70
70
  }
71
71
 
72
+ /* :nodoc: */
72
73
  static VALUE
73
74
  ossl_ssl_session_initialize_copy(VALUE self, VALUE other)
74
75
  {
@@ -79,9 +80,9 @@ ossl_ssl_session_initialize_copy(VALUE self, VALUE other)
79
80
  GetSSLSession(other, sess_other);
80
81
 
81
82
  sess_new = ASN1_dup((i2d_of_void *)i2d_SSL_SESSION, (d2i_of_void *)d2i_SSL_SESSION,
82
- (char *)sess_other);
83
+ (char *)sess_other);
83
84
  if (!sess_new)
84
- ossl_raise(eSSLSession, "ASN1_dup");
85
+ ossl_raise(eSSLSession, "ASN1_dup");
85
86
 
86
87
  RTYPEDDATA_DATA(self) = sess_new;
87
88
  SSL_SESSION_free(sess);
@@ -98,9 +99,9 @@ ossl_SSL_SESSION_cmp(const SSL_SESSION *a, const SSL_SESSION *b)
98
99
  const unsigned char *b_sid = SSL_SESSION_get_id(b, &b_len);
99
100
 
100
101
  if (SSL_SESSION_get_protocol_version(a) != SSL_SESSION_get_protocol_version(b))
101
- return 1;
102
+ return 1;
102
103
  if (a_len != b_len)
103
- return 1;
104
+ return 1;
104
105
 
105
106
  return CRYPTO_memcmp(a_sid, b_sid, a_len);
106
107
  }
@@ -113,15 +114,15 @@ ossl_SSL_SESSION_cmp(const SSL_SESSION *a, const SSL_SESSION *b)
113
114
  */
114
115
  static VALUE ossl_ssl_session_eq(VALUE val1, VALUE val2)
115
116
  {
116
- SSL_SESSION *ctx1, *ctx2;
117
+ SSL_SESSION *ctx1, *ctx2;
117
118
 
118
- GetSSLSession(val1, ctx1);
119
- GetSSLSession(val2, ctx2);
119
+ GetSSLSession(val1, ctx1);
120
+ GetSSLSession(val2, ctx2);
120
121
 
121
- switch (ossl_SSL_SESSION_cmp(ctx1, ctx2)) {
122
- case 0: return Qtrue;
123
- default: return Qfalse;
124
- }
122
+ switch (ossl_SSL_SESSION_cmp(ctx1, ctx2)) {
123
+ case 0: return Qtrue;
124
+ default: return Qfalse;
125
+ }
125
126
  }
126
127
 
127
128
  /*
@@ -139,7 +140,7 @@ ossl_ssl_session_get_time(VALUE self)
139
140
  GetSSLSession(self, ctx);
140
141
  t = SSL_SESSION_get_time(ctx);
141
142
  if (t == 0)
142
- return Qnil;
143
+ return Qnil;
143
144
 
144
145
  return rb_funcall(rb_cTime, rb_intern("at"), 1, LONG2NUM(t));
145
146
  }
@@ -174,16 +175,16 @@ ossl_ssl_session_get_timeout(VALUE self)
174
175
  */
175
176
  static VALUE ossl_ssl_session_set_time(VALUE self, VALUE time_v)
176
177
  {
177
- SSL_SESSION *ctx;
178
- long t;
179
-
180
- GetSSLSession(self, ctx);
181
- if (rb_obj_is_instance_of(time_v, rb_cTime)) {
182
- time_v = rb_funcall(time_v, rb_intern("to_i"), 0);
183
- }
184
- t = NUM2LONG(time_v);
185
- SSL_SESSION_set_time(ctx, t);
186
- return ossl_ssl_session_get_time(self);
178
+ SSL_SESSION *ctx;
179
+ long t;
180
+
181
+ GetSSLSession(self, ctx);
182
+ if (rb_obj_is_instance_of(time_v, rb_cTime)) {
183
+ time_v = rb_funcall(time_v, rb_intern("to_i"), 0);
184
+ }
185
+ t = NUM2LONG(time_v);
186
+ SSL_SESSION_set_time(ctx, t);
187
+ return ossl_ssl_session_get_time(self);
187
188
  }
188
189
 
189
190
  /*
@@ -194,13 +195,13 @@ static VALUE ossl_ssl_session_set_time(VALUE self, VALUE time_v)
194
195
  */
195
196
  static VALUE ossl_ssl_session_set_timeout(VALUE self, VALUE time_v)
196
197
  {
197
- SSL_SESSION *ctx;
198
- long t;
198
+ SSL_SESSION *ctx;
199
+ long t;
199
200
 
200
- GetSSLSession(self, ctx);
201
- t = NUM2LONG(time_v);
202
- SSL_SESSION_set_timeout(ctx, t);
203
- return ossl_ssl_session_get_timeout(self);
201
+ GetSSLSession(self, ctx);
202
+ t = NUM2LONG(time_v);
203
+ SSL_SESSION_set_timeout(ctx, t);
204
+ return ossl_ssl_session_get_timeout(self);
204
205
  }
205
206
 
206
207
  /*
@@ -208,18 +209,18 @@ static VALUE ossl_ssl_session_set_timeout(VALUE self, VALUE time_v)
208
209
  * session.id -> String
209
210
  *
210
211
  * Returns the Session ID.
211
- */
212
+ */
212
213
  static VALUE ossl_ssl_session_get_id(VALUE self)
213
214
  {
214
- SSL_SESSION *ctx;
215
- const unsigned char *p = NULL;
216
- unsigned int i = 0;
215
+ SSL_SESSION *ctx;
216
+ const unsigned char *p = NULL;
217
+ unsigned int i = 0;
217
218
 
218
- GetSSLSession(self, ctx);
219
+ GetSSLSession(self, ctx);
219
220
 
220
- p = SSL_SESSION_get_id(ctx, &i);
221
+ p = SSL_SESSION_get_id(ctx, &i);
221
222
 
222
- return rb_str_new((const char *) p, i);
223
+ return rb_str_new((const char *) p, i);
223
224
  }
224
225
 
225
226
  /*
@@ -230,22 +231,22 @@ static VALUE ossl_ssl_session_get_id(VALUE self)
230
231
  */
231
232
  static VALUE ossl_ssl_session_to_der(VALUE self)
232
233
  {
233
- SSL_SESSION *ctx;
234
- unsigned char *p;
235
- int len;
236
- VALUE str;
237
-
238
- GetSSLSession(self, ctx);
239
- len = i2d_SSL_SESSION(ctx, NULL);
240
- if (len <= 0) {
241
- ossl_raise(eSSLSession, "i2d_SSL_SESSION");
242
- }
243
-
244
- str = rb_str_new(0, len);
245
- p = (unsigned char *)RSTRING_PTR(str);
246
- i2d_SSL_SESSION(ctx, &p);
247
- ossl_str_adjust(str, p);
248
- return str;
234
+ SSL_SESSION *ctx;
235
+ unsigned char *p;
236
+ int len;
237
+ VALUE str;
238
+
239
+ GetSSLSession(self, ctx);
240
+ len = i2d_SSL_SESSION(ctx, NULL);
241
+ if (len <= 0) {
242
+ ossl_raise(eSSLSession, "i2d_SSL_SESSION");
243
+ }
244
+
245
+ str = rb_str_new(0, len);
246
+ p = (unsigned char *)RSTRING_PTR(str);
247
+ i2d_SSL_SESSION(ctx, &p);
248
+ ossl_str_adjust(str, p);
249
+ return str;
249
250
  }
250
251
 
251
252
  /*
@@ -256,22 +257,22 @@ static VALUE ossl_ssl_session_to_der(VALUE self)
256
257
  */
257
258
  static VALUE ossl_ssl_session_to_pem(VALUE self)
258
259
  {
259
- SSL_SESSION *ctx;
260
- BIO *out;
260
+ SSL_SESSION *ctx;
261
+ BIO *out;
261
262
 
262
- GetSSLSession(self, ctx);
263
+ GetSSLSession(self, ctx);
263
264
 
264
- if (!(out = BIO_new(BIO_s_mem()))) {
265
- ossl_raise(eSSLSession, "BIO_s_mem()");
266
- }
265
+ if (!(out = BIO_new(BIO_s_mem()))) {
266
+ ossl_raise(eSSLSession, "BIO_s_mem()");
267
+ }
267
268
 
268
- if (!PEM_write_bio_SSL_SESSION(out, ctx)) {
269
- BIO_free(out);
270
- ossl_raise(eSSLSession, "SSL_SESSION_print()");
271
- }
269
+ if (!PEM_write_bio_SSL_SESSION(out, ctx)) {
270
+ BIO_free(out);
271
+ ossl_raise(eSSLSession, "SSL_SESSION_print()");
272
+ }
272
273
 
273
274
 
274
- return ossl_membio2str(out);
275
+ return ossl_membio2str(out);
275
276
  }
276
277
 
277
278
 
@@ -283,49 +284,44 @@ static VALUE ossl_ssl_session_to_pem(VALUE self)
283
284
  */
284
285
  static VALUE ossl_ssl_session_to_text(VALUE self)
285
286
  {
286
- SSL_SESSION *ctx;
287
- BIO *out;
287
+ SSL_SESSION *ctx;
288
+ BIO *out;
288
289
 
289
- GetSSLSession(self, ctx);
290
+ GetSSLSession(self, ctx);
290
291
 
291
- if (!(out = BIO_new(BIO_s_mem()))) {
292
- ossl_raise(eSSLSession, "BIO_s_mem()");
293
- }
292
+ if (!(out = BIO_new(BIO_s_mem()))) {
293
+ ossl_raise(eSSLSession, "BIO_s_mem()");
294
+ }
294
295
 
295
- if (!SSL_SESSION_print(out, ctx)) {
296
- BIO_free(out);
297
- ossl_raise(eSSLSession, "SSL_SESSION_print()");
298
- }
296
+ if (!SSL_SESSION_print(out, ctx)) {
297
+ BIO_free(out);
298
+ ossl_raise(eSSLSession, "SSL_SESSION_print()");
299
+ }
299
300
 
300
- return ossl_membio2str(out);
301
+ return ossl_membio2str(out);
301
302
  }
302
303
 
303
304
  #endif /* !defined(OPENSSL_NO_SOCK) */
304
305
 
305
306
  void Init_ossl_ssl_session(void)
306
307
  {
307
- #if 0
308
- mOSSL = rb_define_module("OpenSSL");
309
- mSSL = rb_define_module_under(mOSSL, "SSL");
310
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
311
- #endif
312
308
  #ifndef OPENSSL_NO_SOCK
313
- cSSLSession = rb_define_class_under(mSSL, "Session", rb_cObject);
314
- eSSLSession = rb_define_class_under(cSSLSession, "SessionError", eOSSLError);
315
-
316
- rb_define_alloc_func(cSSLSession, ossl_ssl_session_alloc);
317
- rb_define_method(cSSLSession, "initialize", ossl_ssl_session_initialize, 1);
318
- rb_define_method(cSSLSession, "initialize_copy", ossl_ssl_session_initialize_copy, 1);
319
-
320
- rb_define_method(cSSLSession, "==", ossl_ssl_session_eq, 1);
321
-
322
- rb_define_method(cSSLSession, "time", ossl_ssl_session_get_time, 0);
323
- rb_define_method(cSSLSession, "time=", ossl_ssl_session_set_time, 1);
324
- rb_define_method(cSSLSession, "timeout", ossl_ssl_session_get_timeout, 0);
325
- rb_define_method(cSSLSession, "timeout=", ossl_ssl_session_set_timeout, 1);
326
- rb_define_method(cSSLSession, "id", ossl_ssl_session_get_id, 0);
327
- rb_define_method(cSSLSession, "to_der", ossl_ssl_session_to_der, 0);
328
- rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0);
329
- rb_define_method(cSSLSession, "to_text", ossl_ssl_session_to_text, 0);
309
+ cSSLSession = rb_define_class_under(mSSL, "Session", rb_cObject);
310
+ eSSLSession = rb_define_class_under(cSSLSession, "SessionError", eOSSLError);
311
+
312
+ rb_define_alloc_func(cSSLSession, ossl_ssl_session_alloc);
313
+ rb_define_method(cSSLSession, "initialize", ossl_ssl_session_initialize, 1);
314
+ rb_define_method(cSSLSession, "initialize_copy", ossl_ssl_session_initialize_copy, 1);
315
+
316
+ rb_define_method(cSSLSession, "==", ossl_ssl_session_eq, 1);
317
+
318
+ rb_define_method(cSSLSession, "time", ossl_ssl_session_get_time, 0);
319
+ rb_define_method(cSSLSession, "time=", ossl_ssl_session_set_time, 1);
320
+ rb_define_method(cSSLSession, "timeout", ossl_ssl_session_get_timeout, 0);
321
+ rb_define_method(cSSLSession, "timeout=", ossl_ssl_session_set_timeout, 1);
322
+ rb_define_method(cSSLSession, "id", ossl_ssl_session_get_id, 0);
323
+ rb_define_method(cSSLSession, "to_der", ossl_ssl_session_to_der, 0);
324
+ rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0);
325
+ rb_define_method(cSSLSession, "to_text", ossl_ssl_session_to_text, 0);
330
326
  #endif /* !defined(OPENSSL_NO_SOCK) */
331
327
  }