[openssl-commits] [openssl] master update

Andy Polyakov appro at openssl.org
Mon Jul 9 10:38:01 UTC 2018


The branch master has been updated
       via  45197ad33ee77f3773eaefe2395072fbdd9d978c (commit)
       via  c118fb92386cc6f81aadf2a64473e94bac938cee (commit)
      from  9e26532295c579afa91a3edf0864b380a5f0ec16 (commit)


- Log -----------------------------------------------------------------
commit 45197ad33ee77f3773eaefe2395072fbdd9d978c
Author: Andy Polyakov <appro at openssl.org>
Date:   Sun Jul 8 12:12:15 2018 +0200

    modes/ocb128.c: readability and formatting improvements.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/6669)

commit c118fb92386cc6f81aadf2a64473e94bac938cee
Author: DesWurstes <DesWurstes at users.noreply.github.com>
Date:   Sat Jul 7 12:10:53 2018 +0300

    modes/ocb128.c: improve the calculation of double mask
    
    CLA: trivial
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/6667)

-----------------------------------------------------------------------

Summary of changes:
 crypto/modes/ocb128.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/crypto/modes/ocb128.c b/crypto/modes/ocb128.c
index 76591e6..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;
     }
 }
 
@@ -74,7 +65,7 @@ static void ocb_double(OCB_BLOCK *in, OCB_BLOCK *out)
      */
     mask = in->c[0] & 0x80;
     mask >>= 7;
-    mask *= 135;
+    mask = (0 - mask) & 0x87;
 
     ocb_block_lshift(in->c, 1, out->c);
 
@@ -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;


More information about the openssl-commits mailing list