diff options
author | David Benjamin <davidben@google.com> | 2019-01-03 15:14:41 -0600 |
---|---|---|
committer | CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org> | 2019-01-03 21:46:45 +0000 |
commit | e67b625e43487d6aaf3dc36d4a14db57c59abd52 (patch) | |
tree | 58c5721196894ae3f181e4f23a8e11c206e642f7 /decrepit | |
parent | 6effbf24bc483b5f62add56129925ffe06b80b4a (diff) | |
download | boringssl-e67b625e43487d6aaf3dc36d4a14db57c59abd52.zip boringssl-e67b625e43487d6aaf3dc36d4a14db57c59abd52.tar.gz boringssl-e67b625e43487d6aaf3dc36d4a14db57c59abd52.tar.bz2 |
Fix some size_t to long casts.
Maybe someday we'll be able to turn on that warning. (The EVP_CIPHER
hooks take size_t while the functions took long.)
Change-Id: Ic4da44efca9419a7f703e232d3f92638eb4ab37a
Reviewed-on: https://boringssl-review.googlesource.com/c/34084
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'decrepit')
-rw-r--r-- | decrepit/blowfish/blowfish.c | 18 | ||||
-rw-r--r-- | decrepit/cast/cast.c | 22 |
2 files changed, 22 insertions, 18 deletions
diff --git a/decrepit/blowfish/blowfish.c b/decrepit/blowfish/blowfish.c index 120e365..186f486 100644 --- a/decrepit/blowfish/blowfish.c +++ b/decrepit/blowfish/blowfish.c @@ -152,18 +152,18 @@ void BF_ecb_encrypt(const uint8_t *in, uint8_t *out, l2n(d[1], out); } -void BF_cbc_encrypt(const uint8_t *in, uint8_t *out, long length, +void BF_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t length, const BF_KEY *schedule, uint8_t *ivec, int encrypt) { uint32_t tin0, tin1; uint32_t tout0, tout1, xor0, xor1; - long l = length; + size_t l = length; uint32_t tin[2]; if (encrypt) { n2l(ivec, tout0); n2l(ivec, tout1); ivec -= 8; - for (l -= 8; l >= 0; l -= 8) { + while (l >= 8) { n2l(in, tin0); n2l(in, tin1); tin0 ^= tout0; @@ -175,9 +175,10 @@ void BF_cbc_encrypt(const uint8_t *in, uint8_t *out, long length, tout1 = tin[1]; l2n(tout0, out); l2n(tout1, out); + l -= 8; } - if (l != -8) { - n2ln(in, tin0, tin1, l + 8); + if (l != 0) { + n2ln(in, tin0, tin1, l); tin0 ^= tout0; tin1 ^= tout1; tin[0] = tin0; @@ -194,7 +195,7 @@ void BF_cbc_encrypt(const uint8_t *in, uint8_t *out, long length, n2l(ivec, xor0); n2l(ivec, xor1); ivec -= 8; - for (l -= 8; l >= 0; l -= 8) { + while (l >= 8) { n2l(in, tin0); n2l(in, tin1); tin[0] = tin0; @@ -206,8 +207,9 @@ void BF_cbc_encrypt(const uint8_t *in, uint8_t *out, long length, l2n(tout1, out); xor0 = tin0; xor1 = tin1; + l -= 8; } - if (l != -8) { + if (l != 0) { n2l(in, tin0); n2l(in, tin1); tin[0] = tin0; @@ -215,7 +217,7 @@ void BF_cbc_encrypt(const uint8_t *in, uint8_t *out, long length, BF_decrypt(tin, schedule); tout0 = tin[0] ^ xor0; tout1 = tin[1] ^ xor1; - l2nn(tout0, tout1, out, l + 8); + l2nn(tout0, tout1, out, l); xor0 = tin0; xor1 = tin1; } diff --git a/decrepit/cast/cast.c b/decrepit/cast/cast.c index 0eb815d..bc37203 100644 --- a/decrepit/cast/cast.c +++ b/decrepit/cast/cast.c @@ -166,18 +166,18 @@ void CAST_decrypt(uint32_t *data, const CAST_KEY *key) { data[0] = r & 0xffffffffL; } -void CAST_cbc_encrypt(const uint8_t *in, uint8_t *out, long length, +void CAST_cbc_encrypt(const uint8_t *in, uint8_t *out, size_t length, const CAST_KEY *ks, uint8_t *iv, int enc) { uint32_t tin0, tin1; uint32_t tout0, tout1, xor0, xor1; - long l = length; + size_t l = length; uint32_t tin[2]; if (enc) { n2l(iv, tout0); n2l(iv, tout1); iv -= 8; - for (l -= 8; l >= 0; l -= 8) { + while (l >= 8) { n2l(in, tin0); n2l(in, tin1); tin0 ^= tout0; @@ -189,9 +189,10 @@ void CAST_cbc_encrypt(const uint8_t *in, uint8_t *out, long length, tout1 = tin[1]; l2n(tout0, out); l2n(tout1, out); + l -= 8; } - if (l != -8) { - n2ln(in, tin0, tin1, l + 8); + if (l != 0) { + n2ln(in, tin0, tin1, l); tin0 ^= tout0; tin1 ^= tout1; tin[0] = tin0; @@ -208,7 +209,7 @@ void CAST_cbc_encrypt(const uint8_t *in, uint8_t *out, long length, n2l(iv, xor0); n2l(iv, xor1); iv -= 8; - for (l -= 8; l >= 0; l -= 8) { + while (l >= 8) { n2l(in, tin0); n2l(in, tin1); tin[0] = tin0; @@ -220,8 +221,9 @@ void CAST_cbc_encrypt(const uint8_t *in, uint8_t *out, long length, l2n(tout1, out); xor0 = tin0; xor1 = tin1; + l -= 8; } - if (l != -8) { + if (l != 0) { n2l(in, tin0); n2l(in, tin1); tin[0] = tin0; @@ -229,7 +231,7 @@ void CAST_cbc_encrypt(const uint8_t *in, uint8_t *out, long length, CAST_decrypt(tin, ks); tout0 = tin[0] ^ xor0; tout1 = tin[1] ^ xor1; - l2nn(tout0, tout1, out, l + 8); + l2nn(tout0, tout1, out, l); xor0 = tin0; xor1 = tin1; } @@ -354,12 +356,12 @@ void CAST_set_key(CAST_KEY *key, size_t len, const uint8_t *data) { // The input and output encrypted as though 64bit cfb mode is being used. The // extra state information to record how much of the 64bit block we have used // is contained in *num. -void CAST_cfb64_encrypt(const uint8_t *in, uint8_t *out, long length, +void CAST_cfb64_encrypt(const uint8_t *in, uint8_t *out, size_t length, const CAST_KEY *schedule, uint8_t *ivec, int *num, int enc) { uint32_t v0, v1, t; int n = *num; - long l = length; + size_t l = length; uint32_t ti[2]; uint8_t *iv, c, cc; |