grpc 1.41.0 → 1.41.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +4 -3
  3. data/etc/roots.pem +335 -326
  4. data/src/ruby/ext/grpc/extconf.rb +1 -1
  5. data/src/ruby/lib/grpc/version.rb +1 -1
  6. data/third_party/boringssl-with-bazel/err_data.c +278 -272
  7. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +1 -1
  8. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_d2i_fp.c +0 -2
  9. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +5 -0
  10. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +15 -22
  11. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +13 -7
  12. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_print.c +19 -29
  13. data/third_party/boringssl-with-bazel/src/crypto/{x509 → asn1}/a_strex.c +268 -271
  14. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +6 -43
  15. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +2 -2
  16. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +0 -39
  17. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_par.c +1 -1
  18. data/third_party/boringssl-with-bazel/src/crypto/{x509 → asn1}/charmap.h +0 -0
  19. data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +25 -0
  20. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +8 -8
  21. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +289 -198
  22. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +8 -8
  23. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c +9 -13
  24. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c +1 -0
  25. data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +11 -8
  26. data/third_party/boringssl-with-bazel/src/crypto/bio/bio_mem.c +1 -7
  27. data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +1 -5
  28. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +0 -4
  29. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +1 -7
  30. data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +1 -6
  31. data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +3 -17
  32. data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbb.c +9 -0
  33. data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +8 -0
  34. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +45 -65
  35. data/third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c +1 -0
  36. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +21 -3
  37. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd_extra.c +3 -2
  38. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +5 -2
  39. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +10 -0
  40. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +1 -1
  41. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +1 -1
  42. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +1 -1
  43. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +24 -9
  44. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +4 -2
  45. data/third_party/boringssl-with-bazel/src/crypto/mem.c +12 -9
  46. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_all.c +0 -9
  47. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_info.c +0 -2
  48. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +0 -8
  49. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pk8.c +0 -2
  50. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pkey.c +0 -4
  51. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/internal.h +16 -7
  52. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +9 -4
  53. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +151 -12
  54. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1 -1
  55. data/third_party/boringssl-with-bazel/src/crypto/x509/by_file.c +2 -0
  56. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +181 -1
  57. data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +246 -0
  58. data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c +11 -2
  59. data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +0 -2
  60. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +0 -179
  61. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +4 -2
  62. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c +0 -5
  63. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +1 -0
  64. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +11 -50
  65. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +1 -1
  66. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +2 -4
  67. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +0 -16
  68. data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +22 -18
  69. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +11 -8
  70. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +16 -0
  71. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_cache.c +1 -0
  72. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +1 -1
  73. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_int.h +1 -1
  74. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_map.c +1 -0
  75. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_tree.c +4 -3
  76. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akey.c +24 -5
  77. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +17 -8
  78. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bitst.c +3 -0
  79. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +6 -6
  80. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_crld.c +4 -0
  81. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_enum.c +5 -0
  82. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ncons.c +112 -55
  83. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pci.c +2 -1
  84. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +0 -2
  85. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -0
  86. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +71 -26
  87. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +304 -192
  88. data/third_party/boringssl-with-bazel/src/include/openssl/asn1t.h +2 -9
  89. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +5 -3
  90. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +3 -1
  91. data/third_party/boringssl-with-bazel/src/include/openssl/bn.h +3 -3
  92. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +9 -0
  93. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +8 -2
  94. data/third_party/boringssl-with-bazel/src/include/openssl/hkdf.h +4 -0
  95. data/third_party/boringssl-with-bazel/src/include/openssl/mem.h +9 -3
  96. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +0 -20
  97. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +12 -5
  98. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +5 -0
  99. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +37 -15
  100. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +26 -12
  101. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +31 -32
  102. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +50 -76
  103. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +0 -131
  104. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +48 -8
  105. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +266 -357
  106. data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +90 -152
  107. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +15 -13
  108. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +75 -79
  109. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +96 -97
  110. data/third_party/boringssl-with-bazel/src/ssl/internal.h +63 -43
  111. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +2 -2
  112. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +2 -2
  113. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +6 -12
  114. data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +14 -16
  115. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +14 -27
  116. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +203 -203
  117. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +30 -41
  118. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +47 -33
  119. metadata +39 -38
@@ -377,7 +377,9 @@ OPENSSL_EXPORT int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len,
377
377
  OPENSSL_EXPORT const BIO_METHOD *BIO_s_mem(void);
378
378
 
379
379
  // BIO_new_mem_buf creates read-only BIO that reads from |len| bytes at |buf|.
