Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Frederik Sdun <fs_1600@web.de>
To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au,
	davem@davemloft.net
Subject: [PATCH] crypto/aes.c remove operator ? and variable t in bf_setkey
Date: Mon, 16 Jul 2007 02:52:34 +0200	[thread overview]
Message-ID: <1184547154.23516.12.camel@localhost> (raw)

Hi,

this removes the the ? operator which is false nearly all the time.


--- aes.c.orig  2007-07-15 11:43:21.000000000 +0200
+++ aes.c       2007-07-16 01:56:49.000000000 +0200
@@ -156,9 +156,12 @@
 
                p = (p << 1) ^ (p & 0x80 ? 0x01b : 0);
        }
+
+       sbx_tab[0] = 0x63;
+       isb_tab[0x63] = (u8) 0;
 
-       for (i = 0; i < 256; ++i) {
-               p = (i ? pow_tab[255 - log_tab[i]] : 0);
+       for (i = 1; i < 256; ++i) {
+               p = pow_tab[255 - log_tab[i]];
                q = ((p >> 7) | (p << 1)) ^ ((p >> 6) | (p << 2));
                p ^= 0x63 ^ q ^ ((q >> 6) | (q << 2));
                sbx_tab[i] = p;

this removes the variable t which is only a working copy of p, but you
do not need a copy

@@ -135,7 +135,7 @@
 static void __init
 gen_tabs (void)
 {
-       u32 i, t;
+       u32 i;
        u8 p, q;
 
        /* log and power tables for GF(2**8) finite field with
@@ -168,38 +171,38 @@
        for (i = 0; i < 256; ++i) {
                p = sbx_tab[i];
 
-               t = p;
-               fl_tab[0][i] = t;
-               fl_tab[1][i] = rol32(t, 8);
-               fl_tab[2][i] = rol32(t, 16);
-               fl_tab[3][i] = rol32(t, 24);
+
+               fl_tab[0][i] = p;
+               fl_tab[1][i] = rol32(p, 8);
+               fl_tab[2][i] = rol32(p, 16);
+               fl_tab[3][i] = rol32(p, 24);
 
-               t = ((u32) ff_mult (2, p)) |
+               p = ((u32) ff_mult (2, p)) |
                    ((u32) p << 8) |
                    ((u32) p << 16) | ((u32) ff_mult (3, p) << 24);
 
-               ft_tab[0][i] = t;
-               ft_tab[1][i] = rol32(t, 8);
-               ft_tab[2][i] = rol32(t, 16);
-               ft_tab[3][i] = rol32(t, 24);
+               ft_tab[0][i] = p;
+               ft_tab[1][i] = rol32(p, 8);
+               ft_tab[2][i] = rol32(p, 16);
+               ft_tab[3][i] = rol32(p, 24);
 
                p = isb_tab[i];
 
-               t = p;
-               il_tab[0][i] = t;
-               il_tab[1][i] = rol32(t, 8);
-               il_tab[2][i] = rol32(t, 16);
-               il_tab[3][i] = rol32(t, 24);
+
+               il_tab[0][i] = p;
+               il_tab[1][i] = rol32(p, 8);
+               il_tab[2][i] = rol32(p, 16);
+               il_tab[3][i] = rol32(p, 24);
 
-               t = ((u32) ff_mult (14, p)) |
+               p = ((u32) ff_mult (14, p)) |
                    ((u32) ff_mult (9, p) << 8) |
                    ((u32) ff_mult (13, p) << 16) |
                    ((u32) ff_mult (11, p) << 24);
 
-               it_tab[0][i] = t;
-               it_tab[1][i] = rol32(t, 8);
-               it_tab[2][i] = rol32(t, 16);
-               it_tab[3][i] = rol32(t, 24);
+               it_tab[0][i] = p;
+               it_tab[1][i] = rol32(p, 8);
+               it_tab[2][i] = rol32(p, 16);
+               it_tab[3][i] = rol32(p, 24);
        }
 }


Frederik

             reply	other threads:[~2007-07-16  0:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-16  0:52 Frederik Sdun [this message]
2007-07-16  3:28 ` [PATCH] crypto/aes.c remove operator ? and variable t in bf_setkey Herbert Xu
2007-07-16 13:15   ` Frederik Sdun
2007-07-17 12:35     ` Herbert Xu
2007-07-18 21:55       ` Frederik Sdun
2007-07-25  6:51         ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1184547154.23516.12.camel@localhost \
    --to=fs_1600@web.de \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox