Use SSL_early_data_reason_string in EarlyDataReasonToString. ssl_early_data_reason_t is an extensible enum. Maintaining a switch-case in QUICHE means compile failures and general churn when BoringSSL adds new values, switch to the newly-added SSL_early_data_reason_string function. This is gated by a BORINGSSL_API_VERSION preprocessor check to smooth the landing between downstream repositories. (QUICHE is incompatible with BoringSSL HEAD due to the addition of ssl_early_data_reason_alps. This CL unblocks the update.) Once https://boringssl-review.googlesource.com/c/boringssl/+/43724 has rolled into all downstream repositories, we can remove the preprocessor check. PiperOrigin-RevId: 340322863 Change-Id: Ie139b5515ac2bc50f21c7cf682fa0f1a3993fd82
diff --git a/quic/core/crypto/crypto_utils.cc b/quic/core/crypto/crypto_utils.cc index 8445a6c..904a3c4 100644 --- a/quic/core/crypto/crypto_utils.cc +++ b/quic/core/crypto/crypto_utils.cc
@@ -737,6 +737,15 @@ // static const char* CryptoUtils::EarlyDataReasonToString( ssl_early_data_reason_t reason) { +#if BORINGSSL_API_VERSION >= 12 + const char* reason_string = SSL_early_data_reason_string(reason); + if (reason_string != nullptr) { + return reason_string; + } +#else + // TODO(davidben): Remove this logic once + // https://boringssl-review.googlesource.com/c/boringssl/+/43724 has landed in + // downstream repositories. switch (reason) { RETURN_STRING_LITERAL(ssl_early_data_unknown); RETURN_STRING_LITERAL(ssl_early_data_disabled); @@ -753,6 +762,7 @@ RETURN_STRING_LITERAL(ssl_early_data_ticket_age_skew); RETURN_STRING_LITERAL(ssl_early_data_quic_parameter_mismatch); } +#endif QUIC_BUG_IF(reason < 0 || reason > ssl_early_data_reason_max_value) << "Unknown ssl_early_data_reason_t " << reason; return "unknown ssl_early_data_reason_t";