380
- // It does not take ownership of |buf|. It returns the BIO or NULL on error.
380
+ // It returns the BIO or NULL on error. This function does not copy or take
381
+ // ownership of |buf|. The caller must ensure the memory pointed to by |buf|
382
+ // outlives the |BIO|.
381
383
  //
382
384
  // If |len| is negative, then |buf| is treated as a NUL-terminated string, but
383
385
  // don't depend on this in new code.
@@ -687,9 +687,9 @@ OPENSSL_EXPORT int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
687
687
  // BN_prime_checks_for_validation can be used as the |checks| argument to the
688
688
  // primarily testing functions when validating an externally-supplied candidate
689
689
  // prime. It gives a false positive rate of at most 2^{-128}. (The worst case
690
- // false positive rate for a single iteration is 1/4, so we perform 32
691
- // iterations.)
692
- #define BN_prime_checks_for_validation 32
690
+ // false positive rate for a single iteration is 1/4 per
691
+ // https://eprint.iacr.org/2018/749. (1/4)^64 = 2^{-128}.)
692
+ #define BN_prime_checks_for_validation 64
693
693
 
694
694
  // BN_prime_checks_for_generation can be used as the |checks| argument to the
695
695
  // primality testing functions when generating random primes. It gives a false
@@ -154,6 +154,11 @@ OPENSSL_EXPORT int CBS_get_u16_length_prefixed(CBS *cbs, CBS *out);
154
154
  // returns one on success and zero on error.
155
155
  OPENSSL_EXPORT int CBS_get_u24_length_prefixed(CBS *cbs, CBS *out);
156
156
 
157
+ // CBS_get_until_first finds the first instance of |c| in |cbs|. If found, it
158
+ // sets |*out| to the text before the match, advances |cbs| over it, and returns
159
+ // one. Otherwise, it returns zero and leaves |cbs| unmodified.
160
+ OPENSSL_EXPORT int CBS_get_until_first(CBS *cbs, CBS *out, uint8_t c);
161
+
157
162
 
158
163
  // Parsing ASN.1
159
164
  //
@@ -463,6 +468,10 @@ OPENSSL_EXPORT int CBB_add_asn1(CBB *cbb, CBB *out_contents, unsigned tag);
463
468
  // success and zero otherwise.
464
469
  OPENSSL_EXPORT int CBB_add_bytes(CBB *cbb, const uint8_t *data, size_t len);
465
470
 
471
+ // CBB_add_zeros append |len| bytes with value zero to |cbb|. It returns one on
472
+ // success and zero otherwise.
473
+ OPENSSL_EXPORT int CBB_add_zeros(CBB *cbb, size_t len);
474
+
466
475
  // CBB_add_space appends |len| bytes to |cbb| and sets |*out_data| to point to
467
476
  // the beginning of that space. The caller must then write |len| bytes of
468
477
  // actual contents to |*out_data|. It returns one on success and zero
@@ -106,7 +106,10 @@ OPENSSL_EXPORT const EVP_CIPHER *EVP_rc2_cbc(void);
106
106
  const EVP_CIPHER *EVP_rc2_40_cbc(void);
107
107
 
108
108
  // EVP_get_cipherbynid returns the cipher corresponding to the given NID, or
109
- // NULL if no such cipher is known.
109
+ // NULL if no such cipher is known. Note using this function links almost every
110
+ // cipher implemented by BoringSSL into the binary, whether the caller uses them
111
+ // or not. Size-conscious callers, such as client software, should not use this
112
+ // function.
110
113
  OPENSSL_EXPORT const EVP_CIPHER *EVP_get_cipherbynid(int nid);
111
114
 
112
115
 
@@ -409,7 +412,10 @@ OPENSSL_EXPORT int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,
409
412
  OPENSSL_EXPORT int EVP_add_cipher_alias(const char *a, const char *b);
410
413
 
411
414
  // EVP_get_cipherbyname returns an |EVP_CIPHER| given a human readable name in
412
- // |name|, or NULL if the name is unknown.
415
+ // |name|, or NULL if the name is unknown. Note using this function links almost
416
+ // every cipher implemented by BoringSSL into the binary, not just the ones the
417
+ // caller requests. Size-conscious callers, such as client software, should not
418
+ // use this function.
413
419
  OPENSSL_EXPORT const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
414
420
 
415
421
  // These AEADs are deprecated AES-GCM implementations that set
