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
@@ -42,7 +42,7 @@ ossl_pkcs12_free(void *ptr)
42
42
  static const rb_data_type_t ossl_pkcs12_type = {
43
43
  "OpenSSL/PKCS12",
44
44
  {
45
- 0, ossl_pkcs12_free,
45
+ 0, ossl_pkcs12_free,
46
46
  },
47
47
  0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
48
48
  };
@@ -60,6 +60,7 @@ ossl_pkcs12_s_allocate(VALUE klass)
60
60
  return obj;
61
61
  }
62
62
 
63
+ /* :nodoc: */
63
64
  static VALUE
64
65
  ossl_pkcs12_initialize_copy(VALUE self, VALUE other)
65
66
  {
@@ -71,7 +72,7 @@ ossl_pkcs12_initialize_copy(VALUE self, VALUE other)
71
72
 
72
73
  p12_new = ASN1_dup((i2d_of_void *)i2d_PKCS12, (d2i_of_void *)d2i_PKCS12, (char *)p12);
73
74
  if (!p12_new)
74
- ossl_raise(ePKCS12Error, "ASN1_dup");
75
+ ossl_raise(ePKCS12Error, "ASN1_dup");
75
76
 
76
77
  SetPKCS12(self, p12_new);
77
78
  PKCS12_free(p12_old);
@@ -121,11 +122,11 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
121
122
  /* TODO: make a VALUE to nid function */
122
123
  if (!NIL_P(key_nid)) {
123
124
  if ((nkey = OBJ_txt2nid(StringValueCStr(key_nid))) == NID_undef)
124
- ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, key_nid);
125
+ ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, key_nid);
125
126
  }
126
127
  if (!NIL_P(cert_nid)) {
127
128
  if ((ncert = OBJ_txt2nid(StringValueCStr(cert_nid))) == NID_undef)
128
- ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, cert_nid);
129
+ ossl_raise(rb_eArgError, "Unknown PBE algorithm %"PRIsVALUE, cert_nid);
129
130
  }
130
131
  if (!NIL_P(key_iter))
131
132
  kiter = NUM2INT(key_iter);
@@ -134,9 +135,15 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
134
135
  if (!NIL_P(keytype))
135
136
  ktype = NUM2INT(keytype);
136
137
 
138
+ #if defined(OPENSSL_IS_AWSLC)
139
+ if (ktype != 0) {
140
+ ossl_raise(rb_eArgError, "Unknown key usage type %"PRIsVALUE, INT2NUM(ktype));
141
+ }
142
+ #else
137
143
  if (ktype != 0 && ktype != KEY_SIG && ktype != KEY_EX) {
138
144
  ossl_raise(rb_eArgError, "Unknown key usage type %"PRIsVALUE, INT2NUM(ktype));
139
145
  }
146
+ #endif
140
147
 
141
148
  obj = NewPKCS12(cPKCS12);
142
149
  x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
@@ -154,9 +161,9 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
154
161
  }
155
162
 
156
163
  static VALUE
157
- ossl_pkey_new_i(VALUE arg)
164
+ ossl_pkey_wrap_i(VALUE arg)
158
165
  {
159
- return ossl_pkey_new((EVP_PKEY *)arg);
166
+ return ossl_pkey_wrap((EVP_PKEY *)arg);
160
167
  }
161
168
 
162
169
  static VALUE
@@ -201,23 +208,19 @@ ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self)
201
208
  BIO_free(in);
202
209
 
203
210
  pkey = cert = ca = Qnil;
204
- /* OpenSSL's bug; PKCS12_parse() puts errors even if it succeeds.
205
- * Fixed in OpenSSL 1.0.0t, 1.0.1p, 1.0.2d */
206
- ERR_set_mark();
207
211
  if(!PKCS12_parse(pkcs, passphrase, &key, &x509, &x509s))
208
- ossl_raise(ePKCS12Error, "PKCS12_parse");
209
- ERR_pop_to_mark();
212
+ ossl_raise(ePKCS12Error, "PKCS12_parse");
210
213
  if (key) {
211
- pkey = rb_protect(ossl_pkey_new_i, (VALUE)key, &st);
212
- if (st) goto err;
214
+ pkey = rb_protect(ossl_pkey_wrap_i, (VALUE)key, &st);
215
+ if (st) goto err;
213
216
  }
214
217
  if (x509) {
215
- cert = rb_protect(ossl_x509_new_i, (VALUE)x509, &st);
216
- if (st) goto err;
218
+ cert = rb_protect(ossl_x509_new_i, (VALUE)x509, &st);
219
+ if (st) goto err;
217
220
  }
218
221
  if (x509s) {
219
- ca = rb_protect(ossl_x509_sk2ary_i, (VALUE)x509s, &st);
220
- if (st) goto err;
222
+ ca = rb_protect(ossl_x509_sk2ary_i, (VALUE)x509s, &st);
223
+ if (st) goto err;
221
224
  }
222
225
 
223
226
  err:
@@ -241,11 +244,11 @@ ossl_pkcs12_to_der(VALUE self)
241
244
 
242
245
  GetPKCS12(self, p12);
243
246
  if((len = i2d_PKCS12(p12, NULL)) <= 0)
244
- ossl_raise(ePKCS12Error, NULL);
247
+ ossl_raise(ePKCS12Error, NULL);
245
248
  str = rb_str_new(0, len);
246
249
  p = (unsigned char *)RSTRING_PTR(str);
247
250
  if(i2d_PKCS12(p12, &p) <= 0)
248
- ossl_raise(ePKCS12Error, NULL);
251
+ ossl_raise(ePKCS12Error, NULL);
249
252
  ossl_str_adjust(str, p);
250
253
 
251
254
  return str;
@@ -268,7 +271,7 @@ static VALUE
268
271
  pkcs12_set_mac(int argc, VALUE *argv, VALUE self)
269
272
  {
270
273
  PKCS12 *p12;
271
- VALUE pass, salt, iter, md_name;
274
+ VALUE pass, salt, iter, md_name, md_holder = Qnil;
272
275
  int iter_i = 0;
273
276
  const EVP_MD *md_type = NULL;
274
277
 
@@ -282,7 +285,7 @@ pkcs12_set_mac(int argc, VALUE *argv, VALUE self)
282
285
  if (!NIL_P(iter))
283
286
  iter_i = NUM2INT(iter);
284
287
  if (!NIL_P(md_name))
285
- md_type = ossl_evp_get_digestbyname(md_name);
288
+ md_type = ossl_evp_md_fetch(md_name, &md_holder);
286
289
 
287
290
  if (!PKCS12_set_mac(p12, RSTRING_PTR(pass), RSTRING_LENINT(pass),
288
291
  !NIL_P(salt) ? (unsigned char *)RSTRING_PTR(salt) : NULL,
@@ -297,11 +300,6 @@ void
297
300
  Init_ossl_pkcs12(void)
298
301
  {
299
302
  #undef rb_intern
300
- #if 0
301
- mOSSL = rb_define_module("OpenSSL");
302
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
303
- #endif
304
-
305
303
  /*
306
304
  * Defines a file format commonly used to store private keys with
307
305
  * accompanying public key certificates, protected with a password-based
@@ -320,7 +318,9 @@ Init_ossl_pkcs12(void)
320
318
  rb_define_method(cPKCS12, "to_der", ossl_pkcs12_to_der, 0);
321
319
  rb_define_method(cPKCS12, "set_mac", pkcs12_set_mac, -1);
322
320
 
321
+ #if !defined(OPENSSL_IS_AWSLC)
323
322
  /* MSIE specific PKCS12 key usage extensions */
324
323
  rb_define_const(cPKCS12, "KEY_EX", INT2NUM(KEY_EX));
325
324
  rb_define_const(cPKCS12, "KEY_SIG", INT2NUM(KEY_SIG));
325
+ #endif
326
326
  }