aboutsummaryrefslogtreecommitdiff
path: root/crypto/modes
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2018-07-08 12:12:15 +0200
committerAndy Polyakov <appro@openssl.org>2018-07-09 12:37:09 +0200
commit45197ad33ee77f3773eaefe2395072fbdd9d978c (patch)
tree9a0d73457945d2698f1648eeb88c9544041165fe /crypto/modes
parentc118fb92386cc6f81aadf2a64473e94bac938cee (diff)
downloadopenssl-45197ad33ee77f3773eaefe2395072fbdd9d978c.zip
openssl-45197ad33ee77f3773eaefe2395072fbdd9d978c.tar.gz
openssl-45197ad33ee77f3773eaefe2395072fbdd9d978c.tar.bz2
modes/ocb128.c: readability and formatting improvements.
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6669)
Diffstat (limited to 'crypto/modes')
-rw-r--r--crypto/modes/ocb128.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/crypto/modes/ocb128.c b/crypto/modes/ocb128.c
index 72e6ea9..713b9aa 100644
--- a/crypto/modes/ocb128.c
+++ b/crypto/modes/ocb128.c
@@ -42,22 +42,13 @@ static u32 ocb_ntz(u64 n)
static void ocb_block_lshift(const unsigned char *in, size_t shift,
unsigned char *out)
{
- unsigned char shift_mask;
int i;
- unsigned char mask[15];
+ unsigned char carry = 0, carry_next;
- shift_mask = 0xff;
- shift_mask <<= (8 - shift);
for (i = 15; i >= 0; i--) {
- if (i > 0) {
- mask[i - 1] = in[i] & shift_mask;
- mask[i - 1] >>= 8 - shift;
- }
- out[i] = in[i] << shift;
-
- if (i != 15) {
- out[i] ^= mask[i];
- }
+ carry_next = in[i] >> (8 - shift);
+ out[i] = (in[i] << shift) | carry;
+ carry = carry_next;
}
}
@@ -119,8 +110,7 @@ static OCB_BLOCK *ocb_lookup_l(OCB128_CONTEXT *ctx, size_t idx)
* the index.
*/
ctx->max_l_index += (idx - ctx->max_l_index + 4) & ~3;
- tmp_ptr =
- OPENSSL_realloc(ctx->l, ctx->max_l_index * sizeof(OCB_BLOCK));
+ tmp_ptr = OPENSSL_realloc(ctx->l, ctx->max_l_index * sizeof(OCB_BLOCK));
if (tmp_ptr == NULL) /* prevent ctx->l from being clobbered */
return NULL;
ctx->l = tmp_ptr;