@@ -41,6 +41,10 @@ OPENSSL_EXPORT int HKDF(uint8_t *out_key, size_t out_len, const EVP_MD *digest,
41
41
  // keying material |secret| and salt |salt| using |digest|, and outputs
42
42
  // |out_len| bytes to |out_key|. The maximum output size is |EVP_MAX_MD_SIZE|.
43
43
  // It returns one on success and zero on error.
44
+ //
45
+ // WARNING: This function orders the inputs differently from RFC 5869
46
+ // specification. Double-check which parameter is the secret/IKM and which is
47
+ // the salt when using.
44
48
  OPENSSL_EXPORT int HKDF_extract(uint8_t *out_key, size_t *out_len,
45
49
  const EVP_MD *digest, const uint8_t *secret,
46
50
  size_t secret_len, const uint8_t *salt,
@@ -150,9 +150,15 @@ OPENSSL_EXPORT size_t OPENSSL_strlcat(char *dst, const char *src,
150
150
 
151
151
  // Deprecated functions.
152
152
 
153
- #define CRYPTO_malloc OPENSSL_malloc
154
- #define CRYPTO_realloc OPENSSL_realloc
155
- #define CRYPTO_free OPENSSL_free
153
+ // CRYPTO_malloc calls |OPENSSL_malloc|. |file| and |line| are ignored.
154
+ OPENSSL_EXPORT void *CRYPTO_malloc(size_t size, const char *file, int line);
155
+
156
+ // CRYPTO_realloc calls |OPENSSL_realloc|. |file| and |line| are ignored.
157
+ OPENSSL_EXPORT void *CRYPTO_realloc(void *ptr, size_t new_size,
158
+ const char *file, int line);
159
+
160
+ // CRYPTO_free calls |OPENSSL_free|. |file| and |line| are ignored.
161
+ OPENSSL_EXPORT void CRYPTO_free(void *ptr, const char *file, int line);
156
162
 
157
163
  // OPENSSL_clear_free calls |OPENSSL_free|. BoringSSL automatically clears all
158
164
  // allocations on free, but we define |OPENSSL_clear_free| for compatibility.
@@ -112,15 +112,6 @@ extern "C" {
112
112
  // write. Now they are all implemented with either:
113
113
  // IMPLEMENT_PEM_rw(...) or IMPLEMENT_PEM_rw_cb(...)
114
114
 
115
- #ifdef OPENSSL_NO_FP_API
116
-
117
- #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) //
118
- #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) //
119
- #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) //
120
- #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) //
121
- #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) //
122
-
123
- #else
124
115
 
125
116
  #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
126
117
  static void *pem_read_##name##_d2i(void **x, const unsigned char **inp, \
@@ -173,7 +164,6 @@ extern "C" {
173
164
  cb, u); \
174
165
  }
175
166
 
176
- #endif
177
167
 
178
168
  #define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
179
169
  static void *pem_read_bio_##name##_d2i(void **x, const unsigned char **inp, \
@@ -260,14 +250,6 @@ extern "C" {
260
250
 
261
251
  // These are the same except they are for the declarations
262
252
 
263
- #if defined(OPENSSL_NO_FP_API)
264
-
265
- #define DECLARE_PEM_read_fp(name, type) //
266
- #define DECLARE_PEM_write_fp(name, type) //
267
- #define DECLARE_PEM_write_cb_fp(name, type) //
268
-
269
- #else
270
-
271
253
  #define DECLARE_PEM_read_fp(name, type) \
272
254
  OPENSSL_EXPORT type *PEM_read_##name(FILE *fp, type **x, \
273
255
  pem_password_cb *cb, void *u);
@@ -283,8 +265,6 @@ extern "C" {
283
265
  FILE *fp, type *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, \
284
266
  pem_password_cb *cb, void *u);
285
267
 
286
- #endif
287
-
288
268
  #define DECLARE_PEM_read_bio(name, type) \
289
269
  OPENSSL_EXPORT type *PEM_read_bio_##name(BIO *bp, type **x, \
290
270
  pem_password_cb *cb, void *u);
@@ -200,15 +200,22 @@ OPENSSL_EXPORT int PKCS7_type_is_signedAndEnveloped(const PKCS7 *p7);
200
200
  #define PKCS7_STREAM 0x1000
201
201
  #define PKCS7_PARTIAL 0x4000
202
202
 
203
- // PKCS7_sign assembles |certs| into a PKCS#7 signed data ContentInfo with
203
+ // PKCS7_sign can operate in two modes to provide some backwards compatibility:
204
+ //
205
+ // The first mode assembles |certs| into a PKCS#7 signed data ContentInfo with
204
206
  // external data and no signatures. It returns a newly-allocated |PKCS7| on
205
207
  // success or NULL on error. |sign_cert| and |pkey| must be NULL. |data| is
206
- // ignored. |flags| must be equal to |PKCS7_DETACHED|.
207
- //
208
- // Note this function only implements a subset of the corresponding OpenSSL
209
- // function. It is provided for backwards compatibility only. Additionally,
208
+ // ignored. |flags| must be equal to |PKCS7_DETACHED|. Additionally,
210
209
  // certificates in SignedData structures are unordered. The order of |certs|
211
210
  // will not be preserved.
211
+ //
212
+ // The second mode generates a detached RSA SHA-256 signature of |data| using
213
+ // |pkey| and produces a PKCS#7 SignedData structure containing it. |certs|
214
+ // must be NULL and |flags| must be exactly |PKCS7_NOATTR | PKCS7_BINARY |
215
+ // PKCS7_NOCERTS | PKCS7_DETACHED|.
216
+ //
217
+ // Note this function only implements a subset of the corresponding OpenSSL
218
+ // function. It is provided for backwards compatibility only.
212
219
  OPENSSL_EXPORT PKCS7 *PKCS7_sign(X509 *sign_cert, EVP_PKEY *pkey,
213
220
  STACK_OF(X509) *certs, BIO *data, int flags);
214
221
 
@@ -684,6 +684,11 @@ OPENSSL_EXPORT int RSA_padding_add_PKCS1_OAEP(uint8_t *to, size_t to_len,
684
684
  // on success or zero otherwise.
685
685
  OPENSSL_EXPORT int RSA_print(BIO *bio, const RSA *rsa, int indent);
686
686
 
687
+ // RSA_get0_pss_params returns NULL. In OpenSSL, this function retries RSA-PSS
688
+ // parameters associated with |RSA| objects, but BoringSSL does not support
689
+ // the id-RSASSA-PSS key encoding.
690
+ OPENSSL_EXPORT const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *rsa);
691
+
687
692
 
688
693
  struct rsa_meth_st {
689
694
  struct openssl_method_common_st common;
@@ -94,18 +94,6 @@ class SpanBase {
94
94
  template <typename T>
95
95
  class Span : private internal::SpanBase<const T> {
96
96
  private:
97
- // Heuristically test whether C is a container type that can be converted into
98
- // a Span by checking for data() and size() member functions.
99
- //
100
- // TODO(davidben): Switch everything to std::enable_if_t when we remove
101
- // support for MSVC 2015. Although we could write our own enable_if_t and MSVC
102
- // 2015 has std::enable_if_t anyway, MSVC 2015's SFINAE implementation is
103
- // problematic and does not work below unless we write the ::type at use.
104
- template <typename C>
105
- using EnableIfContainer = std::enable_if<
106
- std::is_convertible<decltype(std::declval<C>().data()), T *>::value &&
107
- std::is_integral<decltype(std::declval<C>().size())>::value>;
108
-
109
97
  static const size_t npos = static_cast<size_t>(-1);
110
98
 
111
99
  public:
@@ -116,12 +104,27 @@ class Span : private internal::SpanBase<const T> {
116
104
  constexpr Span(T (&array)[N]) : Span(array, N) {}
117
105
 
118
106
  template <
119
- typename C, typename = typename EnableIfContainer<C>::type,
107
+ typename C,
108
+ // TODO(davidben): Switch everything to std::enable_if_t when we remove
109
+ // support for MSVC 2015. Although we could write our own enable_if_t and
110
+ // MSVC 2015 has std::enable_if_t anyway, MSVC 2015's SFINAE
111
+ // implementation is problematic and does not work below unless we write
112
+ // the ::type at use.
113
+ //
114
+ // TODO(davidben): Move this and the identical copy below into an
115
+ // EnableIfContainer alias when we drop MSVC 2015 support. MSVC 2015's
116
+ // SFINAE support cannot handle type aliases.
117
+ typename = typename std::enable_if<
118
+ std::is_convertible<decltype(std::declval<C>().data()), T *>::value &&
119
+ std::is_integral<decltype(std::declval<C>().size())>::value>::type,
120
120
  typename = typename std::enable_if<std::is_const<T>::value, C>::type>
121
121
  Span(const C &container) : data_(container.data()), size_(container.size()) {}
122
122
 
123
123
  template <
124
- typename C, typename = typename EnableIfContainer<C>::type,
124
+ typename C,
125
+ typename = typename std::enable_if<
126
+ std::is_convertible<decltype(std::declval<C>().data()), T *>::value &&
127
+ std::is_integral<decltype(std::declval<C>().size())>::value>::type,
125
128
  typename = typename std::enable_if<!std::is_const<T>::value, C>::type>
126
129
  explicit Span(C &container)
127
130
  : data_(container.data()), size_(container.size()) {}
@@ -158,11 +161,30 @@ class Span : private internal::SpanBase<const T> {
158
161
 
159
162
  Span subspan(size_t pos = 0, size_t len = npos) const {
160
163
  if (pos > size_) {
161
- abort(); // absl::Span throws an exception here.
164
+ // absl::Span throws an exception here. Note std::span and Chromium
165
+ // base::span additionally forbid pos + len being out of range, with a
166
+ // special case at npos/dynamic_extent, while absl::Span::subspan clips
167
+ // the span. For now, we align with absl::Span in case we switch to it in
168
+ // the future.
169
+ abort();
162
170
  }
163
171
  return Span(data_ + pos, std::min(size_ - pos, len));
164
172
  }
165
173
 
174
+ Span first(size_t len) {
175
+ if (len > size_) {
176
+ abort();
177
+ }
178
+ return Span(data_, len);
179
+ }
180
+
181
+ Span last(size_t len) {
182
+ if (len > size_) {
183
+ abort();
184
+ }
185
+ return Span(data_ + size_ - len, len);
186
+ }
187
+
166
188
  private:
167
189
  T *data_;
168
190
  size_t size_;
@@ -1649,6 +1649,11 @@ OPENSSL_EXPORT int SSL_export_keying_material(
1649
1649
  // abbreviated handshake. It is reference-counted and immutable. Once
1650
1650
  // established, an |SSL_SESSION| may be shared by multiple |SSL| objects on
1651
1651
  // different threads and must not be modified.
1652
+ //
1653
+ // Note the TLS notion of "session" is not suitable for application-level
1654
+ // session state. It is an optional caching mechanism for the handshake. Not all
1655
+ // connections within an application-level session will reuse TLS sessions. TLS
1656
+ // sessions may be dropped by the client or ignored by the server at any time.
1652
1657
 
1653
1658
  DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)
1654
1659
 
@@ -1703,6 +1708,19 @@ OPENSSL_EXPORT int SSL_SESSION_set_protocol_version(SSL_SESSION *session,
1703
1708
 
1704
1709
  // SSL_SESSION_get_id returns a pointer to a buffer containing |session|'s
1705
1710
  // session ID and sets |*out_len| to its length.
1711
+ //
1712
+ // This function should only be used for implementing a TLS session cache. TLS
1713
+ // sessions are not suitable for application-level session state, and a session
1714
+ // ID is an implementation detail of the TLS resumption handshake mechanism. Not
1715
+ // all resumption flows use session IDs, and not all connections within an
1716
+ // application-level session will reuse TLS sessions.
1717
+ //
1718
+ // To determine if resumption occurred, use |SSL_session_reused| instead.
1719
+ // Comparing session IDs will not give the right result in all cases.
1720
+ //
1721
+ // As a workaround for some broken applications, BoringSSL sometimes synthesizes
1722
+ // arbitrary session IDs for non-ID-based sessions. This behavior may be
1723
+ // removed in the future.
1706
1724
  OPENSSL_EXPORT const uint8_t *SSL_SESSION_get_id(const SSL_SESSION *session,
1707
1725
  unsigned *out_len);
1708
1726
 
@@ -3569,7 +3587,7 @@ OPENSSL_EXPORT const char *SSL_early_data_reason_string(
3569
3587
  //
3570
3588
  // ECH support in BoringSSL is still experimental and under development.
3571
3589
  //
3572
- // See https://tools.ietf.org/html/draft-ietf-tls-esni-10.
3590
+ // See https://tools.ietf.org/html/draft-ietf-tls-esni-13.
3573
3591
 
3574
3592
  // SSL_set_enable_ech_grease configures whether the client will send a GREASE
3575
3593
  // ECH extension when no supported ECHConfig is available.
@@ -3601,12 +3619,12 @@ OPENSSL_EXPORT int SSL_set1_ech_config_list(SSL *ssl,
3601
3619
  const uint8_t *ech_config_list,
3602
3620
  size_t ech_config_list_len);
3603
3621
 
3604
- // SSL_get0_ech_name_override sets |*out_name| and |*out_name_len| to point to a
3605
- // buffer containing the ECH public name, if the server rejected ECH, or the
3606
- // empty string otherwise.
3622
+ // SSL_get0_ech_name_override, if |ssl| is a client and the server rejected ECH,
3623
+ // sets |*out_name| and |*out_name_len| to point to a buffer containing the ECH
3624
+ // public name. Otherwise, the buffer will be empty.
3607
3625
  //
3608
- // This function should be called during the certificate verification callback
3609
- // (see |SSL_CTX_set_custom_verify|) if |ssl| is a client offering ECH. If
3626
+ // When offering ECH as a client, this function should be called during the
3627
+ // certificate verification callback (see |SSL_CTX_set_custom_verify|). If
3610
3628
  // |*out_name_len| is non-zero, the caller should verify the certificate against
3611
3629
  // the result, interpreted as a DNS name, rather than the true server name. In
3612
3630
  // this case, the handshake will never succeed and is only used to authenticate
@@ -4894,12 +4912,6 @@ OPENSSL_EXPORT int SSL_set_tmp_ecdh(SSL *ssl, const EC_KEY *ec_key);
4894
4912
  OPENSSL_EXPORT int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *out,
4895
4913
  const char *dir);
4896
4914
 
4897
- // SSL_set_verify_result calls |abort| unless |result| is |X509_V_OK|.
4898
- //
4899
- // TODO(davidben): Remove this function once it has been removed from
4900
- // netty-tcnative.
4901
- OPENSSL_EXPORT void SSL_set_verify_result(SSL *ssl, long result);
4902
-
4903
4915
  // SSL_CTX_enable_tls_channel_id calls |SSL_CTX_set_tls_channel_id_enabled|.
4904
4916
  OPENSSL_EXPORT int SSL_CTX_enable_tls_channel_id(SSL_CTX *ctx);
4905
4917
 
@@ -5554,6 +5566,8 @@ BSSL_NAMESPACE_END
5554
5566
  #define SSL_R_INVALID_ECH_PUBLIC_NAME 317
5555
5567
  #define SSL_R_INVALID_ECH_CONFIG_LIST 318
5556
5568
  #define SSL_R_ECH_REJECTED 319
5569
+ #define SSL_R_OUTER_EXTENSION_NOT_FOUND 320
5570
+ #define SSL_R_INCONSISTENT_ECH_NEGOTIATION 321
5557
5571
  #define SSL_R_SSLV3_ALERT_CLOSE_NOTIFY 1000
5558
5572
  #define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010
5559
5573
  #define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020
@@ -179,28 +179,28 @@ extern "C" {
179
179
  #define TLS1_AD_UNKNOWN_PSK_IDENTITY 115
180
180
  #define TLS1_AD_CERTIFICATE_REQUIRED 116
181
181
  #define TLS1_AD_NO_APPLICATION_PROTOCOL 120
182
- #define TLS1_AD_ECH_REQUIRED 121 // draft-ietf-tls-esni-10
182
+ #define TLS1_AD_ECH_REQUIRED 121 // draft-ietf-tls-esni-13
183
183
 
184
- // ExtensionType values from RFC6066
184
+ // ExtensionType values from RFC 6066
185
185
  #define TLSEXT_TYPE_server_name 0
186
186
  #define TLSEXT_TYPE_status_request 5
187
187
 
188
- // ExtensionType values from RFC4492
188
+ // ExtensionType values from RFC 4492
189
189
  #define TLSEXT_TYPE_ec_point_formats 11
190
190
 
191
- // ExtensionType values from RFC5246
191
+ // ExtensionType values from RFC 5246
192
192
  #define TLSEXT_TYPE_signature_algorithms 13
193
193
 
194
- // ExtensionType value from RFC5764
194
+ // ExtensionType value from RFC 5764
195
195
  #define TLSEXT_TYPE_srtp 14
196
196
 
197
- // ExtensionType value from RFC7301
197
+ // ExtensionType value from RFC 7301
198
198
  #define TLSEXT_TYPE_application_layer_protocol_negotiation 16
199
199
 
200
- // ExtensionType value from RFC7685
200
+ // ExtensionType value from RFC 7685
201
201
  #define TLSEXT_TYPE_padding 21
202
202
 
203
- // ExtensionType value from RFC7627
203
+ // ExtensionType value from RFC 7627
204
204
  #define TLSEXT_TYPE_extended_master_secret 23
205
205
 
206
206
  // ExtensionType value from draft-ietf-quic-tls. Drafts 00 through 32 use
@@ -210,7 +210,7 @@ extern "C" {
210
210
  // use the value 57 which was officially registered with IANA.
211
211
  #define TLSEXT_TYPE_quic_transport_parameters_legacy 0xffa5
212
212
 
213
- // ExtensionType value from RFC9000
213
+ // ExtensionType value from RFC 9000
214
214
  #define TLSEXT_TYPE_quic_transport_parameters 57
215
215
 
216
216
  // TLSEXT_TYPE_quic_transport_parameters_standard is an alias for
@@ -219,13 +219,13 @@ extern "C" {
219
219
  #define TLSEXT_TYPE_quic_transport_parameters_standard \
220
220
  TLSEXT_TYPE_quic_transport_parameters
221
221
 
222
- // ExtensionType value from RFC8879
222
+ // ExtensionType value from RFC 8879
223
223
  #define TLSEXT_TYPE_cert_compression 27
224
224
 
225
- // ExtensionType value from RFC4507
225
+ // ExtensionType value from RFC 4507
226
226
  #define TLSEXT_TYPE_session_ticket 35
227
227
 
228
- // ExtensionType values from RFC8446
228
+ // ExtensionType values from RFC 8446
229
229
  #define TLSEXT_TYPE_supported_groups 10
230
230
  #define TLSEXT_TYPE_pre_shared_key 41
231
231
  #define TLSEXT_TYPE_early_data 42
@@ -236,7 +236,7 @@ extern "C" {
236
236
  #define TLSEXT_TYPE_signature_algorithms_cert 50
237
237
  #define TLSEXT_TYPE_key_share 51
238
238
 
239
- // ExtensionType value from RFC5746
239
+ // ExtensionType value from RFC 5746
240
240
  #define TLSEXT_TYPE_renegotiate 0xff01
241
241
 
242
242
  // ExtensionType value from draft-ietf-tls-subcerts.
@@ -246,13 +246,12 @@ extern "C" {
246
246
  // extension number.
247
247
  #define TLSEXT_TYPE_application_settings 17513
248
248
 
249
- // ExtensionType values from draft-ietf-tls-esni-10. This is not an IANA defined
249
+ // ExtensionType values from draft-ietf-tls-esni-13. This is not an IANA defined
250
250
  // extension number.
251
- #define TLSEXT_TYPE_encrypted_client_hello 0xfe0a
252
- #define TLSEXT_TYPE_ech_is_inner 0xda09
251
+ #define TLSEXT_TYPE_encrypted_client_hello 0xfe0d
253
252
  #define TLSEXT_TYPE_ech_outer_extensions 0xfd00
254
253
 
255
- // ExtensionType value from RFC6962
254
+ // ExtensionType value from RFC 6962
256
255
  #define TLSEXT_TYPE_certificate_timestamp 18
257
256
 
258
257
  // This is not an IANA defined extension number
@@ -313,7 +312,7 @@ extern "C" {
313
312
  #define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065
314
313
  #define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066
315
314
 
316
- // AES ciphersuites from RFC3268
315
+ // AES ciphersuites from RFC 3268
317
316
 
318
317
  #define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F
319
318
  #define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030
@@ -337,7 +336,7 @@ extern "C" {
337
336
  #define TLS1_CK_DH_RSA_WITH_AES_128_SHA256 0x0300003F
338
337
  #define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256 0x03000040
339
338
 
340
- // Camellia ciphersuites from RFC4132
339
+ // Camellia ciphersuites from RFC 4132
341
340
  #define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000041
342
341
  #define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000042
343
342
  #define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000043
@@ -354,7 +353,7 @@ extern "C" {
354
353
  #define TLS1_CK_ADH_WITH_AES_128_SHA256 0x0300006C
355
354
  #define TLS1_CK_ADH_WITH_AES_256_SHA256 0x0300006D
356
355
 
357
- // Camellia ciphersuites from RFC4132
356
+ // Camellia ciphersuites from RFC 4132
358
357
  #define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000084
359
358
  #define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000085
360
359
  #define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000086
@@ -362,7 +361,7 @@ extern "C" {
362
361
  #define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000088
363
362
  #define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA 0x03000089
364
363
 
365
- // SEED ciphersuites from RFC4162
364
+ // SEED ciphersuites from RFC 4162
366
365
  #define TLS1_CK_RSA_WITH_SEED_SHA 0x03000096
367
366
  #define TLS1_CK_DH_DSS_WITH_SEED_SHA 0x03000097
368
367
  #define TLS1_CK_DH_RSA_WITH_SEED_SHA 0x03000098
@@ -370,7 +369,7 @@ extern "C" {
370
369
  #define TLS1_CK_DHE_RSA_WITH_SEED_SHA 0x0300009A
371
370
  #define TLS1_CK_ADH_WITH_SEED_SHA 0x0300009B
372
371
 
373
- // TLS v1.2 GCM ciphersuites from RFC5288
372
+ // TLS v1.2 GCM ciphersuites from RFC 5288
374
373
  #define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256 0x0300009C
375
374
  #define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384 0x0300009D
376
375
  #define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256 0x0300009E
@@ -384,7 +383,7 @@ extern "C" {
384
383
  #define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256 0x030000A6
385
384
  #define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384 0x030000A7
386
385
 
387
- // ECC ciphersuites from RFC4492
386
+ // ECC ciphersuites from RFC 4492
388
387
  #define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001
389
388
  #define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002
390
389
  #define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003
@@ -426,7 +425,7 @@ extern "C" {
426
425
  #define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA 0x0300C021
427
426
  #define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA 0x0300C022
428
427
 
429
- // ECDH HMAC based ciphersuites from RFC5289
428
+ // ECDH HMAC based ciphersuites from RFC 5289
430
429
 
431
430
  #define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256 0x0300C023
432
431
  #define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384 0x0300C024
@@ -437,7 +436,7 @@ extern "C" {
437
436
  #define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256 0x0300C029
438
437
  #define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384 0x0300C02A
439
438
 
440
- // ECDH GCM based ciphersuites from RFC5289
439
+ // ECDH GCM based ciphersuites from RFC 5289
441
440
  #define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02B
442
441
  #define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02C
443
442
  #define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02D
@@ -473,7 +472,7 @@ extern "C" {
473
472
  #define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA"
474
473
  #define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA"
475
474
 
476
- // AES ciphersuites from RFC3268
475
+ // AES ciphersuites from RFC 3268
477
476
  #define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA"
478
477
  #define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA"
479
478
  #define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA"
@@ -488,7 +487,7 @@ extern "C" {
488
487
  #define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA"
489
488
  #define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA"
490
489
 
491
- // ECC ciphersuites from RFC4492
490
+ // ECC ciphersuites from RFC 4492
492
491
  #define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA"
493
492
  #define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA"
494
493
  #define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA"
@@ -540,7 +539,7 @@ extern "C" {
540
539
  #define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA "SRP-RSA-AES-256-CBC-SHA"
541
540
  #define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA "SRP-DSS-AES-256-CBC-SHA"
542
541
 
543
- // Camellia ciphersuites from RFC4132
542
+ // Camellia ciphersuites from RFC 4132
544
543
  #define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA "CAMELLIA128-SHA"
545
544
  #define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA "DH-DSS-CAMELLIA128-SHA"
546
545
  #define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA "DH-RSA-CAMELLIA128-SHA"
@@ -555,7 +554,7 @@ extern "C" {
555
554
  #define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "DHE-RSA-CAMELLIA256-SHA"
556
555
  #define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA "ADH-CAMELLIA256-SHA"
557
556
 
558
- // SEED ciphersuites from RFC4162
557
+ // SEED ciphersuites from RFC 4162
559
558
  #define TLS1_TXT_RSA_WITH_SEED_SHA "SEED-SHA"
560
559
  #define TLS1_TXT_DH_DSS_WITH_SEED_SHA "DH-DSS-SEED-SHA"
561
560
  #define TLS1_TXT_DH_RSA_WITH_SEED_SHA "DH-RSA-SEED-SHA"
@@ -578,7 +577,7 @@ extern "C" {
578
577
  #define TLS1_TXT_ADH_WITH_AES_128_SHA256 "ADH-AES128-SHA256"
579
578
  #define TLS1_TXT_ADH_WITH_AES_256_SHA256 "ADH-AES256-SHA256"
580
579
 
581
- // TLS v1.2 GCM ciphersuites from RFC5288
580
+ // TLS v1.2 GCM ciphersuites from RFC 5288
582
581
  #define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256 "AES128-GCM-SHA256"
583
582
  #define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384 "AES256-GCM-SHA384"
584
583
  #define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256 "DHE-RSA-AES128-GCM-SHA256"
@@ -592,7 +591,7 @@ extern "C" {
592
591
  #define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256 "ADH-AES128-GCM-SHA256"
593
592
  #define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384 "ADH-AES256-GCM-SHA384"
594
593
 
595
- // ECDH HMAC based ciphersuites from RFC5289
594
+ // ECDH HMAC based ciphersuites from RFC 5289
596
595
 
597
596
  #define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256 "ECDHE-ECDSA-AES128-SHA256"
598
597
  #define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384 "ECDHE-ECDSA-AES256-SHA384"
@@ -603,7 +602,7 @@ extern "C" {
603
602
  #define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256 "ECDH-RSA-AES128-SHA256"
604
603
  #define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384 "ECDH-RSA-AES256-SHA384"
605
604
 
606
- // ECDH GCM based ciphersuites from RFC5289
605
+ // ECDH GCM based ciphersuites from RFC 5289
607
606
  #define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 \
608
607
  "ECDHE-ECDSA-AES128-GCM-SHA256"
609
608
  #define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 \