[slice] remove absl_base64 experiment (#36178)

Closes #36178

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36178 from markdroth:b64_remove 0139e3bce8
PiperOrigin-RevId: 619288082
pull/36163/head
Mark D. Roth 11 months ago committed by Copybara-Service
parent ca478bd429
commit e715261ac6
  1. 3
      BUILD
  2. 46
      CMakeLists.txt
  3. 1
      Makefile
  4. 2
      Package.swift
  5. 10
      bazel/experiments.bzl
  6. 17
      build_autogenerated.yaml
  7. 1
      config.m4
  8. 1
      config.w32
  9. 2
      gRPC-C++.podspec
  10. 3
      gRPC-Core.podspec
  11. 2
      grpc.gemspec
  12. 2
      package.xml
  13. 11
      src/core/client_channel/http_proxy_mapper.cc
  14. 12
      src/core/lib/experiments/experiments.cc
  15. 11
      src/core/lib/experiments/experiments.h
  16. 5
      src/core/lib/experiments/experiments.yaml
  17. 2
      src/core/lib/experiments/rollouts.yaml
  18. 20
      src/core/lib/security/credentials/jwt/json_token.cc
  19. 41
      src/core/lib/security/credentials/jwt/jwt_verifier.cc
  20. 239
      src/core/lib/slice/b64.cc
  21. 52
      src/core/lib/slice/b64.h
  22. 1
      src/python/grpcio/grpc_core_dependencies.py
  23. 37
      test/core/slice/BUILD
  24. 6
      test/core/slice/b64_decode_corpus/testcase-5759629707444224
  25. 39
      test/core/slice/b64_decode_fuzzer.cc
  26. 1
      test/core/slice/b64_encode_corpus/testcase-5686577615339520
  27. 37
      test/core/slice/b64_encode_fuzzer.cc
  28. 193
      test/core/slice/b64_test.cc
  29. 2
      tools/doxygen/Doxyfile.c++.internal
  30. 2
      tools/doxygen/Doxyfile.core.internal
  31. 24
      tools/run_tests/generated/tests.json

@ -1919,7 +1919,6 @@ grpc_cc_library(
"//src/core:lib/channel/promise_based_filter.cc",
"//src/core:lib/channel/status_util.cc",
"//src/core:lib/compression/message_compress.cc",
"//src/core:lib/slice/b64.cc",
"//src/core:lib/surface/call.cc",
"//src/core:lib/surface/call_details.cc",
"//src/core:lib/surface/call_log_batch.cc",
@ -1942,7 +1941,6 @@ grpc_cc_library(
"//src/core:lib/channel/promise_based_filter.h",
"//src/core:lib/channel/status_util.h",
"//src/core:lib/compression/message_compress.h",
"//src/core:lib/slice/b64.h",
"//src/core:lib/surface/call.h",
"//src/core:lib/surface/call_test_only.h",
"//src/core:lib/surface/completion_queue.h",
@ -3921,7 +3919,6 @@ grpc_cc_library(
"//src/core:arena_promise",
"//src/core:closure",
"//src/core:error",
"//src/core:experiments",
"//src/core:gpr_manual_constructor",
"//src/core:httpcli_ssl_credentials",
"//src/core:iomgr_fwd",

46
CMakeLists.txt generated

@ -930,7 +930,6 @@ if(gRPC_BUILD_TESTS)
add_dependencies(buildtests_cxx authorization_policy_provider_test)
add_dependencies(buildtests_cxx avl_test)
add_dependencies(buildtests_cxx aws_request_signer_test)
add_dependencies(buildtests_cxx b64_test)
add_dependencies(buildtests_cxx backend_metrics_lb_policy_test)
add_dependencies(buildtests_cxx backoff_test)
add_dependencies(buildtests_cxx bad_ping_test)
@ -2482,7 +2481,6 @@ add_library(grpc
src/core/lib/security/transport/server_auth_filter.cc
src/core/lib/security/transport/tsi_error.cc
src/core/lib/security/util/json_util.cc
src/core/lib/slice/b64.cc
src/core/lib/slice/percent_encoding.cc
src/core/lib/slice/slice.cc
src/core/lib/slice/slice_buffer.cc
@ -3209,7 +3207,6 @@ add_library(grpc_unsecure
src/core/lib/security/transport/server_auth_filter.cc
src/core/lib/security/transport/tsi_error.cc
src/core/lib/security/util/json_util.cc
src/core/lib/slice/b64.cc
src/core/lib/slice/percent_encoding.cc
src/core/lib/slice/slice.cc
src/core/lib/slice/slice_buffer.cc
@ -5318,7 +5315,6 @@ add_library(grpc_authorization_provider
src/core/lib/security/transport/server_auth_filter.cc
src/core/lib/security/transport/tsi_error.cc
src/core/lib/security/util/json_util.cc
src/core/lib/slice/b64.cc
src/core/lib/slice/percent_encoding.cc
src/core/lib/slice/slice.cc
src/core/lib/slice/slice_buffer.cc
@ -7390,48 +7386,6 @@ target_link_libraries(aws_request_signer_test
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(b64_test
test/core/slice/b64_test.cc
)
if(WIN32 AND MSVC)
if(BUILD_SHARED_LIBS)
target_compile_definitions(b64_test
PRIVATE
"GPR_DLL_IMPORTS"
"GRPC_DLL_IMPORTS"
)
endif()
endif()
target_compile_features(b64_test PUBLIC cxx_std_14)
target_include_directories(b64_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(b64_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
grpc_test_util
)
endif()
if(gRPC_BUILD_TESTS)

1
Makefile generated

@ -1379,7 +1379,6 @@ LIBGRPC_SRC = \
src/core/lib/security/transport/server_auth_filter.cc \
src/core/lib/security/transport/tsi_error.cc \
src/core/lib/security/util/json_util.cc \
src/core/lib/slice/b64.cc \
src/core/lib/slice/percent_encoding.cc \
src/core/lib/slice/slice.cc \
src/core/lib/slice/slice_buffer.cc \

2
Package.swift generated

@ -1749,8 +1749,6 @@ let package = Package(
"src/core/lib/security/transport/tsi_error.h",
"src/core/lib/security/util/json_util.cc",
"src/core/lib/security/util/json_util.h",
"src/core/lib/slice/b64.cc",
"src/core/lib/slice/b64.h",
"src/core/lib/slice/percent_encoding.cc",
"src/core/lib/slice/percent_encoding.h",
"src/core/lib/slice/slice.cc",

@ -17,7 +17,6 @@
"""Dictionary of tags to experiments so we know when to test different experiments."""
EXPERIMENT_ENABLES = {
"absl_base64": "absl_base64",
"call_status_override_on_cancellation": "call_status_override_on_cancellation",
"call_v3": "call_v3",
"canary_client_privacy": "canary_client_privacy",
@ -94,9 +93,6 @@ EXPERIMENTS = {
"core_end2end_test": [
"event_engine_listener",
],
"credential_token_tests": [
"absl_base64",
],
"event_engine_listener_test": [
"event_engine_listener",
],
@ -138,9 +134,6 @@ EXPERIMENTS = {
],
},
"on": {
"credential_token_tests": [
"absl_base64",
],
"surface_registered_method_lookup": [
"registered_method_lookup_in_transport",
],
@ -198,9 +191,6 @@ EXPERIMENTS = {
"cpp_end2end_test": [
"work_serializer_dispatch",
],
"credential_token_tests": [
"absl_base64",
],
"event_engine_listener_test": [
"event_engine_listener",
],

@ -1110,7 +1110,6 @@ libs:
- src/core/lib/security/transport/security_handshaker.h
- src/core/lib/security/transport/tsi_error.h
- src/core/lib/security/util/json_util.h
- src/core/lib/slice/b64.h
- src/core/lib/slice/percent_encoding.h
- src/core/lib/slice/slice.h
- src/core/lib/slice/slice_buffer.h
@ -1912,7 +1911,6 @@ libs:
- src/core/lib/security/transport/server_auth_filter.cc
- src/core/lib/security/transport/tsi_error.cc
- src/core/lib/security/util/json_util.cc
- src/core/lib/slice/b64.cc
- src/core/lib/slice/percent_encoding.cc
- src/core/lib/slice/slice.cc
- src/core/lib/slice/slice_buffer.cc
@ -2581,7 +2579,6 @@ libs:
- src/core/lib/security/transport/security_handshaker.h
- src/core/lib/security/transport/tsi_error.h
- src/core/lib/security/util/json_util.h
- src/core/lib/slice/b64.h
- src/core/lib/slice/percent_encoding.h
- src/core/lib/slice/slice.h
- src/core/lib/slice/slice_buffer.h
@ -3003,7 +3000,6 @@ libs:
- src/core/lib/security/transport/server_auth_filter.cc
- src/core/lib/security/transport/tsi_error.cc
- src/core/lib/security/util/json_util.cc
- src/core/lib/slice/b64.cc
- src/core/lib/slice/percent_encoding.cc
- src/core/lib/slice/slice.cc
- src/core/lib/slice/slice_buffer.cc
@ -4659,7 +4655,6 @@ libs:
- src/core/lib/security/transport/security_handshaker.h
- src/core/lib/security/transport/tsi_error.h
- src/core/lib/security/util/json_util.h
- src/core/lib/slice/b64.h
- src/core/lib/slice/percent_encoding.h
- src/core/lib/slice/slice.h
- src/core/lib/slice/slice_buffer.h
@ -4958,7 +4953,6 @@ libs:
- src/core/lib/security/transport/server_auth_filter.cc
- src/core/lib/security/transport/tsi_error.cc
- src/core/lib/security/util/json_util.cc
- src/core/lib/slice/b64.cc
- src/core/lib/slice/percent_encoding.cc
- src/core/lib/slice/slice.cc
- src/core/lib/slice/slice_buffer.cc
@ -5773,17 +5767,6 @@ targets:
deps:
- gtest
- grpc_test_util
- name: b64_test
gtest: true
build: test
language: c++
headers: []
src:
- test/core/slice/b64_test.cc
deps:
- gtest
- grpc_test_util
uses_polling: false
- name: backend_metrics_lb_policy_test
gtest: true
build: test

1
config.m4 generated

@ -754,7 +754,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/security/transport/server_auth_filter.cc \
src/core/lib/security/transport/tsi_error.cc \
src/core/lib/security/util/json_util.cc \
src/core/lib/slice/b64.cc \
src/core/lib/slice/percent_encoding.cc \
src/core/lib/slice/slice.cc \
src/core/lib/slice/slice_buffer.cc \

1
config.w32 generated

@ -719,7 +719,6 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\security\\transport\\server_auth_filter.cc " +
"src\\core\\lib\\security\\transport\\tsi_error.cc " +
"src\\core\\lib\\security\\util\\json_util.cc " +
"src\\core\\lib\\slice\\b64.cc " +
"src\\core\\lib\\slice\\percent_encoding.cc " +
"src\\core\\lib\\slice\\slice.cc " +
"src\\core\\lib\\slice\\slice_buffer.cc " +

2
gRPC-C++.podspec generated

@ -1216,7 +1216,6 @@ Pod::Spec.new do |s|
'src/core/lib/security/transport/security_handshaker.h',
'src/core/lib/security/transport/tsi_error.h',
'src/core/lib/security/util/json_util.h',
'src/core/lib/slice/b64.h',
'src/core/lib/slice/percent_encoding.h',
'src/core/lib/slice/slice.h',
'src/core/lib/slice/slice_buffer.h',
@ -2482,7 +2481,6 @@ Pod::Spec.new do |s|
'src/core/lib/security/transport/security_handshaker.h',
'src/core/lib/security/transport/tsi_error.h',
'src/core/lib/security/util/json_util.h',
'src/core/lib/slice/b64.h',
'src/core/lib/slice/percent_encoding.h',
'src/core/lib/slice/slice.h',
'src/core/lib/slice/slice_buffer.h',

3
gRPC-Core.podspec generated

@ -1861,8 +1861,6 @@ Pod::Spec.new do |s|
'src/core/lib/security/transport/tsi_error.h',
'src/core/lib/security/util/json_util.cc',
'src/core/lib/security/util/json_util.h',
'src/core/lib/slice/b64.cc',
'src/core/lib/slice/b64.h',
'src/core/lib/slice/percent_encoding.cc',
'src/core/lib/slice/percent_encoding.h',
'src/core/lib/slice/slice.cc',
@ -3262,7 +3260,6 @@ Pod::Spec.new do |s|
'src/core/lib/security/transport/security_handshaker.h',
'src/core/lib/security/transport/tsi_error.h',
'src/core/lib/security/util/json_util.h',
'src/core/lib/slice/b64.h',
'src/core/lib/slice/percent_encoding.h',
'src/core/lib/slice/slice.h',
'src/core/lib/slice/slice_buffer.h',

2
grpc.gemspec generated

@ -1751,8 +1751,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/security/transport/tsi_error.h )
s.files += %w( src/core/lib/security/util/json_util.cc )
s.files += %w( src/core/lib/security/util/json_util.h )
s.files += %w( src/core/lib/slice/b64.cc )
s.files += %w( src/core/lib/slice/b64.h )
s.files += %w( src/core/lib/slice/percent_encoding.cc )
s.files += %w( src/core/lib/slice/percent_encoding.h )
s.files += %w( src/core/lib/slice/slice.cc )

2
package.xml generated

@ -1733,8 +1733,6 @@
<file baseinstalldir="/" name="src/core/lib/security/transport/tsi_error.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/util/json_util.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/security/util/json_util.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/b64.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/b64.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/percent_encoding.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/percent_encoding.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/slice/slice.cc" role="src" />

@ -46,13 +46,11 @@
#include "src/core/lib/address_utils/parse_address.h"
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/experiments/experiments.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/env.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/slice/b64.h"
#include "src/core/lib/transport/http_connect_handshaker.h"
#include "src/core/lib/uri/uri_parser.h"
@ -260,14 +258,7 @@ absl::optional<std::string> HttpProxyMapper::MapName(
MaybeAddDefaultPort(absl::StripPrefix(uri->path(), "/")));
if (user_cred.has_value()) {
// Use base64 encoding for user credentials as stated in RFC 7617
std::string encoded_user_cred;
if (IsAbslBase64Enabled()) {
encoded_user_cred = absl::Base64Escape(*user_cred);
} else {
UniquePtr<char> tmp(
grpc_base64_encode(user_cred->data(), user_cred->length(), 0, 0));
encoded_user_cred = tmp.get();
}
std::string encoded_user_cred = absl::Base64Escape(*user_cred);
*args = args->Set(
GRPC_ARG_HTTP_CONNECT_HEADERS,
absl::StrCat("Proxy-Authorization:Basic ", encoded_user_cred));

@ -24,8 +24,6 @@
#if defined(GRPC_CFSTREAM)
namespace {
const char* const description_absl_base64 = "Use abseil base64 functions.";
const char* const additional_constraints_absl_base64 = "{}";
const char* const description_call_status_override_on_cancellation =
"Avoid overriding call status of successfully finished calls if it races "
"with cancellation.";
@ -163,8 +161,6 @@ const bool kDefaultForDebugOnly = true;
namespace grpc_core {
const ExperimentMetadata g_experiment_metadata[] = {
{"absl_base64", description_absl_base64, additional_constraints_absl_base64,
nullptr, 0, true, true},
{"call_status_override_on_cancellation",
description_call_status_override_on_cancellation,
additional_constraints_call_status_override_on_cancellation, nullptr, 0,
@ -248,8 +244,6 @@ const ExperimentMetadata g_experiment_metadata[] = {
#elif defined(GPR_WINDOWS)
namespace {
const char* const description_absl_base64 = "Use abseil base64 functions.";
const char* const additional_constraints_absl_base64 = "{}";
const char* const description_call_status_override_on_cancellation =
"Avoid overriding call status of successfully finished calls if it races "
"with cancellation.";
@ -387,8 +381,6 @@ const bool kDefaultForDebugOnly = true;
namespace grpc_core {
const ExperimentMetadata g_experiment_metadata[] = {
{"absl_base64", description_absl_base64, additional_constraints_absl_base64,
nullptr, 0, true, true},
{"call_status_override_on_cancellation",
description_call_status_override_on_cancellation,
additional_constraints_call_status_override_on_cancellation, nullptr, 0,
@ -472,8 +464,6 @@ const ExperimentMetadata g_experiment_metadata[] = {
#else
namespace {
const char* const description_absl_base64 = "Use abseil base64 functions.";
const char* const additional_constraints_absl_base64 = "{}";
const char* const description_call_status_override_on_cancellation =
"Avoid overriding call status of successfully finished calls if it races "
"with cancellation.";
@ -611,8 +601,6 @@ const bool kDefaultForDebugOnly = true;
namespace grpc_core {
const ExperimentMetadata g_experiment_metadata[] = {
{"absl_base64", description_absl_base64, additional_constraints_absl_base64,
nullptr, 0, true, true},
{"call_status_override_on_cancellation",
description_call_status_override_on_cancellation,
additional_constraints_call_status_override_on_cancellation, nullptr, 0,

@ -57,8 +57,6 @@ namespace grpc_core {
#ifdef GRPC_EXPERIMENTS_ARE_FINAL
#if defined(GRPC_CFSTREAM)
#define GRPC_EXPERIMENT_IS_INCLUDED_ABSL_BASE64
inline bool IsAbslBase64Enabled() { return true; }
#ifndef NDEBUG
#define GRPC_EXPERIMENT_IS_INCLUDED_CALL_STATUS_OVERRIDE_ON_CANCELLATION
#endif
@ -106,8 +104,6 @@ inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; }
inline bool IsWorkSerializerDispatchEnabled() { return false; }
#elif defined(GPR_WINDOWS)
#define GRPC_EXPERIMENT_IS_INCLUDED_ABSL_BASE64
inline bool IsAbslBase64Enabled() { return true; }
#ifndef NDEBUG
#define GRPC_EXPERIMENT_IS_INCLUDED_CALL_STATUS_OVERRIDE_ON_CANCELLATION
#endif
@ -156,8 +152,6 @@ inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; }
inline bool IsWorkSerializerDispatchEnabled() { return false; }
#else
#define GRPC_EXPERIMENT_IS_INCLUDED_ABSL_BASE64
inline bool IsAbslBase64Enabled() { return true; }
#ifndef NDEBUG
#define GRPC_EXPERIMENT_IS_INCLUDED_CALL_STATUS_OVERRIDE_ON_CANCELLATION
#endif
@ -210,7 +204,6 @@ inline bool IsWorkSerializerDispatchEnabled() { return true; }
#else
enum ExperimentIds {
kExperimentIdAbslBase64,
kExperimentIdCallStatusOverrideOnCancellation,
kExperimentIdCallV3,
kExperimentIdCanaryClientPrivacy,
@ -244,10 +237,6 @@ enum ExperimentIds {
kExperimentIdWorkSerializerDispatch,
kNumExperiments
};
#define GRPC_EXPERIMENT_IS_INCLUDED_ABSL_BASE64
inline bool IsAbslBase64Enabled() {
return IsExperimentEnabled(kExperimentIdAbslBase64);
}
#define GRPC_EXPERIMENT_IS_INCLUDED_CALL_STATUS_OVERRIDE_ON_CANCELLATION
inline bool IsCallStatusOverrideOnCancellationEnabled() {
return IsExperimentEnabled(kExperimentIdCallStatusOverrideOnCancellation);

@ -40,11 +40,6 @@
# This file only defines the experiments. Refer to rollouts.yaml for the rollout
# state of each experiment.
- name: absl_base64
description: Use abseil base64 functions.
expiry: 2024/06/01
owner: roth@google.com
test_tags: ["credential_token_tests"]
- name: call_status_override_on_cancellation
description:
Avoid overriding call status of successfully finished calls if it races with

@ -40,8 +40,6 @@
#
# Supported platforms: ios, windows, posix
- name: absl_base64
default: true
- name: call_status_override_on_cancellation
default: debug
- name: call_v3

@ -42,12 +42,10 @@
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
#include "src/core/lib/experiments/experiments.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/json/json_reader.h"
#include "src/core/lib/json/json_writer.h"
#include "src/core/lib/security/util/json_util.h"
#include "src/core/lib/slice/b64.h"
using grpc_core::Json;
@ -183,9 +181,6 @@ static char* encoded_jwt_header(const char* key_id, const char* algorithm) {
{"kid", Json::FromString(key_id)},
});
std::string json_str = grpc_core::JsonDump(json);
if (!grpc_core::IsAbslBase64Enabled()) {
return grpc_base64_encode(json_str.c_str(), json_str.size(), 1, 0);
}
return gpr_strdup(absl::WebSafeBase64Escape(json_str).c_str());
}
@ -214,9 +209,6 @@ static char* encoded_jwt_claim(const grpc_auth_json_key* json_key,
std::string json_str =
grpc_core::JsonDump(Json::FromObject(std::move(object)));
if (!grpc_core::IsAbslBase64Enabled()) {
return grpc_base64_encode(json_str.c_str(), json_str.size(), 1, 0);
}
return gpr_strdup(absl::WebSafeBase64Escape(json_str).c_str());
}
@ -289,14 +281,10 @@ char* compute_and_encode_signature(const grpc_auth_json_key* json_key,
gpr_log(GPR_ERROR, "DigestFinal (signature compute) failed.");
goto end;
}
if (!grpc_core::IsAbslBase64Enabled()) {
result = grpc_base64_encode(sig, sig_len, 1, 0);
} else {
result =
gpr_strdup(absl::WebSafeBase64Escape(
absl::string_view(reinterpret_cast<char*>(sig), sig_len))
.c_str());
}
result =
gpr_strdup(absl::WebSafeBase64Escape(
absl::string_view(reinterpret_cast<char*>(sig), sig_len))
.c_str());
end:
#if OPENSSL_VERSION_NUMBER < 0x30000000L

@ -53,7 +53,6 @@
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
#include "src/core/lib/experiments/experiments.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/memory.h"
@ -68,7 +67,6 @@
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/json/json_reader.h"
#include "src/core/lib/security/credentials/credentials.h" // IWYU pragma: keep
#include "src/core/lib/slice/b64.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/uri/uri_parser.h"
@ -114,19 +112,9 @@ static const EVP_MD* evp_md_from_alg(const char* alg) {
static Json parse_json_part_from_jwt(const char* str, size_t len) {
std::string string;
if (!grpc_core::IsAbslBase64Enabled()) {
grpc_slice slice = grpc_base64_decode_with_len(str, len, 1);
if (GRPC_SLICE_IS_EMPTY(slice)) {
gpr_log(GPR_ERROR, "Invalid base64.");
return Json(); // JSON null
}
string = std::string(grpc_core::StringViewFromSlice(slice));
grpc_core::CSliceUnref(slice);
} else {
if (!absl::WebSafeBase64Unescape(absl::string_view(str, len), &string)) {
gpr_log(GPR_ERROR, "Invalid base64.");
return Json(); // JSON null
}
if (!absl::WebSafeBase64Unescape(absl::string_view(str, len), &string)) {
gpr_log(GPR_ERROR, "Invalid base64.");
return Json(); // JSON null
}
auto json = grpc_core::JsonParse(string);
if (!json.ok()) {
@ -491,18 +479,6 @@ end:
static BIGNUM* bignum_from_base64(const char* b64) {
if (b64 == nullptr) return nullptr;
if (!grpc_core::IsAbslBase64Enabled()) {
grpc_slice bin = grpc_base64_decode(b64, 1);
if (GRPC_SLICE_IS_EMPTY(bin)) {
gpr_log(GPR_ERROR, "Invalid base64 for big num.");
return nullptr;
}
BIGNUM* result =
BN_bin2bn(GRPC_SLICE_START_PTR(bin),
TSI_SIZE_AS_SIZE(GRPC_SLICE_LENGTH(bin)), nullptr);
grpc_core::CSliceUnref(bin);
return result;
}
std::string string;
if (!absl::WebSafeBase64Unescape(b64, &string)) {
gpr_log(GPR_ERROR, "Invalid base64 for big num.");
@ -948,6 +924,7 @@ void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier,
size_t signed_jwt_len;
const char* cur = jwt;
Json json;
std::string signature_str;
GPR_ASSERT(verifier != nullptr && jwt != nullptr && audience != nullptr &&
cb != nullptr);
@ -969,14 +946,8 @@ void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier,
signed_jwt_len = static_cast<size_t>(dot - jwt);
cur = dot + 1;
if (!grpc_core::IsAbslBase64Enabled()) {
signature = grpc_base64_decode(cur, 1);
if (GRPC_SLICE_IS_EMPTY(signature)) goto error;
} else {
std::string signature_str;
if (!absl::WebSafeBase64Unescape(cur, &signature_str)) goto error;
signature = grpc_slice_from_cpp_string(std::move(signature_str));
}
if (!absl::WebSafeBase64Unescape(cur, &signature_str)) goto error;
signature = grpc_slice_from_cpp_string(std::move(signature_str));
retrieve_key_and_verify(
verifier_cb_ctx_create(verifier, pollset, header, claims, audience,
signature, jwt, signed_jwt_len, user_data, cb));

@ -1,239 +0,0 @@
//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#include <grpc/support/port_platform.h>
#include "src/core/lib/slice/b64.h"
#include <stdint.h>
#include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/slice/slice.h"
// --- Constants. ---
static const int8_t base64_bytes[] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 0x3E, -1, -1, -1, 0x3F,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, -1, -1,
-1, 0x7F, -1, -1, -1, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12,
0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, -1, -1, -1, -1, -1,
-1, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
0x31, 0x32, 0x33, -1, -1, -1, -1, -1};
static const char base64_url_unsafe_chars[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char base64_url_safe_chars[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
#define GRPC_BASE64_PAD_CHAR '='
#define GRPC_BASE64_PAD_BYTE 0x7F
#define GRPC_BASE64_MULTILINE_LINE_LEN 76
#define GRPC_BASE64_MULTILINE_NUM_BLOCKS (GRPC_BASE64_MULTILINE_LINE_LEN / 4)
// --- base64 functions. ---
char* grpc_base64_encode(const void* vdata, size_t data_size, int url_safe,
int multiline) {
size_t result_projected_size =
grpc_base64_estimate_encoded_size(data_size, multiline);
char* result = static_cast<char*>(gpr_malloc(result_projected_size));
grpc_base64_encode_core(result, vdata, data_size, url_safe, multiline);
return result;
}
size_t grpc_base64_estimate_encoded_size(size_t data_size, int multiline) {
size_t result_projected_size =
4 * ((data_size + 3) / 3) +
2 * (multiline ? (data_size / (3 * GRPC_BASE64_MULTILINE_NUM_BLOCKS))
: 0) +
1;
return result_projected_size;
}
void grpc_base64_encode_core(char* result, const void* vdata, size_t data_size,
int url_safe, int multiline) {
const unsigned char* data = static_cast<const unsigned char*>(vdata);
const char* base64_chars =
url_safe ? base64_url_safe_chars : base64_url_unsafe_chars;
const size_t result_projected_size =
grpc_base64_estimate_encoded_size(data_size, multiline);
char* current = result;
size_t num_blocks = 0;
size_t i = 0;
// Encode each block.
while (data_size >= 3) {
*current++ = base64_chars[(data[i] >> 2) & 0x3F];
*current++ =
base64_chars[((data[i] & 0x03) << 4) | ((data[i + 1] >> 4) & 0x0F)];
*current++ =
base64_chars[((data[i + 1] & 0x0F) << 2) | ((data[i + 2] >> 6) & 0x03)];
*current++ = base64_chars[data[i + 2] & 0x3F];
data_size -= 3;
i += 3;
if (multiline && (++num_blocks == GRPC_BASE64_MULTILINE_NUM_BLOCKS)) {
*current++ = '\r';
*current++ = '\n';
num_blocks = 0;
}
}
// Take care of the tail.
if (data_size == 2) {
*current++ = base64_chars[(data[i] >> 2) & 0x3F];
*current++ =
base64_chars[((data[i] & 0x03) << 4) | ((data[i + 1] >> 4) & 0x0F)];
*current++ = base64_chars[(data[i + 1] & 0x0F) << 2];
*current++ = GRPC_BASE64_PAD_CHAR;
} else if (data_size == 1) {
*current++ = base64_chars[(data[i] >> 2) & 0x3F];
*current++ = base64_chars[(data[i] & 0x03) << 4];
*current++ = GRPC_BASE64_PAD_CHAR;
*current++ = GRPC_BASE64_PAD_CHAR;
}
GPR_ASSERT(current >= result);
GPR_ASSERT((uintptr_t)(current - result) < result_projected_size);
result[current - result] = '\0';
}
grpc_slice grpc_base64_decode(const char* b64, int url_safe) {
return grpc_base64_decode_with_len(b64, strlen(b64), url_safe);
}
static void decode_one_char(const unsigned char* codes, unsigned char* result,
size_t* result_offset) {
uint32_t packed = (static_cast<uint32_t>(codes[0]) << 2) |
(static_cast<uint32_t>(codes[1]) >> 4);
result[(*result_offset)++] = static_cast<unsigned char>(packed);
}
static void decode_two_chars(const unsigned char* codes, unsigned char* result,
size_t* result_offset) {
uint32_t packed = (static_cast<uint32_t>(codes[0]) << 10) |
(static_cast<uint32_t>(codes[1]) << 4) |
(static_cast<uint32_t>(codes[2]) >> 2);
result[(*result_offset)++] = static_cast<unsigned char>(packed >> 8);
result[(*result_offset)++] = static_cast<unsigned char>(packed);
}
static int decode_group(const unsigned char* codes, size_t num_codes,
unsigned char* result, size_t* result_offset) {
GPR_ASSERT(num_codes <= 4);
// Short end groups that may not have padding.
if (num_codes == 1) {
gpr_log(GPR_ERROR, "Invalid group. Must be at least 2 bytes.");
return 0;
}
if (num_codes == 2) {
decode_one_char(codes, result, result_offset);
return 1;
}
if (num_codes == 3) {
decode_two_chars(codes, result, result_offset);
return 1;
}
// Regular 4 byte groups with padding or not.
GPR_ASSERT(num_codes == 4);
if (codes[0] == GRPC_BASE64_PAD_BYTE || codes[1] == GRPC_BASE64_PAD_BYTE) {
gpr_log(GPR_ERROR, "Invalid padding detected.");
return 0;
}
if (codes[2] == GRPC_BASE64_PAD_BYTE) {
if (codes[3] == GRPC_BASE64_PAD_BYTE) {
decode_one_char(codes, result, result_offset);
} else {
gpr_log(GPR_ERROR, "Invalid padding detected.");
return 0;
}
} else if (codes[3] == GRPC_BASE64_PAD_BYTE) {
decode_two_chars(codes, result, result_offset);
} else {
// No padding.
uint32_t packed = (static_cast<uint32_t>(codes[0]) << 18) |
(static_cast<uint32_t>(codes[1]) << 12) |
(static_cast<uint32_t>(codes[2]) << 6) | codes[3];
result[(*result_offset)++] = static_cast<unsigned char>(packed >> 16);
result[(*result_offset)++] = static_cast<unsigned char>(packed >> 8);
result[(*result_offset)++] = static_cast<unsigned char>(packed);
}
return 1;
}
grpc_slice grpc_base64_decode_with_len(const char* b64, size_t b64_len,
int url_safe) {
grpc_slice result = GRPC_SLICE_MALLOC(b64_len);
unsigned char* current = GRPC_SLICE_START_PTR(result);
size_t result_size = 0;
unsigned char codes[4];
size_t num_codes = 0;
while (b64_len--) {
unsigned char c = static_cast<unsigned char>(*b64++);
signed char code;
if (c >= GPR_ARRAY_SIZE(base64_bytes)) continue;
if (url_safe) {
if (c == '+' || c == '/') {
gpr_log(GPR_ERROR, "Invalid character for url safe base64 %c", c);
goto fail;
}
if (c == '-') {
c = '+';
} else if (c == '_') {
c = '/';
}
}
code = base64_bytes[c];
if (code == -1) {
if (c != '\r' && c != '\n') {
gpr_log(GPR_ERROR, "Invalid character %c", c);
goto fail;
}
} else {
codes[num_codes++] = static_cast<unsigned char>(code);
if (num_codes == 4) {
if (!decode_group(codes, num_codes, current, &result_size)) goto fail;
num_codes = 0;
}
}
}
if (num_codes != 0 &&
!decode_group(codes, num_codes, current, &result_size)) {
goto fail;
}
GRPC_SLICE_SET_LENGTH(result, result_size);
return result;
fail:
grpc_core::CSliceUnref(result);
return grpc_empty_slice();
}

@ -1,52 +0,0 @@
//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#ifndef GRPC_SRC_CORE_LIB_SLICE_B64_H
#define GRPC_SRC_CORE_LIB_SLICE_B64_H
#include <grpc/support/port_platform.h>
#include <stddef.h>
#include <grpc/slice.h>
// Encodes data using base64. It is the caller's responsibility to free
// the returned char * using gpr_free. Returns NULL on NULL input.
// TODO(makdharma) : change the flags to bool from int
char* grpc_base64_encode(const void* data, size_t data_size, int url_safe,
int multiline);
// estimate the upper bound on size of base64 encoded data. The actual size
// is guaranteed to be less than or equal to the size returned here.
size_t grpc_base64_estimate_encoded_size(size_t data_size, int multiline);
// Encodes data using base64 and write it to memory pointed to by result. It is
// the caller's responsibility to allocate enough memory in |result| to fit the
// encoded data.
void grpc_base64_encode_core(char* result, const void* vdata, size_t data_size,
int url_safe, int multiline);
// Decodes data according to the base64 specification. Returns an empty
// slice in case of failure.
grpc_slice grpc_base64_decode(const char* b64, int url_safe);
// Same as above except that the length is provided by the caller.
grpc_slice grpc_base64_decode_with_len(const char* b64, size_t b64_len,
int url_safe);
#endif // GRPC_SRC_CORE_LIB_SLICE_B64_H

@ -728,7 +728,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/security/transport/server_auth_filter.cc',
'src/core/lib/security/transport/tsi_error.cc',
'src/core/lib/security/util/json_util.cc',
'src/core/lib/slice/b64.cc',
'src/core/lib/slice/percent_encoding.cc',
'src/core/lib/slice/slice.cc',
'src/core/lib/slice/slice_buffer.cc',

@ -19,28 +19,6 @@ grpc_package(name = "test/core/slice")
licenses(["notice"])
grpc_fuzzer(
name = "b64_encode_fuzzer",
srcs = ["b64_encode_fuzzer.cc"],
corpus = "b64_encode_corpus",
language = "C++",
tags = ["no_windows"],
deps = [
"//:grpc",
],
)
grpc_fuzzer(
name = "b64_decode_fuzzer",
srcs = ["b64_decode_fuzzer.cc"],
corpus = "b64_decode_corpus",
language = "C++",
tags = ["no_windows"],
deps = [
"//:grpc",
],
)
grpc_fuzzer(
name = "percent_encode_fuzzer",
srcs = ["percent_encode_fuzzer.cc"],
@ -138,18 +116,3 @@ grpc_cc_test(
"//test/core/util:grpc_test_util",
],
)
grpc_cc_test(
name = "b64_test",
srcs = ["b64_test.cc"],
external_deps = ["gtest"],
language = "C++",
uses_event_engine = False,
uses_polling = False,
deps = [
"//:gpr",
"//:grpc",
"//src/core:slice",
"//test/core/util:grpc_test_util",
],
)

@ -1,39 +0,0 @@
//
//
// Copyright 2019 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#include <stddef.h>
#include <stdint.h>
#include <grpc/grpc.h>
#include <grpc/slice.h>
#include "src/core/lib/slice/b64.h"
bool squelch = true;
bool leak_check = true;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (size < 1) return 0;
grpc_init();
const bool url_safe = static_cast<uint8_t>(0x100) < data[0];
grpc_slice res = grpc_base64_decode_with_len(
reinterpret_cast<const char*>(data + 1), size - 1, url_safe);
grpc_slice_unref(res);
grpc_shutdown();
return 0;
}

@ -1,37 +0,0 @@
//
//
// Copyright 2019 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#include <stddef.h>
#include <stdint.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/slice/b64.h"
bool squelch = true;
bool leak_check = true;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (size < 2) return 0;
const bool url_safe = static_cast<uint8_t>(0x100) < data[0];
const bool multiline = static_cast<uint8_t>(0x100) < data[1];
char* res = grpc_base64_encode(reinterpret_cast<const char*>(data + 2),
size - 2, url_safe, multiline);
gpr_free(res);
return 0;
}

@ -1,193 +0,0 @@
//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#include "src/core/lib/slice/b64.h"
#include <stdint.h>
#include <string.h>
#include <memory>
#include "absl/strings/string_view.h"
#include "gtest/gtest.h"
#include <grpc/slice.h>
#include <grpc/support/alloc.h>
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/slice/slice_internal.h"
#include "test/core/util/test_config.h"
static void test_simple_encode_decode_b64(int url_safe, int multiline) {
const char* hello = "hello";
char* hello_b64 =
grpc_base64_encode(hello, strlen(hello), url_safe, multiline);
grpc_core::ExecCtx exec_ctx;
grpc_slice hello_slice = grpc_base64_decode(hello_b64, url_safe);
ASSERT_EQ(grpc_core::StringViewFromSlice(hello_slice),
absl::string_view(hello));
grpc_slice_unref(hello_slice);
gpr_free(hello_b64);
}
static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
unsigned char orig[256];
size_t i;
char* b64;
grpc_slice orig_decoded;
for (i = 0; i < sizeof(orig); i++) orig[i] = static_cast<uint8_t>(i);
// Try all the different paddings.
for (i = 0; i < 3; i++) {
grpc_core::ExecCtx exec_ctx;
b64 = grpc_base64_encode(orig, sizeof(orig) - i, url_safe, multiline);
orig_decoded = grpc_base64_decode(b64, url_safe);
ASSERT_EQ(
grpc_core::StringViewFromSlice(orig_decoded),
absl::string_view(reinterpret_cast<char*>(orig), sizeof(orig) - i));
grpc_slice_unref(orig_decoded);
gpr_free(b64);
}
}
TEST(B64Test, SimpleEncodeDecodeB64NoMultiline) {
test_simple_encode_decode_b64(0, 0);
}
TEST(B64Test, SimpleEncodeDecodeB64Multiline) {
test_simple_encode_decode_b64(0, 1);
}
TEST(B64Test, SimpleEncodeDecodeB64UrlsafeNoMultiline) {
test_simple_encode_decode_b64(1, 0);
}
TEST(B64Test, SimpleEncodeDecodeB64UrlsafeMultiline) {
test_simple_encode_decode_b64(1, 1);
}
TEST(B64Test, FullRangeEncodeDecodeB64NoMultiline) {
test_full_range_encode_decode_b64(0, 0);
}
TEST(B64Test, FullRangeEncodeDecodeB64Multiline) {
test_full_range_encode_decode_b64(0, 1);
}
TEST(B64Test, FullRangeEncodeDecodeB64UrlsafeNoMultiline) {
test_full_range_encode_decode_b64(1, 0);
}
TEST(B64Test, FullRangeEncodeDecodeB64UrlsafeMultiline) {
test_full_range_encode_decode_b64(1, 1);
}
TEST(B64Test, UrlSafeUnsafeMismatchFailure) {
unsigned char orig[256];
size_t i;
char* b64;
grpc_slice orig_decoded;
int url_safe = 1;
for (i = 0; i < sizeof(orig); i++) orig[i] = static_cast<uint8_t>(i);
grpc_core::ExecCtx exec_ctx;
b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0);
orig_decoded = grpc_base64_decode(b64, !url_safe);
ASSERT_TRUE(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
grpc_slice_unref(orig_decoded);
b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0);
orig_decoded = grpc_base64_decode(b64, url_safe);
ASSERT_TRUE(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
grpc_slice_unref(orig_decoded);
}
TEST(B64Test, Rfc4648TestVectors) {
char* b64;
b64 = grpc_base64_encode("", 0, 0, 0);
ASSERT_STREQ("", b64);
gpr_free(b64);
b64 = grpc_base64_encode("f", 1, 0, 0);
ASSERT_STREQ("Zg==", b64);
gpr_free(b64);
b64 = grpc_base64_encode("fo", 2, 0, 0);
ASSERT_STREQ("Zm8=", b64);
gpr_free(b64);
b64 = grpc_base64_encode("foo", 3, 0, 0);
ASSERT_STREQ("Zm9v", b64);
gpr_free(b64);
b64 = grpc_base64_encode("foob", 4, 0, 0);
ASSERT_STREQ("Zm9vYg==", b64);
gpr_free(b64);
b64 = grpc_base64_encode("fooba", 5, 0, 0);
ASSERT_STREQ("Zm9vYmE=", b64);
gpr_free(b64);
b64 = grpc_base64_encode("foobar", 6, 0, 0);
ASSERT_STREQ("Zm9vYmFy", b64);
gpr_free(b64);
}
TEST(B64Test, UnpaddedDecode) {
grpc_slice decoded;
grpc_core::ExecCtx exec_ctx;
decoded = grpc_base64_decode("Zm9vYmFy", 0);
ASSERT_EQ(grpc_core::StringViewFromSlice(decoded), "foobar");
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("Zm9vYmE", 0);
ASSERT_EQ(grpc_core::StringViewFromSlice(decoded), "fooba");
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("Zm9vYg", 0);
ASSERT_EQ(grpc_core::StringViewFromSlice(decoded), "foob");
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("Zm9v", 0);
ASSERT_EQ(grpc_core::StringViewFromSlice(decoded), "foo");
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("Zm8", 0);
ASSERT_EQ(grpc_core::StringViewFromSlice(decoded), "fo");
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("Zg", 0);
ASSERT_EQ(grpc_core::StringViewFromSlice(decoded), "f");
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("", 0);
ASSERT_TRUE(GRPC_SLICE_IS_EMPTY(decoded));
}
int main(int argc, char** argv) {
grpc::testing::TestEnvironment env(&argc, argv);
::testing::InitGoogleTest(&argc, argv);
grpc::testing::TestGrpcScope grpc_scope;
return RUN_ALL_TESTS();
}

@ -2750,8 +2750,6 @@ src/core/lib/security/transport/tsi_error.cc \
src/core/lib/security/transport/tsi_error.h \
src/core/lib/security/util/json_util.cc \
src/core/lib/security/util/json_util.h \
src/core/lib/slice/b64.cc \
src/core/lib/slice/b64.h \
src/core/lib/slice/percent_encoding.cc \
src/core/lib/slice/percent_encoding.h \
src/core/lib/slice/slice.cc \

@ -2525,8 +2525,6 @@ src/core/lib/security/transport/tsi_error.cc \
src/core/lib/security/transport/tsi_error.h \
src/core/lib/security/util/json_util.cc \
src/core/lib/security/util/json_util.h \
src/core/lib/slice/b64.cc \
src/core/lib/slice/b64.h \
src/core/lib/slice/percent_encoding.cc \
src/core/lib/slice/percent_encoding.h \
src/core/lib/slice/slice.cc \

@ -779,30 +779,6 @@
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": true,
"language": "c++",
"name": "b64_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": false
},
{
"args": [],
"benchmark": false,

Loading…
Cancel
Save