openssl 3.3.3 → 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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +3 -0
  3. data/History.md +81 -12
  4. data/README.md +12 -11
  5. data/ext/openssl/extconf.rb +29 -72
  6. data/ext/openssl/openssl_missing.h +0 -233
  7. data/ext/openssl/ossl.c +279 -300
  8. data/ext/openssl/ossl.h +13 -9
  9. data/ext/openssl/ossl_asn1.c +610 -423
  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 +27 -32
  22. data/ext/openssl/ossl_ocsp.c +209 -236
  23. data/ext/openssl/ossl_pkcs12.c +26 -26
  24. data/ext/openssl/ossl_pkcs7.c +176 -146
  25. data/ext/openssl/ossl_pkey.c +102 -158
  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 -5
  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 +79 -125
  37. data/ext/openssl/ossl_x509.c +9 -28
  38. data/ext/openssl/ossl_x509.h +6 -6
  39. data/ext/openssl/ossl_x509attr.c +35 -57
  40. data/ext/openssl/ossl_x509cert.c +73 -104
  41. data/ext/openssl/ossl_x509crl.c +80 -91
  42. data/ext/openssl/ossl_x509ext.c +45 -75
  43. data/ext/openssl/ossl_x509name.c +64 -91
  44. data/ext/openssl/ossl_x509req.c +57 -64
  45. data/ext/openssl/ossl_x509revoked.c +29 -44
  46. data/ext/openssl/ossl_x509store.c +41 -57
  47. data/lib/openssl/buffering.rb +30 -24
  48. data/lib/openssl/digest.rb +1 -1
  49. data/lib/openssl/pkey.rb +71 -49
  50. data/lib/openssl/ssl.rb +12 -79
  51. data/lib/openssl/version.rb +2 -1
  52. data/lib/openssl/x509.rb +9 -0
  53. data/lib/openssl.rb +9 -6
  54. metadata +2 -4
  55. data/ext/openssl/openssl_missing.c +0 -41
  56. data/lib/openssl/asn1.rb +0 -188
@@ -103,7 +103,7 @@ static const rb_data_type_t ossl_ts_resp_type = {
103
103
  static void
104
104
  ossl_ts_token_info_free(void *ptr)
105
105
  {
106
- TS_TST_INFO_free(ptr);
106
+ TS_TST_INFO_free(ptr);
107
107
  }
108
108
 
109
109
  static const rb_data_type_t ossl_ts_token_info_type = {
@@ -132,44 +132,10 @@ asn1_to_der(void *template, int (*i2d)(void *template, unsigned char **pp))
132
132
  return str;
133
133
  }
134
134
 
135
- static ASN1_OBJECT*
136
- obj_to_asn1obj(VALUE obj)
137
- {
138
- ASN1_OBJECT *a1obj;
139
-
140
- StringValue(obj);
141
- a1obj = OBJ_txt2obj(RSTRING_PTR(obj), 0);
142
- if(!a1obj) a1obj = OBJ_txt2obj(RSTRING_PTR(obj), 1);
143
- if(!a1obj) ossl_raise(eASN1Error, "invalid OBJECT ID");
144
-
145
- return a1obj;
146
- }
147
-
148
135
  static VALUE
149
136
  obj_to_asn1obj_i(VALUE obj)
150
137
  {
151
- return (VALUE)obj_to_asn1obj(obj);
152
- }
153
-
154
- static VALUE
155
- get_asn1obj(ASN1_OBJECT *obj)
156
- {
157
- BIO *out;
158
- VALUE ret;
159
- int nid;
160
- if ((nid = OBJ_obj2nid(obj)) != NID_undef)
161
- ret = rb_str_new2(OBJ_nid2sn(nid));
162
- else{
163
- if (!(out = BIO_new(BIO_s_mem())))
164
- ossl_raise(eTimestampError, "BIO_new(BIO_s_mem())");
165
- if (i2a_ASN1_OBJECT(out, obj) <= 0) {
166
- BIO_free(out);
167
- ossl_raise(eTimestampError, "i2a_ASN1_OBJECT");
168
- }
169
- ret = ossl_membio2str(out);
170
- }
171
-
172
- return ret;
138
+ return (VALUE)ossl_to_asn1obj(obj);
173
139
  }
174
140
 
175
141
  static VALUE
@@ -236,11 +202,13 @@ ossl_ts_req_get_algorithm(VALUE self)
236
202
  TS_REQ *req;
237
203
  TS_MSG_IMPRINT *mi;
238
204
  X509_ALGOR *algor;
205
+ const ASN1_OBJECT *obj;
239
206
 
240
207
  GetTSRequest(self, req);
241
208
  mi = TS_REQ_get_msg_imprint(req);
242
209
  algor = TS_MSG_IMPRINT_get_algo(mi);
243
- return get_asn1obj(algor->algorithm);
210
+ X509_ALGOR_get0(&obj, NULL, NULL, algor);
211
+ return ossl_asn1obj_to_string(obj);
244
212
  }
245
213
 
246
214
  /*
@@ -262,7 +230,7 @@ ossl_ts_req_set_algorithm(VALUE self, VALUE algo)
262
230
  X509_ALGOR *algor;
263
231
 
264
232
  GetTSRequest(self, req);
265
- obj = obj_to_asn1obj(algo);
233
+ obj = ossl_to_asn1obj(algo);
266
234
  mi = TS_REQ_get_msg_imprint(req);
267
235
  algor = TS_MSG_IMPRINT_get_algo(mi);
268
236
  if (!X509_ALGOR_set0(algor, obj, V_ASN1_NULL, NULL)) {
@@ -369,7 +337,7 @@ ossl_ts_req_get_policy_id(VALUE self)
369
337
  GetTSRequest(self, req);
370
338
  if (!TS_REQ_get_policy_id(req))
371
339
  return Qnil;
372
- return get_asn1obj(TS_REQ_get_policy_id(req));
340
+ return ossl_asn1obj_to_string(TS_REQ_get_policy_id(req));
373
341
  }
374
342
 
375
343
  /*
@@ -392,7 +360,7 @@ ossl_ts_req_set_policy_id(VALUE self, VALUE oid)
392
360
  int ok;
393
361
 
394
362
  GetTSRequest(self, req);
395
- obj = obj_to_asn1obj(oid);
363
+ obj = ossl_to_asn1obj(oid);
396
364
  ok = TS_REQ_set_policy_id(req, obj);
397
365
  ASN1_OBJECT_free(obj);
398
366
  if (!ok)
@@ -490,13 +458,15 @@ ossl_ts_req_to_der(VALUE self)
490
458
  TS_REQ *req;
491
459
  TS_MSG_IMPRINT *mi;
492
460
  X509_ALGOR *algo;
461
+ const ASN1_OBJECT *obj;
493
462
  ASN1_OCTET_STRING *hashed_msg;
494
463
 
495
464
  GetTSRequest(self, req);
496
465
  mi = TS_REQ_get_msg_imprint(req);
497
466
 
498
467
  algo = TS_MSG_IMPRINT_get_algo(mi);
499
- if (OBJ_obj2nid(algo->algorithm) == NID_undef)
468
+ X509_ALGOR_get0(&obj, NULL, NULL, algo);
469
+ if (OBJ_obj2nid(obj) == NID_undef)
500
470
  ossl_raise(eTimestampError, "Message imprint missing algorithm");
501
471
 
502
472
  hashed_msg = TS_MSG_IMPRINT_get_msg(mi);
@@ -620,14 +590,7 @@ ossl_ts_resp_get_failure_info(VALUE self)
620
590
  {
621
591
  TS_RESP *resp;
622
592
  TS_STATUS_INFO *si;
623
-
624
- /* The ASN1_BIT_STRING_get_bit changed from 1.0.0. to 1.1.0, making this
625
- * const. */
626
- #if defined(HAVE_TS_STATUS_INFO_GET0_FAILURE_INFO)
627
593
  const ASN1_BIT_STRING *fi;
