From 894a47df2423f0d2b6be57e6d90f2bea88213382 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Mon, 8 Feb 2016 10:17:39 -1000 Subject: [PATCH] Clarify some confusing casts involving |size_t|. Change-Id: I7af2c87fe6e7513aa2603d5e845a4db87ab14fcc Reviewed-on: https://boringssl-review.googlesource.com/7101 Reviewed-by: David Benjamin --- crypto/cipher/cipher_test.cc | 2 +- crypto/cipher/e_aes.c | 4 ++-- crypto/rsa/padding.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crypto/cipher/cipher_test.cc b/crypto/cipher/cipher_test.cc index 1cbfae97..7b4944cb 100644 --- a/crypto/cipher/cipher_test.cc +++ b/crypto/cipher/cipher_test.cc @@ -138,7 +138,7 @@ static bool TestOperation(FileTest *t, iv.size(), 0)) { return false; } - } else if (iv.size() != (size_t)EVP_CIPHER_CTX_iv_length(ctx.get())) { + } else if (iv.size() != EVP_CIPHER_CTX_iv_length(ctx.get())) { t->PrintLine("Bad IV length."); return false; } diff --git a/crypto/cipher/e_aes.c b/crypto/cipher/e_aes.c index e5104b47..f7b6fa31 100644 --- a/crypto/cipher/e_aes.c +++ b/crypto/cipher/e_aes.c @@ -384,7 +384,7 @@ static int aes_ecb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, static int aes_ctr_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, size_t len) { - unsigned int num = ctx->num; + unsigned num = (unsigned)ctx->num; EVP_AES_KEY *dat = (EVP_AES_KEY *)ctx->cipher_data; if (dat->stream.ctr) { @@ -394,7 +394,7 @@ static int aes_ctr_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, CRYPTO_ctr128_encrypt(in, out, len, &dat->ks, ctx->iv, ctx->buf, &num, dat->block); } - ctx->num = (size_t)num; + ctx->num = (int)num; return 1; } diff --git a/crypto/rsa/padding.c b/crypto/rsa/padding.c index 032df2e6..128950ae 100644 --- a/crypto/rsa/padding.c +++ b/crypto/rsa/padding.c @@ -95,7 +95,7 @@ int RSA_padding_add_PKCS1_type_1(uint8_t *to, unsigned to_len, memset(p, 0xff, j); p += j; *(p++) = 0; - memcpy(p, from, (unsigned int)from_len); + memcpy(p, from, from_len); return 1; } @@ -189,7 +189,7 @@ int RSA_padding_add_PKCS1_type_2(uint8_t *to, unsigned to_len, *(p++) = 0; - memcpy(p, from, (unsigned int)from_len); + memcpy(p, from, from_len); return 1; } @@ -271,7 +271,7 @@ int RSA_padding_add_none(uint8_t *to, unsigned to_len, const uint8_t *from, return 0; } - memcpy(to, from, (unsigned int)from_len); + memcpy(to, from, from_len); return 1; }