aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/security
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/security')
-rw-r--r--src/core/security/base64.c13
-rw-r--r--src/core/security/client_auth_filter.c6
-rw-r--r--src/core/security/credentials.c2
-rw-r--r--src/core/security/json_token.c6
-rw-r--r--src/core/security/jwt_verifier.c4
-rw-r--r--src/core/security/secure_endpoint.c22
-rw-r--r--src/core/security/security_connector.c17
-rw-r--r--src/core/security/security_connector.h5
8 files changed, 36 insertions, 39 deletions
diff --git a/src/core/security/base64.c b/src/core/security/base64.c
index 5226d2c578..e68359602e 100644
--- a/src/core/security/base64.c
+++ b/src/core/security/base64.c
@@ -114,7 +114,7 @@ char *grpc_base64_encode(const void *vdata, size_t data_size, int url_safe,
}
GPR_ASSERT(current >= result);
- GPR_ASSERT((gpr_uintptr)(current - result) < result_projected_size);
+ GPR_ASSERT((uintptr_t)(current - result) < result_projected_size);
result[current - result] = '\0';
return result;
}
@@ -125,14 +125,14 @@ gpr_slice grpc_base64_decode(const char *b64, int url_safe) {
static void decode_one_char(const unsigned char *codes, unsigned char *result,
size_t *result_offset) {
- gpr_uint32 packed = ((gpr_uint32)codes[0] << 2) | ((gpr_uint32)codes[1] >> 4);
+ 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) {
- gpr_uint32 packed = ((gpr_uint32)codes[0] << 10) |
- ((gpr_uint32)codes[1] << 4) | ((gpr_uint32)codes[2] >> 2);
+ 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);
}
@@ -172,9 +172,8 @@ static int decode_group(const unsigned char *codes, size_t num_codes,
decode_two_chars(codes, result, result_offset);
} else {
/* No padding. */
- gpr_uint32 packed = ((gpr_uint32)codes[0] << 18) |
- ((gpr_uint32)codes[1] << 12) |
- ((gpr_uint32)codes[2] << 6) | codes[3];
+ 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);
diff --git a/src/core/security/client_auth_filter.c b/src/core/security/client_auth_filter.c
index 1cb247d874..d6568f1cfd 100644
--- a/src/core/security/client_auth_filter.c
+++ b/src/core/security/client_auth_filter.c
@@ -60,7 +60,7 @@ typedef struct {
progress */
grpc_pollset *pollset;
grpc_transport_stream_op op;
- gpr_uint8 security_context_set;
+ uint8_t security_context_set;
grpc_linked_mdelem md_links[MAX_CREDENTIALS_METADATA_COUNT];
grpc_auth_metadata_context auth_md_context;
} call_data;
@@ -232,8 +232,8 @@ static void auth_start_transport_op(grpc_exec_ctx *exec_ctx,
}
sec_ctx = op->context[GRPC_CONTEXT_SECURITY].value;
GRPC_AUTH_CONTEXT_UNREF(sec_ctx->auth_context, "client auth filter");
- sec_ctx->auth_context = GRPC_AUTH_CONTEXT_REF(
- chand->auth_context, "client_auth_filter");
+ sec_ctx->auth_context =
+ GRPC_AUTH_CONTEXT_REF(chand->auth_context, "client_auth_filter");
}
if (op->send_initial_metadata != NULL) {
diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c
index 1d1c3b098a..8e33227458 100644
--- a/src/core/security/credentials.c
+++ b/src/core/security/credentials.c
@@ -180,7 +180,7 @@ void grpc_server_credentials_set_auth_metadata_processor(
"grpc_server_credentials_set_auth_metadata_processor("
"creds=%p, "
"processor=grpc_auth_metadata_processor { process: %p, state: %p })",
- 3, (creds, (void*)(gpr_intptr)processor.process, processor.state));
+ 3, (creds, (void *)(intptr_t)processor.process, processor.state));
if (creds == NULL) return;
if (creds->processor.destroy != NULL && creds->processor.state != NULL) {
creds->processor.destroy(creds->processor.state);
diff --git a/src/core/security/json_token.c b/src/core/security/json_token.c
index 92775d885d..4d4bc4baad 100644
--- a/src/core/security/json_token.c
+++ b/src/core/security/json_token.c
@@ -215,8 +215,8 @@ static char *encoded_jwt_claim(const grpc_auth_json_key *json_key,
gpr_log(GPR_INFO, "Cropping token lifetime to maximum allowed value.");
expiration = gpr_time_add(now, grpc_max_auth_token_lifetime);
}
- gpr_int64toa(now.tv_sec, now_str);
- gpr_int64toa(expiration.tv_sec, expiration_str);
+ int64_ttoa(now.tv_sec, now_str);
+ int64_ttoa(expiration.tv_sec, expiration_str);
child =
create_child(NULL, json, "iss", json_key->client_email, GRPC_JSON_STRING);
@@ -251,7 +251,7 @@ static char *dot_concat_and_free_strings(char *str1, char *str2) {
memcpy(current, str2, str2_len);
current += str2_len;
GPR_ASSERT(current >= result);
- GPR_ASSERT((gpr_uintptr)(current - result) == result_len);
+ GPR_ASSERT((uintptr_t)(current - result) == result_len);
*current = '\0';
gpr_free(str1);
gpr_free(str2);
diff --git a/src/core/security/jwt_verifier.c b/src/core/security/jwt_verifier.c
index eca903d930..85b9624cfe 100644
--- a/src/core/security/jwt_verifier.c
+++ b/src/core/security/jwt_verifier.c
@@ -443,8 +443,8 @@ static BIGNUM *bignum_from_base64(const char *b64) {
gpr_log(GPR_ERROR, "Invalid base64 for big num.");
return NULL;
}
- result =
- BN_bin2bn(GPR_SLICE_START_PTR(bin), TSI_SIZE_AS_SIZE(GPR_SLICE_LENGTH(bin)), NULL);
+ result = BN_bin2bn(GPR_SLICE_START_PTR(bin),
+ TSI_SIZE_AS_SIZE(GPR_SLICE_LENGTH(bin)), NULL);
gpr_slice_unref(bin);
return result;
}
diff --git a/src/core/security/secure_endpoint.c b/src/core/security/secure_endpoint.c
index fd50abb773..9b87e268c6 100644
--- a/src/core/security/secure_endpoint.c
+++ b/src/core/security/secure_endpoint.c
@@ -117,8 +117,8 @@ static void secure_endpoint_unref(grpc_exec_ctx *exec_ctx,
static void secure_endpoint_ref(secure_endpoint *ep) { gpr_ref(&ep->ref); }
#endif
-static void flush_read_staging_buffer(secure_endpoint *ep, gpr_uint8 **cur,
- gpr_uint8 **end) {
+static void flush_read_staging_buffer(secure_endpoint *ep, uint8_t **cur,
+ uint8_t **end) {
gpr_slice_buffer_add(ep->read_buffer, ep->read_staging_buffer);
ep->read_staging_buffer = gpr_slice_malloc(STAGING_BUFFER_SIZE);
*cur = GPR_SLICE_START_PTR(ep->read_staging_buffer);
@@ -143,11 +143,11 @@ static void call_read_cb(grpc_exec_ctx *exec_ctx, secure_endpoint *ep,
static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, int success) {
unsigned i;
- gpr_uint8 keep_looping = 0;
+ uint8_t keep_looping = 0;
tsi_result result = TSI_OK;
secure_endpoint *ep = (secure_endpoint *)user_data;
- gpr_uint8 *cur = GPR_SLICE_START_PTR(ep->read_staging_buffer);
- gpr_uint8 *end = GPR_SLICE_END_PTR(ep->read_staging_buffer);
+ uint8_t *cur = GPR_SLICE_START_PTR(ep->read_staging_buffer);
+ uint8_t *end = GPR_SLICE_END_PTR(ep->read_staging_buffer);
if (!success) {
gpr_slice_buffer_reset_and_unref(ep->read_buffer);
@@ -158,7 +158,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, int success) {
/* TODO(yangg) check error, maybe bail out early */
for (i = 0; i < ep->source_buffer.count; i++) {
gpr_slice encrypted = ep->source_buffer.slices[i];
- gpr_uint8 *message_bytes = GPR_SLICE_START_PTR(encrypted);
+ uint8_t *message_bytes = GPR_SLICE_START_PTR(encrypted);
size_t message_size = GPR_SLICE_LENGTH(encrypted);
while (message_size > 0 || keep_looping) {
@@ -234,8 +234,8 @@ static void endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
&ep->on_read);
}
-static void flush_write_staging_buffer(secure_endpoint *ep, gpr_uint8 **cur,
- gpr_uint8 **end) {
+static void flush_write_staging_buffer(secure_endpoint *ep, uint8_t **cur,
+ uint8_t **end) {
gpr_slice_buffer_add(&ep->output_buffer, ep->write_staging_buffer);
ep->write_staging_buffer = gpr_slice_malloc(STAGING_BUFFER_SIZE);
*cur = GPR_SLICE_START_PTR(ep->write_staging_buffer);
@@ -247,8 +247,8 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
unsigned i;
tsi_result result = TSI_OK;
secure_endpoint *ep = (secure_endpoint *)secure_ep;
- gpr_uint8 *cur = GPR_SLICE_START_PTR(ep->write_staging_buffer);
- gpr_uint8 *end = GPR_SLICE_END_PTR(ep->write_staging_buffer);
+ uint8_t *cur = GPR_SLICE_START_PTR(ep->write_staging_buffer);
+ uint8_t *end = GPR_SLICE_END_PTR(ep->write_staging_buffer);
gpr_slice_buffer_reset_and_unref(&ep->output_buffer);
@@ -263,7 +263,7 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
for (i = 0; i < slices->count; i++) {
gpr_slice plain = slices->slices[i];
- gpr_uint8 *message_bytes = GPR_SLICE_START_PTR(plain);
+ uint8_t *message_bytes = GPR_SLICE_START_PTR(plain);
size_t message_size = GPR_SLICE_LENGTH(plain);
while (message_size > 0) {
size_t protected_buffer_size_to_send = (size_t)(end - cur);
diff --git a/src/core/security/security_connector.c b/src/core/security/security_connector.c
index 204cd324f6..a115b942a6 100644
--- a/src/core/security/security_connector.c
+++ b/src/core/security/security_connector.c
@@ -316,8 +316,7 @@ grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
c->base.is_client_side = 1;
c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
c->base.vtable = &fake_channel_vtable;
- c->request_metadata_creds =
- grpc_call_credentials_ref(request_metadata_creds);
+ c->request_metadata_creds = grpc_call_credentials_ref(request_metadata_creds);
c->check_call_host = fake_channel_check_call_host;
return c;
}
@@ -500,9 +499,10 @@ static grpc_security_status ssl_check_peer(grpc_security_connector *sc,
return GRPC_SECURITY_OK;
}
-static void ssl_channel_check_peer(
- grpc_exec_ctx *exec_ctx, grpc_security_connector *sc, tsi_peer peer,
- grpc_security_peer_check_cb cb, void *user_data) {
+static void ssl_channel_check_peer(grpc_exec_ctx *exec_ctx,
+ grpc_security_connector *sc, tsi_peer peer,
+ grpc_security_peer_check_cb cb,
+ void *user_data) {
grpc_ssl_channel_security_connector *c =
(grpc_ssl_channel_security_connector *)sc;
grpc_security_status status;
@@ -516,9 +516,10 @@ static void ssl_channel_check_peer(
tsi_peer_destruct(&peer);
}
-static void ssl_server_check_peer(
- grpc_exec_ctx *exec_ctx, grpc_security_connector *sc, tsi_peer peer,
- grpc_security_peer_check_cb cb, void *user_data) {
+static void ssl_server_check_peer(grpc_exec_ctx *exec_ctx,
+ grpc_security_connector *sc, tsi_peer peer,
+ grpc_security_peer_check_cb cb,
+ void *user_data) {
grpc_auth_context *auth_context = NULL;
grpc_security_status status = ssl_check_peer(sc, NULL, &peer, &auth_context);
tsi_peer_destruct(&peer);
diff --git a/src/core/security/security_connector.h b/src/core/security/security_connector.h
index b5f3ff17f4..cc6cc742c8 100644
--- a/src/core/security/security_connector.h
+++ b/src/core/security/security_connector.h
@@ -40,10 +40,7 @@
/* --- status enum. --- */
-typedef enum {
- GRPC_SECURITY_OK = 0,
- GRPC_SECURITY_ERROR
-} grpc_security_status;
+typedef enum { GRPC_SECURITY_OK = 0, GRPC_SECURITY_ERROR } grpc_security_status;
/* --- URL schemes. --- */