628
- #else
629
- ASN1_BIT_STRING *fi;
630
- #endif
631
594
 
632
595
  GetTSResponse(self, resp);
633
596
  si = TS_RESP_get_status_info(resp);
@@ -743,7 +706,7 @@ ossl_ts_resp_get_tsa_certificate(VALUE self)
743
706
  TS_RESP *resp;
744
707
  PKCS7 *p7;
745
708
  PKCS7_SIGNER_INFO *ts_info;
746
- const X509 *cert;
709
+ X509 *cert;
747
710
 
748
711
  GetTSResponse(self, resp);
749
712
  if (!(p7 = TS_RESP_get_token(resp)))
@@ -858,16 +821,26 @@ ossl_ts_resp_verify(int argc, VALUE *argv, VALUE self)
858
821
  X509_up_ref(cert);
859
822
  }
860
823
 
824
+ if (!X509_STORE_up_ref(x509st)) {
825
+ sk_X509_pop_free(x509inter, X509_free);
826
+ TS_VERIFY_CTX_free(ctx);
827
+ ossl_raise(eTimestampError, "X509_STORE_up_ref");
828
+ }
829
+
830
+ #ifdef HAVE_TS_VERIFY_CTX_SET0_CERTS
831
+ TS_VERIFY_CTX_set0_certs(ctx, x509inter);
832
+ TS_VERIFY_CTX_set0_store(ctx, x509st);
833
+ #else
834
+ # if OSSL_OPENSSL_PREREQ(3, 0, 0) || OSSL_IS_LIBRESSL
861
835
  TS_VERIFY_CTX_set_certs(ctx, x509inter);
862
- TS_VERIFY_CTX_add_flags(ctx, TS_VFY_SIGNATURE);
836
+ # else
837
+ TS_VERIFY_CTS_set_certs(ctx, x509inter);
838
+ # endif
863
839
  TS_VERIFY_CTX_set_store(ctx, x509st);
840
+ #endif
841
+ TS_VERIFY_CTX_add_flags(ctx, TS_VFY_SIGNATURE);
864
842
 
865
843
  ok = TS_RESP_verify_response(ctx, resp);
866
- /*
867
- * TS_VERIFY_CTX_set_store() call above does not increment the reference
868
- * counter, so it must be unset before TS_VERIFY_CTX_free() is called.
869
- */
870
- TS_VERIFY_CTX_set_store(ctx, NULL);
871
844
  TS_VERIFY_CTX_free(ctx);
872
845
 
873
846
  if (!ok)
@@ -954,7 +927,7 @@ ossl_ts_token_info_get_policy_id(VALUE self)
954
927
  TS_TST_INFO *info;
955
928
 
956
929
  GetTSTokenInfo(self, info);
957
- return get_asn1obj(TS_TST_INFO_get_policy_id(info));
930
+ return ossl_asn1obj_to_string(TS_TST_INFO_get_policy_id(info));
958
931
  }
959
932
 
960
933
  /*
@@ -976,11 +949,13 @@ ossl_ts_token_info_get_algorithm(VALUE self)
976
949
  TS_TST_INFO *info;
977
950
  TS_MSG_IMPRINT *mi;
978
951
  X509_ALGOR *algo;
952
+ const ASN1_OBJECT *obj;
979
953
 
980
954
  GetTSTokenInfo(self, info);
981
955
  mi = TS_TST_INFO_get_msg_imprint(info);
982
956
  algo = TS_MSG_IMPRINT_get_algo(mi);
983
- return get_asn1obj(algo->algorithm);
957
+ X509_ALGOR_get0(&obj, NULL, NULL, algo);
958
+ return ossl_asn1obj_to_string(obj);
984
959
  }
985
960
 
986
961
  /*
@@ -1146,9 +1121,14 @@ ossl_tsfac_time_cb(struct TS_resp_ctx *ctx, void *data, time_t *sec, long *usec)
1146
1121
  }
1147
1122
 
1148
1123
  static VALUE
1149
- ossl_evp_get_digestbyname_i(VALUE arg)
1124
+ ossl_evp_md_fetch_i(VALUE args_)
1150
1125
  {
1151
- return (VALUE)ossl_evp_get_digestbyname(arg);
1126
+ VALUE *args = (VALUE *)args_, md_holder;
1127
+ const EVP_MD *md;
1128
+
1129
+ md = ossl_evp_md_fetch(args[1], &md_holder);
1130
+ rb_ary_push(args[0], md_holder);
1131
+ return (VALUE)md;
1152
1132
  }
1153
1133
 
1154
1134
  static VALUE
@@ -1184,7 +1164,8 @@ ossl_obj2bio_i(VALUE arg)
1184
1164
  static VALUE
1185
1165
  ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
1186
1166
  {
1187
- VALUE serial_number, def_policy_id, gen_time, additional_certs, allowed_digests;
1167
+ VALUE serial_number, def_policy_id, gen_time, additional_certs,
1168
+ allowed_digests, allowed_digests_tmp = Qnil;
1188
1169
  VALUE str;
1189
1170
  STACK_OF(X509) *inter_certs;
1190
1171
  VALUE tsresp, ret = Qnil;
@@ -1245,7 +1226,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
1245
1226
  if (rb_obj_is_kind_of(additional_certs, rb_cArray)) {
1246
1227
  inter_certs = ossl_protect_x509_ary2sk(additional_certs, &status);
1247
1228
  if (status)
1248
- goto end;
1229
+ goto end;
1249
1230
 
1250
1231
  /* this dups the sk_X509 and ups each cert's ref count */
1251
1232
  TS_RESP_CTX_set_certs(ctx, inter_certs);
@@ -1261,16 +1242,18 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
1261
1242
 
1262
1243
  allowed_digests = ossl_tsfac_get_allowed_digests(self);
