From a809ea5c14d0e0d3b2ec5756626dadddfee6f4d6 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Tue, 28 Mar 2017 02:02:45 -0700 Subject: Add max_age_filter --- build.yaml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'build.yaml') diff --git a/build.yaml b/build.yaml index 650f127492..059221cd72 100644 --- a/build.yaml +++ b/build.yaml @@ -186,6 +186,7 @@ filegroups: - src/core/lib/channel/handshaker_registry.h - src/core/lib/channel/http_client_filter.h - src/core/lib/channel/http_server_filter.h + - src/core/lib/channel/max_age_filter.h - src/core/lib/channel/message_size_filter.h - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/message_compress.h @@ -295,6 +296,7 @@ filegroups: - src/core/lib/channel/handshaker_registry.c - src/core/lib/channel/http_client_filter.c - src/core/lib/channel/http_server_filter.c + - src/core/lib/channel/max_age_filter.c - src/core/lib/channel/message_size_filter.c - src/core/lib/compression/compression.c - src/core/lib/compression/message_compress.c -- cgit v1.2.3 From 29b527fa306fd46be0120e6c1322b813969e5e4e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 30 Mar 2017 10:27:20 -0700 Subject: Reinstate one check, fix fall out --- BUILD | 8 +- CMakeLists.txt | 10 +- Makefile | 10 +- binding.gyp | 2 +- build.yaml | 11 +- config.m4 | 2 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- package.xml | 4 +- src/core/lib/channel/http_client_filter.c | 2 +- src/core/lib/channel/http_server_filter.c | 2 +- src/core/lib/security/credentials/jwt/json_token.c | 2 +- .../lib/security/credentials/jwt/jwt_verifier.c | 2 +- src/core/lib/security/util/b64.c | 251 --------------------- src/core/lib/security/util/b64.h | 65 ------ src/core/lib/slice/b64.c | 251 +++++++++++++++++++++ src/core/lib/slice/b64.h | 65 ++++++ src/cpp/common/channel_filter.h | 11 - src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/security/b64_test.c | 234 ------------------- test/core/security/json_token_test.c | 2 +- test/core/security/jwt_verifier_test.c | 2 +- test/core/slice/b64_test.c | 234 +++++++++++++++++++ tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 17 +- .../run_tests/sanity/check_sources_and_headers.py | 2 +- 26 files changed, 601 insertions(+), 604 deletions(-) delete mode 100644 src/core/lib/security/util/b64.c delete mode 100644 src/core/lib/security/util/b64.h create mode 100644 src/core/lib/slice/b64.c create mode 100644 src/core/lib/slice/b64.h delete mode 100644 test/core/security/b64_test.c create mode 100644 test/core/slice/b64_test.c (limited to 'build.yaml') diff --git a/BUILD b/BUILD index f6187e0998..5f89638946 100644 --- a/BUILD +++ b/BUILD @@ -511,7 +511,7 @@ grpc_cc_library( "src/core/lib/json/json_reader.c", "src/core/lib/json/json_string.c", "src/core/lib/json/json_writer.c", - "src/core/lib/security/util/b64.c", + "src/core/lib/slice/b64.c", "src/core/lib/slice/percent_encoding.c", "src/core/lib/slice/slice.c", "src/core/lib/slice/slice_buffer.c", @@ -630,7 +630,7 @@ grpc_cc_library( "src/core/lib/json/json_common.h", "src/core/lib/json/json_reader.h", "src/core/lib/json/json_writer.h", - "src/core/lib/security/util/b64.h", + "src/core/lib/slice/b64.h", "src/core/lib/slice/percent_encoding.h", "src/core/lib/slice/slice_hash_table.h", "src/core/lib/slice/slice_internal.h", @@ -911,7 +911,7 @@ grpc_cc_library( "src/core/lib/security/transport/security_handshaker.c", "src/core/lib/security/transport/server_auth_filter.c", "src/core/lib/security/transport/tsi_error.c", - "src/core/lib/security/util/b64.c", + "src/core/lib/slice/b64.c", "src/core/lib/security/util/json_util.c", "src/core/lib/surface/init_secure.c", ], @@ -934,7 +934,7 @@ grpc_cc_library( "src/core/lib/security/transport/security_connector.h", "src/core/lib/security/transport/security_handshaker.h", "src/core/lib/security/transport/tsi_error.h", - "src/core/lib/security/util/b64.h", + "src/core/lib/slice/b64.h", "src/core/lib/security/util/json_util.h", ], language = "c", diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b8e49e126..8b3f4c809b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -993,7 +993,7 @@ add_library(grpc src/core/lib/json/json_reader.c src/core/lib/json/json_string.c src/core/lib/json/json_writer.c - src/core/lib/security/util/b64.c + src/core/lib/slice/b64.c src/core/lib/slice/percent_encoding.c src/core/lib/slice/slice.c src/core/lib/slice/slice_buffer.c @@ -1314,7 +1314,7 @@ add_library(grpc_cronet src/core/lib/json/json_reader.c src/core/lib/json/json_string.c src/core/lib/json/json_writer.c - src/core/lib/security/util/b64.c + src/core/lib/slice/b64.c src/core/lib/slice/percent_encoding.c src/core/lib/slice/slice.c src/core/lib/slice/slice_buffer.c @@ -1622,7 +1622,7 @@ add_library(grpc_test_util src/core/lib/json/json_reader.c src/core/lib/json/json_string.c src/core/lib/json/json_writer.c - src/core/lib/security/util/b64.c + src/core/lib/slice/b64.c src/core/lib/slice/percent_encoding.c src/core/lib/slice/slice.c src/core/lib/slice/slice_buffer.c @@ -1882,7 +1882,7 @@ add_library(grpc_unsecure src/core/lib/json/json_reader.c src/core/lib/json/json_string.c src/core/lib/json/json_writer.c - src/core/lib/security/util/b64.c + src/core/lib/slice/b64.c src/core/lib/slice/percent_encoding.c src/core/lib/slice/slice.c src/core/lib/slice/slice_buffer.c @@ -2513,7 +2513,7 @@ add_library(grpc++_cronet src/core/lib/json/json_reader.c src/core/lib/json/json_string.c src/core/lib/json/json_writer.c - src/core/lib/security/util/b64.c + src/core/lib/slice/b64.c src/core/lib/slice/percent_encoding.c src/core/lib/slice/slice.c src/core/lib/slice/slice_buffer.c diff --git a/Makefile b/Makefile index c3c568ce09..fc5e63207f 100644 --- a/Makefile +++ b/Makefile @@ -2887,7 +2887,7 @@ LIBGRPC_SRC = \ src/core/lib/json/json_reader.c \ src/core/lib/json/json_string.c \ src/core/lib/json/json_writer.c \ - src/core/lib/security/util/b64.c \ + src/core/lib/slice/b64.c \ src/core/lib/slice/percent_encoding.c \ src/core/lib/slice/slice.c \ src/core/lib/slice/slice_buffer.c \ @@ -3206,7 +3206,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/json/json_reader.c \ src/core/lib/json/json_string.c \ src/core/lib/json/json_writer.c \ - src/core/lib/security/util/b64.c \ + src/core/lib/slice/b64.c \ src/core/lib/slice/percent_encoding.c \ src/core/lib/slice/slice.c \ src/core/lib/slice/slice_buffer.c \ @@ -3513,7 +3513,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/json/json_reader.c \ src/core/lib/json/json_string.c \ src/core/lib/json/json_writer.c \ - src/core/lib/security/util/b64.c \ + src/core/lib/slice/b64.c \ src/core/lib/slice/percent_encoding.c \ src/core/lib/slice/slice.c \ src/core/lib/slice/slice_buffer.c \ @@ -3745,7 +3745,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/json/json_reader.c \ src/core/lib/json/json_string.c \ src/core/lib/json/json_writer.c \ - src/core/lib/security/util/b64.c \ + src/core/lib/slice/b64.c \ src/core/lib/slice/percent_encoding.c \ src/core/lib/slice/slice.c \ src/core/lib/slice/slice_buffer.c \ @@ -4362,7 +4362,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/json/json_reader.c \ src/core/lib/json/json_string.c \ src/core/lib/json/json_writer.c \ - src/core/lib/security/util/b64.c \ + src/core/lib/slice/b64.c \ src/core/lib/slice/percent_encoding.c \ src/core/lib/slice/slice.c \ src/core/lib/slice/slice_buffer.c \ diff --git a/binding.gyp b/binding.gyp index f1cef607ec..e01142da54 100644 --- a/binding.gyp +++ b/binding.gyp @@ -700,7 +700,7 @@ 'src/core/lib/json/json_reader.c', 'src/core/lib/json/json_string.c', 'src/core/lib/json/json_writer.c', - 'src/core/lib/security/util/b64.c', + 'src/core/lib/slice/b64.c', 'src/core/lib/slice/percent_encoding.c', 'src/core/lib/slice/slice.c', 'src/core/lib/slice/slice_buffer.c', diff --git a/build.yaml b/build.yaml index 6a89b71fb2..0febc5e6e1 100644 --- a/build.yaml +++ b/build.yaml @@ -252,6 +252,7 @@ filegroups: - src/core/lib/json/json_common.h - src/core/lib/json/json_reader.h - src/core/lib/json/json_writer.h + - src/core/lib/slice/b64.h - src/core/lib/slice/percent_encoding.h - src/core/lib/slice/slice_hash_table.h - src/core/lib/slice/slice_internal.h @@ -369,7 +370,7 @@ filegroups: - src/core/lib/json/json_reader.c - src/core/lib/json/json_string.c - src/core/lib/json/json_writer.c - - src/core/lib/security/util/b64.c + - src/core/lib/slice/b64.c - src/core/lib/slice/percent_encoding.c - src/core/lib/slice/slice.c - src/core/lib/slice/slice_buffer.c @@ -497,6 +498,7 @@ filegroups: plugin: grpc_lb_policy_grpclb uses: - grpc_base + - grpc_secure - grpc_client_channel - nanopb - name: grpc_lb_policy_pick_first @@ -571,7 +573,6 @@ filegroups: - src/core/lib/security/transport/security_connector.h - src/core/lib/security/transport/security_handshaker.h - src/core/lib/security/transport/tsi_error.h - - src/core/lib/security/util/b64.h - src/core/lib/security/util/json_util.h src: - src/core/lib/http/httpcli_security_connector.c @@ -596,7 +597,6 @@ filegroups: - src/core/lib/security/transport/security_handshaker.c - src/core/lib/security/transport/server_auth_filter.c - src/core/lib/security/transport/tsi_error.c - - src/core/lib/security/util/b64.c - src/core/lib/security/util/json_util.c - src/core/lib/surface/init_secure.c secure: true @@ -701,6 +701,7 @@ filegroups: uses: - grpc_transport_chttp2 - grpc_base + - grpc_client_channel - name: grpc_transport_chttp2_client_insecure src: - src/core/ext/transport/chttp2/client/insecure/channel_create.c @@ -874,6 +875,8 @@ filegroups: - src/cpp/util/time_cc.cc uses: - grpc++_codegen_base + - grpc_base + - nanopb - name: grpc++_codegen_base language: c++ public_headers: @@ -2036,7 +2039,7 @@ targets: build: test language: c src: - - test/core/security/b64_test.c + - test/core/slice/b64_test.c deps: - grpc_test_util - grpc diff --git a/config.m4 b/config.m4 index 6ce7d70c5b..5a3091f575 100644 --- a/config.m4 +++ b/config.m4 @@ -168,7 +168,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/json/json_reader.c \ src/core/lib/json/json_string.c \ src/core/lib/json/json_writer.c \ - src/core/lib/security/util/b64.c \ + src/core/lib/slice/b64.c \ src/core/lib/slice/percent_encoding.c \ src/core/lib/slice/slice.c \ src/core/lib/slice/slice_buffer.c \ diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 97bd3c2864..de69f1a21c 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -402,7 +402,7 @@ Pod::Spec.new do |s| 'src/core/lib/security/transport/security_connector.h', 'src/core/lib/security/transport/security_handshaker.h', 'src/core/lib/security/transport/tsi_error.h', - 'src/core/lib/security/util/b64.h', + 'src/core/lib/slice/b64.h', 'src/core/lib/security/util/json_util.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', @@ -543,7 +543,7 @@ Pod::Spec.new do |s| 'src/core/lib/json/json_reader.c', 'src/core/lib/json/json_string.c', 'src/core/lib/json/json_writer.c', - 'src/core/lib/security/util/b64.c', + 'src/core/lib/slice/b64.c', 'src/core/lib/slice/percent_encoding.c', 'src/core/lib/slice/slice.c', 'src/core/lib/slice/slice_buffer.c', @@ -850,7 +850,7 @@ Pod::Spec.new do |s| 'src/core/lib/security/transport/security_connector.h', 'src/core/lib/security/transport/security_handshaker.h', 'src/core/lib/security/transport/tsi_error.h', - 'src/core/lib/security/util/b64.h', + 'src/core/lib/slice/b64.h', 'src/core/lib/security/util/json_util.h', 'src/core/tsi/fake_transport_security.h', 'src/core/tsi/ssl_transport_security.h', diff --git a/grpc.gemspec b/grpc.gemspec index cb51da1b57..66489ca3c7 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -318,7 +318,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/security/transport/security_connector.h ) s.files += %w( src/core/lib/security/transport/security_handshaker.h ) s.files += %w( src/core/lib/security/transport/tsi_error.h ) - s.files += %w( src/core/lib/security/util/b64.h ) + s.files += %w( src/core/lib/slice/b64.h ) s.files += %w( src/core/lib/security/util/json_util.h ) s.files += %w( src/core/tsi/fake_transport_security.h ) s.files += %w( src/core/tsi/ssl_transport_security.h ) @@ -459,7 +459,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/json/json_reader.c ) s.files += %w( src/core/lib/json/json_string.c ) s.files += %w( src/core/lib/json/json_writer.c ) - s.files += %w( src/core/lib/security/util/b64.c ) + s.files += %w( src/core/lib/slice/b64.c ) s.files += %w( src/core/lib/slice/percent_encoding.c ) s.files += %w( src/core/lib/slice/slice.c ) s.files += %w( src/core/lib/slice/slice_buffer.c ) diff --git a/package.xml b/package.xml index afac1800be..4fea42ee87 100644 --- a/package.xml +++ b/package.xml @@ -327,7 +327,7 @@ - + @@ -468,7 +468,7 @@ - + diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index 967904df1e..17af2013d9 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -36,7 +36,7 @@ #include #include #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/security/util/b64.h" +#include "src/core/lib/slice/b64.h" #include "src/core/lib/slice/percent_encoding.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c index 8d3c488ea0..6b1a02efa1 100644 --- a/src/core/lib/channel/http_server_filter.c +++ b/src/core/lib/channel/http_server_filter.c @@ -37,7 +37,7 @@ #include #include #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/security/util/b64.h" +#include "src/core/lib/slice/b64.h" #include "src/core/lib/slice/percent_encoding.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" diff --git a/src/core/lib/security/credentials/jwt/json_token.c b/src/core/lib/security/credentials/jwt/json_token.c index 192a5f47ed..9749e2b09b 100644 --- a/src/core/lib/security/credentials/jwt/json_token.c +++ b/src/core/lib/security/credentials/jwt/json_token.c @@ -40,7 +40,7 @@ #include #include -#include "src/core/lib/security/util/b64.h" +#include "src/core/lib/slice/b64.h" #include "src/core/lib/security/util/json_util.h" #include "src/core/lib/support/string.h" diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.c b/src/core/lib/security/credentials/jwt/jwt_verifier.c index b10a5da2a2..0e2a264371 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.c +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.c @@ -45,7 +45,7 @@ #include "src/core/lib/http/httpcli.h" #include "src/core/lib/iomgr/polling_entity.h" -#include "src/core/lib/security/util/b64.h" +#include "src/core/lib/slice/b64.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/support/string.h" #include "src/core/tsi/ssl_types.h" diff --git a/src/core/lib/security/util/b64.c b/src/core/lib/security/util/b64.c deleted file mode 100644 index 0d5a917660..0000000000 --- a/src/core/lib/security/util/b64.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "src/core/lib/security/util/b64.h" - -#include -#include - -#include -#include -#include - -#include "src/core/lib/slice/slice_internal.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, url_safe, multiline); - char *result = 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 url_safe, - 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 = 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, url_safe, 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(grpc_exec_ctx *exec_ctx, const char *b64, - int url_safe) { - return grpc_base64_decode_with_len(exec_ctx, b64, strlen(b64), url_safe); -} - -static void decode_one_char(const unsigned char *codes, unsigned char *result, - size_t *result_offset) { - uint32_t packed = ((uint32_t)codes[0] << 2) | ((uint32_t)codes[1] >> 4); - result[(*result_offset)++] = (unsigned char)packed; -} - -static void decode_two_chars(const unsigned char *codes, unsigned char *result, - size_t *result_offset) { - uint32_t packed = ((uint32_t)codes[0] << 10) | ((uint32_t)codes[1] << 4) | - ((uint32_t)codes[2] >> 2); - result[(*result_offset)++] = (unsigned char)(packed >> 8); - result[(*result_offset)++] = (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 = ((uint32_t)codes[0] << 18) | ((uint32_t)codes[1] << 12) | - ((uint32_t)codes[2] << 6) | codes[3]; - result[(*result_offset)++] = (unsigned char)(packed >> 16); - result[(*result_offset)++] = (unsigned char)(packed >> 8); - result[(*result_offset)++] = (unsigned char)(packed); - } - return 1; -} - -grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx *exec_ctx, 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 = (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++] = (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_slice_unref_internal(exec_ctx, result); - return grpc_empty_slice(); -} diff --git a/src/core/lib/security/util/b64.h b/src/core/lib/security/util/b64.h deleted file mode 100644 index ef52291c6a..0000000000 --- a/src/core/lib/security/util/b64.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_CORE_LIB_SECURITY_UTIL_B64_H -#define GRPC_CORE_LIB_SECURITY_UTIL_B64_H - -#include - -/* Encodes data using base64. It is the caller's responsability 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 url_safe, - int multiline); - -/* Encodes data using base64 and write it to memory pointed to by result. It is - * the caller's responsiblity 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(grpc_exec_ctx *exec_ctx, 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(grpc_exec_ctx *exec_ctx, const char *b64, - size_t b64_len, int url_safe); - -#endif /* GRPC_CORE_LIB_SECURITY_UTIL_B64_H */ diff --git a/src/core/lib/slice/b64.c b/src/core/lib/slice/b64.c new file mode 100644 index 0000000000..2007cc4810 --- /dev/null +++ b/src/core/lib/slice/b64.c @@ -0,0 +1,251 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/lib/slice/b64.h" + +#include +#include + +#include +#include +#include + +#include "src/core/lib/slice/slice_internal.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, url_safe, multiline); + char *result = 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 url_safe, + 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 = 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, url_safe, 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(grpc_exec_ctx *exec_ctx, const char *b64, + int url_safe) { + return grpc_base64_decode_with_len(exec_ctx, b64, strlen(b64), url_safe); +} + +static void decode_one_char(const unsigned char *codes, unsigned char *result, + size_t *result_offset) { + uint32_t packed = ((uint32_t)codes[0] << 2) | ((uint32_t)codes[1] >> 4); + result[(*result_offset)++] = (unsigned char)packed; +} + +static void decode_two_chars(const unsigned char *codes, unsigned char *result, + size_t *result_offset) { + uint32_t packed = ((uint32_t)codes[0] << 10) | ((uint32_t)codes[1] << 4) | + ((uint32_t)codes[2] >> 2); + result[(*result_offset)++] = (unsigned char)(packed >> 8); + result[(*result_offset)++] = (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 = ((uint32_t)codes[0] << 18) | ((uint32_t)codes[1] << 12) | + ((uint32_t)codes[2] << 6) | codes[3]; + result[(*result_offset)++] = (unsigned char)(packed >> 16); + result[(*result_offset)++] = (unsigned char)(packed >> 8); + result[(*result_offset)++] = (unsigned char)(packed); + } + return 1; +} + +grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx *exec_ctx, 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 = (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++] = (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_slice_unref_internal(exec_ctx, result); + return grpc_empty_slice(); +} diff --git a/src/core/lib/slice/b64.h b/src/core/lib/slice/b64.h new file mode 100644 index 0000000000..ef52291c6a --- /dev/null +++ b/src/core/lib/slice/b64.h @@ -0,0 +1,65 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_UTIL_B64_H +#define GRPC_CORE_LIB_SECURITY_UTIL_B64_H + +#include + +/* Encodes data using base64. It is the caller's responsability 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 url_safe, + int multiline); + +/* Encodes data using base64 and write it to memory pointed to by result. It is + * the caller's responsiblity 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(grpc_exec_ctx *exec_ctx, 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(grpc_exec_ctx *exec_ctx, const char *b64, + size_t b64_len, int url_safe); + +#endif /* GRPC_CORE_LIB_SECURITY_UTIL_B64_H */ diff --git a/src/cpp/common/channel_filter.h b/src/cpp/common/channel_filter.h index 494d5d64d7..7bdb9b3de9 100644 --- a/src/cpp/common/channel_filter.h +++ b/src/cpp/common/channel_filter.h @@ -42,7 +42,6 @@ #include #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/security/context/security_context.h" #include "src/core/lib/surface/channel_init.h" #include "src/core/lib/transport/metadata_batch.h" @@ -192,16 +191,6 @@ class TransportStreamOp { op_->send_message = send_message; } - /// To be called only on clients and servers, respectively. - grpc_client_security_context *client_security_context() const { - return (grpc_client_security_context *)op_->context[GRPC_CONTEXT_SECURITY] - .value; - } - grpc_server_security_context *server_security_context() const { - return (grpc_server_security_context *)op_->context[GRPC_CONTEXT_SECURITY] - .value; - } - census_context *get_census_context() const { return (census_context *)op_->context[GRPC_CONTEXT_TRACING].value; } diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 970c70bb1b..5431f06cac 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -162,7 +162,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/json/json_reader.c', 'src/core/lib/json/json_string.c', 'src/core/lib/json/json_writer.c', - 'src/core/lib/security/util/b64.c', + 'src/core/lib/slice/b64.c', 'src/core/lib/slice/percent_encoding.c', 'src/core/lib/slice/slice.c', 'src/core/lib/slice/slice_buffer.c', diff --git a/test/core/security/b64_test.c b/test/core/security/b64_test.c deleted file mode 100644 index 28af48075e..0000000000 --- a/test/core/security/b64_test.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "src/core/lib/security/util/b64.h" - -#include - -#include -#include -#include -#include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/slice/slice_internal.h" -#include "test/core/util/test_config.h" - -static int buffers_are_equal(const unsigned char *buf1, - const unsigned char *buf2, size_t size) { - size_t i; - for (i = 0; i < size; i++) { - if (buf1[i] != buf2[i]) { - gpr_log(GPR_ERROR, "buf1 and buf2 differ: buf1[%d] = %x vs buf2[%d] = %x", - (int)i, buf1[i], (int)i, buf2[i]); - return 0; - } - } - return 1; -} - -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_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_slice hello_slice = grpc_base64_decode(&exec_ctx, hello_b64, url_safe); - GPR_ASSERT(GRPC_SLICE_LENGTH(hello_slice) == strlen(hello)); - GPR_ASSERT(strncmp((const char *)GRPC_SLICE_START_PTR(hello_slice), hello, - GRPC_SLICE_LENGTH(hello_slice)) == 0); - - grpc_slice_unref_internal(&exec_ctx, hello_slice); - grpc_exec_ctx_finish(&exec_ctx); - 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] = (uint8_t)i; - - /* Try all the different paddings. */ - for (i = 0; i < 3; i++) { - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - b64 = grpc_base64_encode(orig, sizeof(orig) - i, url_safe, multiline); - orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe); - GPR_ASSERT(GRPC_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i)); - GPR_ASSERT(buffers_are_equal(orig, GRPC_SLICE_START_PTR(orig_decoded), - sizeof(orig) - i)); - grpc_slice_unref_internal(&exec_ctx, orig_decoded); - gpr_free(b64); - grpc_exec_ctx_finish(&exec_ctx); - } -} - -static void test_simple_encode_decode_b64_no_multiline(void) { - test_simple_encode_decode_b64(0, 0); -} - -static void test_simple_encode_decode_b64_multiline(void) { - test_simple_encode_decode_b64(0, 1); -} - -static void test_simple_encode_decode_b64_urlsafe_no_multiline(void) { - test_simple_encode_decode_b64(1, 0); -} - -static void test_simple_encode_decode_b64_urlsafe_multiline(void) { - test_simple_encode_decode_b64(1, 1); -} - -static void test_full_range_encode_decode_b64_no_multiline(void) { - test_full_range_encode_decode_b64(0, 0); -} - -static void test_full_range_encode_decode_b64_multiline(void) { - test_full_range_encode_decode_b64(0, 1); -} - -static void test_full_range_encode_decode_b64_urlsafe_no_multiline(void) { - test_full_range_encode_decode_b64(1, 0); -} - -static void test_full_range_encode_decode_b64_urlsafe_multiline(void) { - test_full_range_encode_decode_b64(1, 1); -} - -static void test_url_safe_unsafe_mismatch_failure(void) { - 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] = (uint8_t)i; - - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0); - orig_decoded = grpc_base64_decode(&exec_ctx, b64, !url_safe); - GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded)); - gpr_free(b64); - grpc_slice_unref_internal(&exec_ctx, orig_decoded); - - b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0); - orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe); - GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded)); - gpr_free(b64); - grpc_slice_unref_internal(&exec_ctx, orig_decoded); - grpc_exec_ctx_finish(&exec_ctx); -} - -static void test_rfc4648_test_vectors(void) { - char *b64; - - b64 = grpc_base64_encode("", 0, 0, 0); - GPR_ASSERT(strcmp("", b64) == 0); - gpr_free(b64); - - b64 = grpc_base64_encode("f", 1, 0, 0); - GPR_ASSERT(strcmp("Zg==", b64) == 0); - gpr_free(b64); - - b64 = grpc_base64_encode("fo", 2, 0, 0); - GPR_ASSERT(strcmp("Zm8=", b64) == 0); - gpr_free(b64); - - b64 = grpc_base64_encode("foo", 3, 0, 0); - GPR_ASSERT(strcmp("Zm9v", b64) == 0); - gpr_free(b64); - - b64 = grpc_base64_encode("foob", 4, 0, 0); - GPR_ASSERT(strcmp("Zm9vYg==", b64) == 0); - gpr_free(b64); - - b64 = grpc_base64_encode("fooba", 5, 0, 0); - GPR_ASSERT(strcmp("Zm9vYmE=", b64) == 0); - gpr_free(b64); - - b64 = grpc_base64_encode("foobar", 6, 0, 0); - GPR_ASSERT(strcmp("Zm9vYmFy", b64) == 0); - gpr_free(b64); -} - -static void test_unpadded_decode(void) { - grpc_slice decoded; - - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmFy", 0); - GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(grpc_slice_str_cmp(decoded, "foobar") == 0); - grpc_slice_unref(decoded); - - decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmE", 0); - GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(grpc_slice_str_cmp(decoded, "fooba") == 0); - grpc_slice_unref(decoded); - - decoded = grpc_base64_decode(&exec_ctx, "Zm9vYg", 0); - GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(grpc_slice_str_cmp(decoded, "foob") == 0); - grpc_slice_unref(decoded); - - decoded = grpc_base64_decode(&exec_ctx, "Zm9v", 0); - GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(grpc_slice_str_cmp(decoded, "foo") == 0); - grpc_slice_unref(decoded); - - decoded = grpc_base64_decode(&exec_ctx, "Zm8", 0); - GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(grpc_slice_str_cmp(decoded, "fo") == 0); - grpc_slice_unref(decoded); - - decoded = grpc_base64_decode(&exec_ctx, "Zg", 0); - GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(grpc_slice_str_cmp(decoded, "f") == 0); - grpc_slice_unref(decoded); - - decoded = grpc_base64_decode(&exec_ctx, "", 0); - GPR_ASSERT(GRPC_SLICE_IS_EMPTY(decoded)); - grpc_exec_ctx_finish(&exec_ctx); -} - -int main(int argc, char **argv) { - grpc_test_init(argc, argv); - test_simple_encode_decode_b64_no_multiline(); - test_simple_encode_decode_b64_multiline(); - test_simple_encode_decode_b64_urlsafe_no_multiline(); - test_simple_encode_decode_b64_urlsafe_multiline(); - test_full_range_encode_decode_b64_no_multiline(); - test_full_range_encode_decode_b64_multiline(); - test_full_range_encode_decode_b64_urlsafe_no_multiline(); - test_full_range_encode_decode_b64_urlsafe_multiline(); - test_url_safe_unsafe_mismatch_failure(); - test_rfc4648_test_vectors(); - test_unpadded_decode(); - return 0; -} diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c index 5cebb09bb2..97dfe87896 100644 --- a/test/core/security/json_token_test.c +++ b/test/core/security/json_token_test.c @@ -43,7 +43,7 @@ #include "src/core/lib/json/json.h" #include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h" -#include "src/core/lib/security/util/b64.h" +#include "src/core/lib/slice/b64.h" #include "src/core/lib/slice/slice_internal.h" #include "test/core/util/test_config.h" diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c index 0a73f67528..7eec780a91 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -44,7 +44,7 @@ #include "src/core/lib/http/httpcli.h" #include "src/core/lib/security/credentials/jwt/json_token.h" -#include "src/core/lib/security/util/b64.h" +#include "src/core/lib/slice/b64.h" #include "test/core/util/test_config.h" /* This JSON key was generated with the GCE console and revoked immediately. diff --git a/test/core/slice/b64_test.c b/test/core/slice/b64_test.c new file mode 100644 index 0000000000..9e5c06551c --- /dev/null +++ b/test/core/slice/b64_test.c @@ -0,0 +1,234 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/lib/slice/b64.h" + +#include + +#include +#include +#include +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/slice/slice_internal.h" +#include "test/core/util/test_config.h" + +static int buffers_are_equal(const unsigned char *buf1, + const unsigned char *buf2, size_t size) { + size_t i; + for (i = 0; i < size; i++) { + if (buf1[i] != buf2[i]) { + gpr_log(GPR_ERROR, "buf1 and buf2 differ: buf1[%d] = %x vs buf2[%d] = %x", + (int)i, buf1[i], (int)i, buf2[i]); + return 0; + } + } + return 1; +} + +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_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_slice hello_slice = grpc_base64_decode(&exec_ctx, hello_b64, url_safe); + GPR_ASSERT(GRPC_SLICE_LENGTH(hello_slice) == strlen(hello)); + GPR_ASSERT(strncmp((const char *)GRPC_SLICE_START_PTR(hello_slice), hello, + GRPC_SLICE_LENGTH(hello_slice)) == 0); + + grpc_slice_unref_internal(&exec_ctx, hello_slice); + grpc_exec_ctx_finish(&exec_ctx); + 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] = (uint8_t)i; + + /* Try all the different paddings. */ + for (i = 0; i < 3; i++) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + b64 = grpc_base64_encode(orig, sizeof(orig) - i, url_safe, multiline); + orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe); + GPR_ASSERT(GRPC_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i)); + GPR_ASSERT(buffers_are_equal(orig, GRPC_SLICE_START_PTR(orig_decoded), + sizeof(orig) - i)); + grpc_slice_unref_internal(&exec_ctx, orig_decoded); + gpr_free(b64); + grpc_exec_ctx_finish(&exec_ctx); + } +} + +static void test_simple_encode_decode_b64_no_multiline(void) { + test_simple_encode_decode_b64(0, 0); +} + +static void test_simple_encode_decode_b64_multiline(void) { + test_simple_encode_decode_b64(0, 1); +} + +static void test_simple_encode_decode_b64_urlsafe_no_multiline(void) { + test_simple_encode_decode_b64(1, 0); +} + +static void test_simple_encode_decode_b64_urlsafe_multiline(void) { + test_simple_encode_decode_b64(1, 1); +} + +static void test_full_range_encode_decode_b64_no_multiline(void) { + test_full_range_encode_decode_b64(0, 0); +} + +static void test_full_range_encode_decode_b64_multiline(void) { + test_full_range_encode_decode_b64(0, 1); +} + +static void test_full_range_encode_decode_b64_urlsafe_no_multiline(void) { + test_full_range_encode_decode_b64(1, 0); +} + +static void test_full_range_encode_decode_b64_urlsafe_multiline(void) { + test_full_range_encode_decode_b64(1, 1); +} + +static void test_url_safe_unsafe_mismatch_failure(void) { + 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] = (uint8_t)i; + + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0); + orig_decoded = grpc_base64_decode(&exec_ctx, b64, !url_safe); + GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded)); + gpr_free(b64); + grpc_slice_unref_internal(&exec_ctx, orig_decoded); + + b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0); + orig_decoded = grpc_base64_decode(&exec_ctx, b64, url_safe); + GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded)); + gpr_free(b64); + grpc_slice_unref_internal(&exec_ctx, orig_decoded); + grpc_exec_ctx_finish(&exec_ctx); +} + +static void test_rfc4648_test_vectors(void) { + char *b64; + + b64 = grpc_base64_encode("", 0, 0, 0); + GPR_ASSERT(strcmp("", b64) == 0); + gpr_free(b64); + + b64 = grpc_base64_encode("f", 1, 0, 0); + GPR_ASSERT(strcmp("Zg==", b64) == 0); + gpr_free(b64); + + b64 = grpc_base64_encode("fo", 2, 0, 0); + GPR_ASSERT(strcmp("Zm8=", b64) == 0); + gpr_free(b64); + + b64 = grpc_base64_encode("foo", 3, 0, 0); + GPR_ASSERT(strcmp("Zm9v", b64) == 0); + gpr_free(b64); + + b64 = grpc_base64_encode("foob", 4, 0, 0); + GPR_ASSERT(strcmp("Zm9vYg==", b64) == 0); + gpr_free(b64); + + b64 = grpc_base64_encode("fooba", 5, 0, 0); + GPR_ASSERT(strcmp("Zm9vYmE=", b64) == 0); + gpr_free(b64); + + b64 = grpc_base64_encode("foobar", 6, 0, 0); + GPR_ASSERT(strcmp("Zm9vYmFy", b64) == 0); + gpr_free(b64); +} + +static void test_unpadded_decode(void) { + grpc_slice decoded; + + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmFy", 0); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "foobar") == 0); + grpc_slice_unref(decoded); + + decoded = grpc_base64_decode(&exec_ctx, "Zm9vYmE", 0); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "fooba") == 0); + grpc_slice_unref(decoded); + + decoded = grpc_base64_decode(&exec_ctx, "Zm9vYg", 0); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "foob") == 0); + grpc_slice_unref(decoded); + + decoded = grpc_base64_decode(&exec_ctx, "Zm9v", 0); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "foo") == 0); + grpc_slice_unref(decoded); + + decoded = grpc_base64_decode(&exec_ctx, "Zm8", 0); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "fo") == 0); + grpc_slice_unref(decoded); + + decoded = grpc_base64_decode(&exec_ctx, "Zg", 0); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "f") == 0); + grpc_slice_unref(decoded); + + decoded = grpc_base64_decode(&exec_ctx, "", 0); + GPR_ASSERT(GRPC_SLICE_IS_EMPTY(decoded)); + grpc_exec_ctx_finish(&exec_ctx); +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + test_simple_encode_decode_b64_no_multiline(); + test_simple_encode_decode_b64_multiline(); + test_simple_encode_decode_b64_urlsafe_no_multiline(); + test_simple_encode_decode_b64_urlsafe_multiline(); + test_full_range_encode_decode_b64_no_multiline(); + test_full_range_encode_decode_b64_multiline(); + test_full_range_encode_decode_b64_urlsafe_no_multiline(); + test_full_range_encode_decode_b64_urlsafe_multiline(); + test_url_safe_unsafe_mismatch_failure(); + test_rfc4648_test_vectors(); + test_unpadded_decode(); + return 0; +} diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index a15b624f34..ed680e30a3 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1225,8 +1225,8 @@ src/core/lib/security/transport/security_handshaker.h \ src/core/lib/security/transport/server_auth_filter.c \ src/core/lib/security/transport/tsi_error.c \ src/core/lib/security/transport/tsi_error.h \ -src/core/lib/security/util/b64.c \ -src/core/lib/security/util/b64.h \ +src/core/lib/slice/b64.c \ +src/core/lib/slice/b64.h \ src/core/lib/security/util/json_util.c \ src/core/lib/security/util/json_util.h \ src/core/lib/slice/percent_encoding.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 446a27e6cf..4aa26eda67 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -912,7 +912,7 @@ "language": "c", "name": "grpc_b64_test", "src": [ - "test/core/security/b64_test.c" + "test/core/slice/b64_test.c" ], "third_party": false, "type": "target" @@ -5738,6 +5738,7 @@ }, { "deps": [ + "gpr", "grpc", "grpc++_base", "grpc++_codegen_base", @@ -7577,6 +7578,7 @@ "src/core/lib/json/json_common.h", "src/core/lib/json/json_reader.h", "src/core/lib/json/json_writer.h", + "src/core/lib/slice/b64.h", "src/core/lib/slice/percent_encoding.h", "src/core/lib/slice/slice_hash_table.h", "src/core/lib/slice/slice_internal.h", @@ -7786,7 +7788,8 @@ "src/core/lib/json/json_string.c", "src/core/lib/json/json_writer.c", "src/core/lib/json/json_writer.h", - "src/core/lib/security/util/b64.c", + "src/core/lib/slice/b64.c", + "src/core/lib/slice/b64.h", "src/core/lib/slice/percent_encoding.c", "src/core/lib/slice/percent_encoding.h", "src/core/lib/slice/slice.c", @@ -7993,6 +7996,7 @@ "gpr", "grpc_base", "grpc_client_channel", + "grpc_secure", "nanopb" ], "headers": [ @@ -8152,7 +8156,6 @@ "src/core/lib/security/transport/security_connector.h", "src/core/lib/security/transport/security_handshaker.h", "src/core/lib/security/transport/tsi_error.h", - "src/core/lib/security/util/b64.h", "src/core/lib/security/util/json_util.h" ], "is_filegroup": true, @@ -8200,8 +8203,6 @@ "src/core/lib/security/transport/server_auth_filter.c", "src/core/lib/security/transport/tsi_error.c", "src/core/lib/security/transport/tsi_error.h", - "src/core/lib/security/util/b64.c", - "src/core/lib/security/util/b64.h", "src/core/lib/security/util/json_util.c", "src/core/lib/security/util/json_util.h", "src/core/lib/surface/init_secure.c" @@ -8362,6 +8363,7 @@ "deps": [ "gpr", "grpc_base", + "grpc_client_channel", "grpc_transport_chttp2" ], "headers": [ @@ -8541,7 +8543,10 @@ }, { "deps": [ - "grpc++_codegen_base" + "gpr", + "grpc++_codegen_base", + "grpc_base", + "nanopb" ], "headers": [ "include/grpc++/alarm.h", diff --git a/tools/run_tests/sanity/check_sources_and_headers.py b/tools/run_tests/sanity/check_sources_and_headers.py index f2e0bfeb3d..c80c221d70 100755 --- a/tools/run_tests/sanity/check_sources_and_headers.py +++ b/tools/run_tests/sanity/check_sources_and_headers.py @@ -77,7 +77,7 @@ for target in js: for line in src: m = re_inc1.match(line) if m: - if not target_has_header(target, m.group(1)) and not target['is_filegroup']: + if not target_has_header(target, m.group(1)): print ( 'target %s (%s) does not name header %s as a dependency' % ( target['name'], fn, m.group(1))) -- cgit v1.2.3 From 283516151388190071ef2fb15368ac3c970faaa1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 30 Mar 2017 10:48:34 -0700 Subject: Reinstate one check, fix fall out --- build.yaml | 2 +- tools/run_tests/generated/sources_and_headers.json | 4 ++-- tools/run_tests/sanity/check_sources_and_headers.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'build.yaml') diff --git a/build.yaml b/build.yaml index 21855e2fd2..eab33c55c2 100644 --- a/build.yaml +++ b/build.yaml @@ -156,7 +156,6 @@ filegroups: - include/grpc/impl/codegen/gpr_slice.h - include/grpc/impl/codegen/gpr_types.h - include/grpc/impl/codegen/port_platform.h - - include/grpc/impl/codegen/slice.h - include/grpc/impl/codegen/sync.h - include/grpc/impl/codegen/sync_generic.h - include/grpc/impl/codegen/sync_posix.h @@ -465,6 +464,7 @@ filegroups: - include/grpc/impl/codegen/exec_ctx_fwd.h - include/grpc/impl/codegen/grpc_types.h - include/grpc/impl/codegen/propagation_bits.h + - include/grpc/impl/codegen/slice.h - include/grpc/impl/codegen/status.h uses: - gpr_codegen diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 267909f98c..27ddd977e9 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7458,7 +7458,6 @@ "include/grpc/impl/codegen/gpr_slice.h", "include/grpc/impl/codegen/gpr_types.h", "include/grpc/impl/codegen/port_platform.h", - "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/sync.h", "include/grpc/impl/codegen/sync_generic.h", "include/grpc/impl/codegen/sync_posix.h", @@ -7475,7 +7474,6 @@ "include/grpc/impl/codegen/gpr_slice.h", "include/grpc/impl/codegen/gpr_types.h", "include/grpc/impl/codegen/port_platform.h", - "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/sync.h", "include/grpc/impl/codegen/sync_generic.h", "include/grpc/impl/codegen/sync_posix.h", @@ -7945,6 +7943,7 @@ "include/grpc/impl/codegen/exec_ctx_fwd.h", "include/grpc/impl/codegen/grpc_types.h", "include/grpc/impl/codegen/propagation_bits.h", + "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/status.h" ], "is_filegroup": true, @@ -7957,6 +7956,7 @@ "include/grpc/impl/codegen/exec_ctx_fwd.h", "include/grpc/impl/codegen/grpc_types.h", "include/grpc/impl/codegen/propagation_bits.h", + "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/status.h" ], "third_party": false, diff --git a/tools/run_tests/sanity/check_sources_and_headers.py b/tools/run_tests/sanity/check_sources_and_headers.py index c80c221d70..42892ea69d 100755 --- a/tools/run_tests/sanity/check_sources_and_headers.py +++ b/tools/run_tests/sanity/check_sources_and_headers.py @@ -84,7 +84,7 @@ for target in js: errors += 1 m = re_inc2.match(line) if m: - if not target_has_header(target, 'include/' + m.group(1)) and not target['is_filegroup']: + if not target_has_header(target, 'include/' + m.group(1)): print ( 'target %s (%s) does not name header %s as a dependency' % ( target['name'], fn, m.group(1))) -- cgit v1.2.3