1263
1244
  if (rb_obj_is_kind_of(allowed_digests, rb_cArray)) {
1264
- int i;
1265
- VALUE rbmd;
1266
- const EVP_MD *md;
1267
-
1268
- for (i = 0; i < RARRAY_LEN(allowed_digests); i++) {
1269
- rbmd = rb_ary_entry(allowed_digests, i);
1270
- md = (const EVP_MD *)rb_protect(ossl_evp_get_digestbyname_i, rbmd, &status);
1245
+ allowed_digests_tmp = rb_ary_new_capa(RARRAY_LEN(allowed_digests));
1246
+ for (long i = 0; i < RARRAY_LEN(allowed_digests); i++) {
1247
+ VALUE args[] = {
1248
+ allowed_digests_tmp,
1249
+ rb_ary_entry(allowed_digests, i),
1250
+ };
1251
+ const EVP_MD *md = (const EVP_MD *)rb_protect(ossl_evp_md_fetch_i,
1252
+ (VALUE)args, &status);
1271
1253
  if (status)
1272
1254
  goto end;
1273
- TS_RESP_CTX_add_md(ctx, md);
1255
+ if (!TS_RESP_CTX_add_md(ctx, md))
1256
+ goto end;
1274
1257
  }
1275
1258
  }
1276
1259
 
@@ -1284,6 +1267,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
1284
1267
 
1285
1268
  response = TS_RESP_create_response(ctx, req_bio);
1286
1269
  BIO_free(req_bio);
1270
+ RB_GC_GUARD(allowed_digests_tmp);
1287
1271
 
1288
1272
  if (!response) {
1289
1273
  err_msg = "Error during response generation";
@@ -1297,7 +1281,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
1297
1281
  SetTSResponse(tsresp, response);
1298
1282
  ret = tsresp;
1299
1283
 
1300
- end:
1284
+ end:
1301
1285
  ASN1_INTEGER_free(asn1_serial);
1302
1286
  ASN1_OBJECT_free(def_policy_id_obj);
1303
1287
  TS_RESP_CTX_free(ctx);
@@ -1314,10 +1298,6 @@ end:
1314
1298
  void
1315
1299
  Init_ossl_ts(void)
1316
1300
  {
1317
- #if 0
1318
- mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
1319
- #endif
1320
-
1321
1301
  /*
1322
1302
  * Possible return value for +Response#failure_info+. Indicates that the
1323
1303
  * timestamp server rejects the message imprint algorithm used in the
@@ -1527,65 +1507,39 @@ Init_ossl_ts(void)
1527
1507
  * fac.default_policy_id = '1.2.3.4.5'
1528
1508
  * fac.additional_certificates = [ inter1, inter2 ]
1529
1509
  * timestamp = fac.create_timestamp(p12.key, p12.certificate, req)
1530
- *
1531
- * ==Attributes
1532
- *
1533
- * ===default_policy_id
1510
+ */
1511
+ cTimestampFactory = rb_define_class_under(mTimestamp, "Factory", rb_cObject);
1512
+ /*
1513
+ * The list of digest algorithms that the factory is allowed
1514
+ * create timestamps for. Known vulnerable or weak algorithms should not be
1515
+ * allowed where possible. Must be an Array of String or OpenSSL::Digest
1516
+ * subclass instances.
1517
+ */
1518
+ rb_attr(cTimestampFactory, rb_intern_const("allowed_digests"), 1, 1, 0);
1519
+ /*
1520
+ * A String representing the default policy object identifier, or +nil+.
1534
1521
  *
1535
1522
  * Request#policy_id will always be preferred over this if present in the
1536
- * Request, only if Request#policy_id is nil default_policy will be used.
1523
+ * Request, only if Request#policy_id is +nil+ default_policy will be used.
1537
1524
  * If none of both is present, a TimestampError will be raised when trying
1538
1525
  * to create a Response.
1539
- *
1540
- * call-seq:
1541
- * factory.default_policy_id = "string" -> string
1542
- * factory.default_policy_id -> string or nil
1543
- *
1544
- * ===serial_number
1545
- *
1546
- * Sets or retrieves the serial number to be used for timestamp creation.
1547
- * Must be present for timestamp creation.
1548
- *
1549
- * call-seq:
1550
- * factory.serial_number = number -> number
1551
- * factory.serial_number -> number or nil
1552
- *
1553
- * ===gen_time
1554
- *
1555
- * Sets or retrieves the Time value to be used in the Response. Must be
1556
- * present for timestamp creation.
1557
- *
1558
- * call-seq:
1559
- * factory.gen_time = Time -> Time
1560
- * factory.gen_time -> Time or nil
1561
- *
1562
- * ===additional_certs
1563
- *
1564
- * Sets or retrieves additional certificates apart from the timestamp
1565
- * certificate (e.g. intermediate certificates) to be added to the Response.
1566
- * Must be an Array of OpenSSL::X509::Certificate.
1567
- *
1568
- * call-seq:
1569
- * factory.additional_certs = [cert1, cert2] -> [ cert1, cert2 ]
1570
- * factory.additional_certs -> array or nil
1571
- *
1572
- * ===allowed_digests
1573
- *
1574
- * Sets or retrieves the digest algorithms that the factory is allowed
1575
- * create timestamps for. Known vulnerable or weak algorithms should not be
1576
- * allowed where possible.
1577
- * Must be an Array of String or OpenSSL::Digest subclass instances.
1578
- *
1579
- * call-seq:
1580
- * factory.allowed_digests = ["sha1", OpenSSL::Digest.new('SHA256').new] -> [ "sha1", OpenSSL::Digest) ]
1581
- * factory.allowed_digests -> array or nil
1582
- *
1583
1526
  */
1584
- cTimestampFactory = rb_define_class_under(mTimestamp, "Factory", rb_cObject);
1585
- rb_attr(cTimestampFactory, rb_intern_const("allowed_digests"), 1, 1, 0);
1586
1527
  rb_attr(cTimestampFactory, rb_intern_const("default_policy_id"), 1, 1, 0);
1528
+ /*
1529
+ * The serial number to be used for timestamp creation. Must be present for
1530
+ * timestamp creation. Must be an instance of OpenSSL::BN or Integer.
1531
+ */
1587
1532
  rb_attr(cTimestampFactory, rb_intern_const("serial_number"), 1, 1, 0);
1533
+ /*
1534
+ * The Time value to be used in the Response. Must be present for timestamp
1535
+ * creation.
1536
+ */
1588
1537
  rb_attr(cTimestampFactory, rb_intern_const("gen_time"), 1, 1, 0);
1538
+ /*
1539
+ * Additional certificates apart from the timestamp certificate (e.g.
1540
+ * intermediate certificates) to be added to the Response.
1541
+ * Must be an Array of OpenSSL::X509::Certificate, or +nil+.
1542
+ */
1589
1543
  rb_attr(cTimestampFactory, rb_intern_const("additional_certs"), 1, 1, 0);
1590
1544
  rb_define_method(cTimestampFactory, "create_timestamp", ossl_tsfac_create_ts, 3);
1591
1545
  }
@@ -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
- rb_define_const(mX509, "DEFAULT_" #x, rb_str_new2(X509_get_default_##i()))
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
- #endif
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);
@@ -29,7 +29,7 @@ void Init_ossl_x509(void);
29
29
  */
30
30
  extern VALUE cX509Attr;
31
31
 
32
- VALUE ossl_x509attr_new(const X509_ATTRIBUTE *);
32
+ VALUE ossl_x509attr_new(X509_ATTRIBUTE *);
33
33
  X509_ATTRIBUTE *GetX509AttrPtr(VALUE);
34
34
  void Init_ossl_x509attr(void);
35
35
 
@@ -38,7 +38,7 @@ void Init_ossl_x509attr(void);
38
38
  */
39
39
  extern VALUE cX509Cert;
40
40
 
41
- VALUE ossl_x509_new(const X509 *);
41
+ VALUE ossl_x509_new(X509 *);
42
42
  X509 *GetX509CertPtr(VALUE);
43
43
  X509 *DupX509CertPtr(VALUE);
44
44
  void Init_ossl_x509cert(void);
@@ -46,7 +46,7 @@ void Init_ossl_x509cert(void);
46
46
  /*
47
47
  * X509CRL
48
48
  */
49
- VALUE ossl_x509crl_new(const X509_CRL *);
49
+ VALUE ossl_x509crl_new(X509_CRL *);
50
50
  X509_CRL *GetX509CRLPtr(VALUE);
51
51
  void Init_ossl_x509crl(void);
52
52
 
@@ -55,14 +55,14 @@ void Init_ossl_x509crl(void);
55
55
  */
56
56
  extern VALUE cX509Ext;
57
57
 
58
- VALUE ossl_x509ext_new(const X509_EXTENSION *);
58
+ VALUE ossl_x509ext_new(X509_EXTENSION *);
59
59
  X509_EXTENSION *GetX509ExtPtr(VALUE);
60
60
  void Init_ossl_x509ext(void);
61
61
 
62
62
  /*
63
63
  * X509Name
64
64
  */
65
- VALUE ossl_x509name_new(const X509_NAME *);
65
+ VALUE ossl_x509name_new(X509_NAME *);
66
66
  X509_NAME *GetX509NamePtr(VALUE);
67
67
  void Init_ossl_x509name(void);
68
68
 
@@ -77,7 +77,7 @@ void Init_ossl_x509req(void);
77
77
  */
78
78
  extern VALUE cX509Rev;
79
79
 
80
- VALUE ossl_x509revoked_new(const X509_REVOKED *);
80
+ VALUE ossl_x509revoked_new(X509_REVOKED *);
81
81
  X509_REVOKED *DupX509RevokedPtr(VALUE);
82
82
  void Init_ossl_x509revoked(void);
83
83