[git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-58-gdfb4673

by Werner Koch cvs at cvs.gnupg.org
Wed Nov 21 14:28:43 CET 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".

The branch, master has been updated
       via  dfb4673da8ee52d95e0a62c9f49ca8599943f22e (commit)
       via  3047795794eb238aa684bd0729acf64c82a19e09 (commit)
       via  7f90d3dff4f87c0c42fc9b9336bbe77e8d33d33a (commit)
       via  8afabc2813948778a3db52d9dee9a041a3dd50d4 (commit)
       via  d8bdfa42ed582655c180e7db9b16d4e756a12a6e (commit)
       via  9e1552517f68459a165ddebbba85e7cf37ff4f0c (commit)
       via  19b9efd1f47a5de9c450ce8212dfa3174a029c7a (commit)
       via  6368ed542150956ff4ba8170a15bbc534143675c (commit)
      from  a96974de734beb51a733a89b3283bcf7b433b54c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dfb4673da8ee52d95e0a62c9f49ca8599943f22e
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Nov 21 12:58:36 2012 +0100

    Fix for strict aliasing rules.
    
    * cipher/rijndael.c (do_setkey, prepare_decryption): Use u32_a_t for
    casting.
    --
    
    gcc 4.7.1 now show warnings for more functions.  Like:
    
      rijndael.c:412:19: warning: dereferencing type-punned pointer will
      break strict-aliasing rules [-Wstrict-aliasing]
    
    This fixes them using the may_alias attribute.

diff --git a/cipher/rijndael.c b/cipher/rijndael.c
index 3418c99..d081b42 100644
--- a/cipher/rijndael.c
+++ b/cipher/rijndael.c
@@ -362,7 +362,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
 
       for (j = KC-1; j >= 0; j--)
         {
-          *((u32*)tk[j]) = *((u32*)k[j]);
+          *((u32_a_t*)tk[j]) = *((u32_a_t*)k[j]);
         }
       r = 0;
       t = 0;
@@ -371,7 +371,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
         {
           for (; (j < KC) && (t < 4); j++, t++)
             {
-              *((u32*)W[r][t]) = *((u32*)tk[j]);
+              *((u32_a_t*)W[r][t]) = *((u32_a_t*)tk[j]);
             }
           if (t == 4)
             {
@@ -394,14 +394,14 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
             {
               for (j = 1; j < KC; j++)
                 {
-                  *((u32*)tk[j]) ^= *((u32*)tk[j-1]);
+                  *((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
                 }
             }
           else
             {
               for (j = 1; j < KC/2; j++)
                 {
-                  *((u32*)tk[j]) ^= *((u32*)tk[j-1]);
+                  *((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
                 }
               tk[KC/2][0] ^= S[tk[KC/2 - 1][0]];
               tk[KC/2][1] ^= S[tk[KC/2 - 1][1]];
@@ -409,7 +409,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
               tk[KC/2][3] ^= S[tk[KC/2 - 1][3]];
               for (j = KC/2 + 1; j < KC; j++)
                 {
-                  *((u32*)tk[j]) ^= *((u32*)tk[j-1]);
+                  *((u32_a_t*)tk[j]) ^= *((u32_a_t*)tk[j-1]);
                 }
             }
 
@@ -418,7 +418,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
             {
               for (; (j < KC) && (t < 4); j++, t++)
                 {
-                  *((u32*)W[r][t]) = *((u32*)tk[j]);
+                  *((u32_a_t*)W[r][t]) = *((u32_a_t*)tk[j]);
                 }
               if (t == 4)
                 {
@@ -488,29 +488,29 @@ prepare_decryption( RIJNDAEL_context *ctx )
 
       for (r=0; r < MAXROUNDS+1; r++ )
         {
-          *((u32*)ctx->keyschdec[r][0]) = *((u32*)ctx->keyschenc[r][0]);
-          *((u32*)ctx->keyschdec[r][1]) = *((u32*)ctx->keyschenc[r][1]);
-          *((u32*)ctx->keyschdec[r][2]) = *((u32*)ctx->keyschenc[r][2]);
-          *((u32*)ctx->keyschdec[r][3]) = *((u32*)ctx->keyschenc[r][3]);
+          *((u32_a_t*)ctx->keyschdec[r][0]) = *((u32_a_t*)ctx->keyschenc[r][0]);
+          *((u32_a_t*)ctx->keyschdec[r][1]) = *((u32_a_t*)ctx->keyschenc[r][1]);
+          *((u32_a_t*)ctx->keyschdec[r][2]) = *((u32_a_t*)ctx->keyschenc[r][2]);
+          *((u32_a_t*)ctx->keyschdec[r][3]) = *((u32_a_t*)ctx->keyschenc[r][3]);
         }
 #define W (ctx->keyschdec)
       for (r = 1; r < ctx->rounds; r++)
         {
           w = W[r][0];
-          *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
-            ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
+          *((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
+            ^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
 
           w = W[r][1];
-          *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
-            ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
+          *((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
+            ^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
 
           w = W[r][2];
-          *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
-        ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
+          *((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
+        ^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
 
           w = W[r][3];
-          *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
-            ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
+          *((u32_a_t*)w) = *((u32_a_t*)U1[w[0]]) ^ *((u32_a_t*)U2[w[1]])
+            ^ *((u32_a_t*)U3[w[2]]) ^ *((u32_a_t*)U4[w[3]]);
         }
 #undef W
 #undef w

commit 3047795794eb238aa684bd0729acf64c82a19e09
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Nov 21 12:30:58 2012 +0100

    Do not detect AES-NI support if disabled by configure.
    
    * src/hwfeatures.c (detect_ia32_gnuc): Detect AESNI support only if
    that support has been enabled.
    --
    
    We better do not try to detect AESNI support if the support has been
    disabled in the configure run.  Disabling the support might have been
    done due to problem with the AESNI support on a certain platform and
    we can't exclude problem for sure with the detection code either.

diff --git a/src/hwfeatures.c b/src/hwfeatures.c
index 89d7685..82c435b 100644
--- a/src/hwfeatures.c
+++ b/src/hwfeatures.c
@@ -118,8 +118,9 @@ detect_x86_64_gnuc (void)
       /* This is an AMD CPU.  */
     }
 
-  /* Detect Intel features, that might be supported also by other vendors
-   * also. */
+  /* Detect Intel features, that might also be supported by other
+     vendors.  */
+#ifdef ENABLE_AESNI_SUPPORT
   asm volatile
     ("movl $1, %%eax\n\t"           /* Get CPU info and feature flags.  */
      "cpuid\n"
@@ -132,6 +133,8 @@ detect_x86_64_gnuc (void)
      :
      : "%eax", "%ebx", "%ecx", "%edx", "cc"
      );
+#endif /*#ifdef ENABLE_AESNI_SUPPORT*/
+
 }
 #endif /* __x86_64__ && __GNUC__ */
 
@@ -246,8 +249,9 @@ detect_ia32_gnuc (void)
 
     }
 
-  /* Detect Intel features, that might be supported also by other vendors
-   * also. */
+  /* Detect Intel features, that might also be supported by other
+     vendors.  */
+#ifdef ENABLE_AESNI_SUPPORT
   asm volatile
     ("pushl %%ebx\n\t"	        /* Save GOT register.  */
      "movl $1, %%eax\n\t"           /* Get CPU info and feature flags.  */
@@ -262,6 +266,8 @@ detect_ia32_gnuc (void)
      :
      : "%eax", "%ecx", "%edx", "cc"
      );
+#endif /*ENABLE_AESNI_SUPPORT*/
+
 }
 #endif /* __i386__ && SIZEOF_UNSIGNED_LONG == 4 && __GNUC__ */
 

commit 7f90d3dff4f87c0c42fc9b9336bbe77e8d33d33a
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Nov 21 11:53:27 2012 +0100

    Add Jussi Kivilinna to the AUTHORS.
    
    --

diff --git a/AUTHORS b/AUTHORS
index c0231d6..3aa54f9 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -107,6 +107,7 @@ Authors with a DCO
 
 DCO:2012-04-16:Tomáš Mráz <tm at t8m.info>
 DCO:2012-04-20:Rafaël Carré <funman at videolan.org>
+DCO:2012-11-14:Jussi Kivilinna <jussi.kivilinna at mbnet.fi>
 
 
 More credits

commit 8afabc2813948778a3db52d9dee9a041a3dd50d4
Author: Jussi Kivilinna <jussi.kivilinna at mbnet.fi>
Date:   Fri Nov 16 10:45:43 2012 +0200

    Fix too large burn_stack in camellia-glue.c
    
    * cipher/camellia-glue.c (camellia_encrypt, camellia_decrypt): Do not
    take full array size of KEY_TABLE_TYPE, but argument size instead.
    --
    
    KEY_TABLE_TYPE is array type, and sizeof(KEY_TABLE_TYPE) gives full
    size of array. However what is wanted here is size of array argument
    in stack, so change sizeof(KEY_TABLE_TYPE) to sizeof(void*). This
    gives boost in speed for camellia cipher.
    
    On AMD Phenom II, x86-64:
    
    Before:
    
     $ tests/benchmark --cipher-repetitions 10 cipher camellia128
     Running each test 10 times.
                     ECB/Stream         CBC             CFB             OFB             CTR
                  --------------- --------------- --------------- --------------- ---------------
     CAMELLIA128    250ms   240ms   270ms   260ms   250ms   250ms   260ms   250ms   340ms   330ms
    
    After:
    
     $ tests/benchmark --cipher-repetitions 10 cipher camellia128
     Running each test 10 times.
                     ECB/Stream         CBC             CFB             OFB             CTR
                  --------------- --------------- --------------- --------------- ---------------
     CAMELLIA128    140ms   130ms   150ms   160ms   150ms   150ms   150ms   140ms   220ms   220ms
    
    [v2]
     - Add GNU style changelog
    
    Signed-off-by: Jussi Kivilinna <jussi.kivilinna at mbnet.fi>

diff --git a/cipher/camellia-glue.c b/cipher/camellia-glue.c
index a263621..c5019d0 100644
--- a/cipher/camellia-glue.c
+++ b/cipher/camellia-glue.c
@@ -111,7 +111,7 @@ camellia_encrypt(void *c, byte *outbuf, const byte *inbuf)
 
   Camellia_EncryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf);
   _gcry_burn_stack
-    (sizeof(int)+2*sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE)
+    (sizeof(int)+2*sizeof(unsigned char *)+sizeof(void*/*KEY_TABLE_TYPE*/)
      +4*sizeof(u32)
      +2*sizeof(u32*)+4*sizeof(u32)
      +2*2*sizeof(void*) /* Function calls.  */
@@ -125,7 +125,7 @@ camellia_decrypt(void *c, byte *outbuf, const byte *inbuf)
 
   Camellia_DecryptBlock(ctx->keybitlength,inbuf,ctx->keytable,outbuf);
   _gcry_burn_stack
-    (sizeof(int)+2*sizeof(unsigned char *)+sizeof(KEY_TABLE_TYPE)
+    (sizeof(int)+2*sizeof(unsigned char *)+sizeof(void*/*KEY_TABLE_TYPE*/)
      +4*sizeof(u32)
      +2*sizeof(u32*)+4*sizeof(u32)
      +2*2*sizeof(void*) /* Function calls.  */

commit d8bdfa42ed582655c180e7db9b16d4e756a12a6e
Author: Jussi Kivilinna <jussi.kivilinna at mbnet.fi>
Date:   Fri Nov 16 10:44:54 2012 +0200

    Add x86_64 support for AES-NI
    
    * cipher/rijndael.c [ENABLE_AESNI_SUPPORT]: Enable USE_AESNI on x86-64.
    (do_setkey) [USE_AESNI_is_disabled_here]: Use %[key] and %[ksch]
    directly as registers instead of using temporary register %%esi.
    [USE_AESNI] (do_aesni_enc_aligned, do_aesni_dec_aligned, do_aesni_cfb,
    do_aesni_ctr, do_aesni_ctr_4): Use %[key] directly as register instead
    of using temporary register %%esi.
    [USE_AESNI] (do_aesni_cfb, do_aesni_ctr, do_aesni_ctr_4): Change %[key]
    from generic "g" type to register "r".
    * src/hwfeatures.c (_gcry_detect_hw_features) [__x86_64__]: Do not
    clear AES-NI feature flag.
    --
    
    AES-NI assembler uses %%esi for key-material pointer register. However
    %[key] can be marked as "r" (register) and automatically be 64bit on
    x86-64 and be 32bit on i386.
    
    So use %[key] for pointer register instead of %esi and that way make
    same AES-NI code work on both x86-64 and i386.
    
    [v2]
     - Add GNU style changelog
     - Fixed do_setkey changes, use %[ksch] for output instead of %[key]
     - Changed [key] assembler arguments from "g" to "r" to force use of
       registers in all cases (when tested v1, "g" did work as indented
       and %[key] mapped to register on i386 and x86-64, but that might
       not happen always).
    
    Signed-off-by: Jussi Kivilinna <jussi.kivilinna at mbnet.fi>

diff --git a/cipher/rijndael.c b/cipher/rijndael.c
index b9ee8ad..3418c99 100644
--- a/cipher/rijndael.c
+++ b/cipher/rijndael.c
@@ -75,7 +75,7 @@
    gcc 3.  However, to be on the safe side we require at least gcc 4.  */
 #undef USE_AESNI
 #ifdef ENABLE_AESNI_SUPPORT
-# if defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4 && __GNUC__ >= 4
+# if ((defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4) || defined(__x86_64__)) && __GNUC__ >= 4
 #  define USE_AESNI 1
 # endif
 #endif /* ENABLE_AESNI_SUPPORT */
@@ -297,40 +297,38 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
          than using the standard key schedule.  We disable it for
          now and don't put any effort into implementing this for
          AES-192 and AES-256.  */
-      asm volatile ("movl   %[key], %%esi\n\t"
-                    "movdqu (%%esi), %%xmm1\n\t"     /* xmm1 := key   */
-                    "movl   %[ksch], %%esi\n\t"
-                    "movdqa %%xmm1, (%%esi)\n\t"     /* ksch[0] := xmm1  */
+      asm volatile ("movdqu (%[key]), %%xmm1\n\t"     /* xmm1 := key   */
+                    "movdqa %%xmm1, (%[ksch])\n\t"     /* ksch[0] := xmm1  */
                     "aeskeygenassist $0x01, %%xmm1, %%xmm2\n\t"
                     "call .Lexpand128_%=\n\t"
-                    "movdqa %%xmm1, 0x10(%%esi)\n\t" /* ksch[1] := xmm1  */
+                    "movdqa %%xmm1, 0x10(%[ksch])\n\t" /* ksch[1] := xmm1  */
                     "aeskeygenassist $0x02, %%xmm1, %%xmm2\n\t"
                     "call .Lexpand128_%=\n\t"
-                    "movdqa %%xmm1, 0x20(%%esi)\n\t" /* ksch[2] := xmm1  */
+                    "movdqa %%xmm1, 0x20(%[ksch])\n\t" /* ksch[2] := xmm1  */
                     "aeskeygenassist $0x04, %%xmm1, %%xmm2\n\t"
                     "call .Lexpand128_%=\n\t"
-                    "movdqa %%xmm1, 0x30(%%esi)\n\t" /* ksch[3] := xmm1  */
+                    "movdqa %%xmm1, 0x30(%[ksch])\n\t" /* ksch[3] := xmm1  */
                     "aeskeygenassist $0x08, %%xmm1, %%xmm2\n\t"
                     "call .Lexpand128_%=\n\t"
-                    "movdqa %%xmm1, 0x40(%%esi)\n\t" /* ksch[4] := xmm1  */
+                    "movdqa %%xmm1, 0x40(%[ksch])\n\t" /* ksch[4] := xmm1  */
                     "aeskeygenassist $0x10, %%xmm1, %%xmm2\n\t"
                     "call .Lexpand128_%=\n\t"
-                    "movdqa %%xmm1, 0x50(%%esi)\n\t" /* ksch[5] := xmm1  */
+                    "movdqa %%xmm1, 0x50(%[ksch])\n\t" /* ksch[5] := xmm1  */
                     "aeskeygenassist $0x20, %%xmm1, %%xmm2\n\t"
                     "call .Lexpand128_%=\n\t"
-                    "movdqa %%xmm1, 0x60(%%esi)\n\t" /* ksch[6] := xmm1  */
+                    "movdqa %%xmm1, 0x60(%[ksch])\n\t" /* ksch[6] := xmm1  */
                     "aeskeygenassist $0x40, %%xmm1, %%xmm2\n\t"
                     "call .Lexpand128_%=\n\t"
-                    "movdqa %%xmm1, 0x70(%%esi)\n\t" /* ksch[7] := xmm1  */
+                    "movdqa %%xmm1, 0x70(%[ksch])\n\t" /* ksch[7] := xmm1  */
                     "aeskeygenassist $0x80, %%xmm1, %%xmm2\n\t"
                     "call .Lexpand128_%=\n\t"
-                    "movdqa %%xmm1, 0x80(%%esi)\n\t" /* ksch[8] := xmm1  */
+                    "movdqa %%xmm1, 0x80(%[ksch])\n\t" /* ksch[8] := xmm1  */
                     "aeskeygenassist $0x1b, %%xmm1, %%xmm2\n\t"
                     "call .Lexpand128_%=\n\t"
-                    "movdqa %%xmm1, 0x90(%%esi)\n\t" /* ksch[9] := xmm1  */
+                    "movdqa %%xmm1, 0x90(%[ksch])\n\t" /* ksch[9] := xmm1  */
                     "aeskeygenassist $0x36, %%xmm1, %%xmm2\n\t"
                     "call .Lexpand128_%=\n\t"
-                    "movdqa %%xmm1, 0xa0(%%esi)\n\t" /* ksch[10] := xmm1  */
+                    "movdqa %%xmm1, 0xa0(%[ksch])\n\t" /* ksch[10] := xmm1  */
                     "jmp .Lleave%=\n"
 
                     ".Lexpand128_%=:\n\t"
@@ -350,8 +348,8 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
                     "pxor %%xmm2, %%xmm2\n\t"
                     "pxor %%xmm3, %%xmm3\n"
                     :
-                    : [key] "g" (key), [ksch] "g" (ctx->keyschenc)
-                    : "%esi", "cc", "memory" );
+                    : [key] "r" (key), [ksch] "r" (ctx->keyschenc)
+                    : "cc", "memory" );
     }
 #endif /*USE_AESNI*/
   else
@@ -722,40 +720,39 @@ do_aesni_enc_aligned (const RIJNDAEL_context *ctx,
      aligned but that is a special case.  We should better implement
      CFB direct in asm.  */
   asm volatile ("movdqu %[src], %%xmm0\n\t"     /* xmm0 := *a     */
-                "movl   %[key], %%esi\n\t"      /* esi  := keyschenc */
-                "movdqa (%%esi), %%xmm1\n\t"    /* xmm1 := key[0] */
+                "movdqa (%[key]), %%xmm1\n\t"    /* xmm1 := key[0] */
                 "pxor   %%xmm1, %%xmm0\n\t"     /* xmm0 ^= key[0] */
-                "movdqa 0x10(%%esi), %%xmm1\n\t"
+                "movdqa 0x10(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x20(%%esi), %%xmm1\n\t"
+                "movdqa 0x20(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x30(%%esi), %%xmm1\n\t"
+                "movdqa 0x30(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x40(%%esi), %%xmm1\n\t"
+                "movdqa 0x40(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x50(%%esi), %%xmm1\n\t"
+                "movdqa 0x50(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x60(%%esi), %%xmm1\n\t"
+                "movdqa 0x60(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x70(%%esi), %%xmm1\n\t"
+                "movdqa 0x70(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x80(%%esi), %%xmm1\n\t"
+                "movdqa 0x80(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x90(%%esi), %%xmm1\n\t"
+                "movdqa 0x90(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xa0(%%esi), %%xmm1\n\t"
+                "movdqa 0xa0(%[key]), %%xmm1\n\t"
                 "cmp $10, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xb0(%%esi), %%xmm1\n\t"
+                "movdqa 0xb0(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xc0(%%esi), %%xmm1\n\t"
+                "movdqa 0xc0(%[key]), %%xmm1\n\t"
                 "cmp $12, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xd0(%%esi), %%xmm1\n\t"
+                "movdqa 0xd0(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xe0(%%esi), %%xmm1\n"
+                "movdqa 0xe0(%[key]), %%xmm1\n"
 
                 ".Lenclast%=:\n\t"
                 aesenclast_xmm1_xmm0
@@ -764,7 +761,7 @@ do_aesni_enc_aligned (const RIJNDAEL_context *ctx,
                 : [src] "m" (*a),
                   [key] "r" (ctx->keyschenc),
                   [rounds] "r" (ctx->rounds)
-                : "%esi", "cc", "memory");
+                : "cc", "memory");
 #undef aesenc_xmm1_xmm0
 #undef aesenclast_xmm1_xmm0
 }
@@ -777,40 +774,39 @@ do_aesni_dec_aligned (const RIJNDAEL_context *ctx,
 #define aesdec_xmm1_xmm0      ".byte 0x66, 0x0f, 0x38, 0xde, 0xc1\n\t"
 #define aesdeclast_xmm1_xmm0  ".byte 0x66, 0x0f, 0x38, 0xdf, 0xc1\n\t"
   asm volatile ("movdqu %[src], %%xmm0\n\t"     /* xmm0 := *a     */
-                "movl   %[key], %%esi\n\t"
-                "movdqa (%%esi), %%xmm1\n\t"
+                "movdqa (%[key]), %%xmm1\n\t"
                 "pxor   %%xmm1, %%xmm0\n\t"     /* xmm0 ^= key[0] */
-                "movdqa 0x10(%%esi), %%xmm1\n\t"
+                "movdqa 0x10(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0x20(%%esi), %%xmm1\n\t"
+                "movdqa 0x20(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0x30(%%esi), %%xmm1\n\t"
+                "movdqa 0x30(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0x40(%%esi), %%xmm1\n\t"
+                "movdqa 0x40(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0x50(%%esi), %%xmm1\n\t"
+                "movdqa 0x50(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0x60(%%esi), %%xmm1\n\t"
+                "movdqa 0x60(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0x70(%%esi), %%xmm1\n\t"
+                "movdqa 0x70(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0x80(%%esi), %%xmm1\n\t"
+                "movdqa 0x80(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0x90(%%esi), %%xmm1\n\t"
+                "movdqa 0x90(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0xa0(%%esi), %%xmm1\n\t"
+                "movdqa 0xa0(%[key]), %%xmm1\n\t"
                 "cmp $10, %[rounds]\n\t"
                 "jz .Ldeclast%=\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0xb0(%%esi), %%xmm1\n\t"
+                "movdqa 0xb0(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0xc0(%%esi), %%xmm1\n\t"
+                "movdqa 0xc0(%[key]), %%xmm1\n\t"
                 "cmp $12, %[rounds]\n\t"
                 "jz .Ldeclast%=\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0xd0(%%esi), %%xmm1\n\t"
+                "movdqa 0xd0(%[key]), %%xmm1\n\t"
                 aesdec_xmm1_xmm0
-                "movdqa 0xe0(%%esi), %%xmm1\n"
+                "movdqa 0xe0(%[key]), %%xmm1\n"
 
                 ".Ldeclast%=:\n\t"
                 aesdeclast_xmm1_xmm0
@@ -819,7 +815,7 @@ do_aesni_dec_aligned (const RIJNDAEL_context *ctx,
                 : [src] "m" (*a),
                   [key] "r" (ctx->keyschdec),
                   [rounds] "r" (ctx->rounds)
-                : "%esi", "cc", "memory");
+                : "cc", "memory");
 #undef aesdec_xmm1_xmm0
 #undef aesdeclast_xmm1_xmm0
 }
@@ -836,40 +832,39 @@ do_aesni_cfb (const RIJNDAEL_context *ctx, int decrypt_flag,
 #define aesenc_xmm1_xmm0      ".byte 0x66, 0x0f, 0x38, 0xdc, 0xc1\n\t"
 #define aesenclast_xmm1_xmm0  ".byte 0x66, 0x0f, 0x38, 0xdd, 0xc1\n\t"
   asm volatile ("movdqa %[iv], %%xmm0\n\t"      /* xmm0 := IV     */
-                "movl   %[key], %%esi\n\t"      /* esi  := keyschenc */
-                "movdqa (%%esi), %%xmm1\n\t"    /* xmm1 := key[0] */
+                "movdqa (%[key]), %%xmm1\n\t"    /* xmm1 := key[0] */
                 "pxor   %%xmm1, %%xmm0\n\t"     /* xmm0 ^= key[0] */
-                "movdqa 0x10(%%esi), %%xmm1\n\t"
+                "movdqa 0x10(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x20(%%esi), %%xmm1\n\t"
+                "movdqa 0x20(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x30(%%esi), %%xmm1\n\t"
+                "movdqa 0x30(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x40(%%esi), %%xmm1\n\t"
+                "movdqa 0x40(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x50(%%esi), %%xmm1\n\t"
+                "movdqa 0x50(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x60(%%esi), %%xmm1\n\t"
+                "movdqa 0x60(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x70(%%esi), %%xmm1\n\t"
+                "movdqa 0x70(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x80(%%esi), %%xmm1\n\t"
+                "movdqa 0x80(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x90(%%esi), %%xmm1\n\t"
+                "movdqa 0x90(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xa0(%%esi), %%xmm1\n\t"
+                "movdqa 0xa0(%[key]), %%xmm1\n\t"
                 "cmp $10, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xb0(%%esi), %%xmm1\n\t"
+                "movdqa 0xb0(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xc0(%%esi), %%xmm1\n\t"
+                "movdqa 0xc0(%[key]), %%xmm1\n\t"
                 "cmp $12, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xd0(%%esi), %%xmm1\n\t"
+                "movdqa 0xd0(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xe0(%%esi), %%xmm1\n"
+                "movdqa 0xe0(%[key]), %%xmm1\n"
 
                 ".Lenclast%=:\n\t"
                 aesenclast_xmm1_xmm0
@@ -886,10 +881,10 @@ do_aesni_cfb (const RIJNDAEL_context *ctx, int decrypt_flag,
                 "movdqu %%xmm0, %[dst]\n"        /* Store output.   */
                 : [iv] "+m" (*iv), [dst] "=m" (*b)
                 : [src] "m" (*a),
-                  [key] "g" (ctx->keyschenc),
+                  [key] "r" (ctx->keyschenc),
                   [rounds] "g" (ctx->rounds),
                   [decrypt] "m" (decrypt_flag)
-                : "%esi", "cc", "memory");
+                : "cc", "memory");
 #undef aesenc_xmm1_xmm0
 #undef aesenclast_xmm1_xmm0
 }
@@ -915,40 +910,39 @@ do_aesni_ctr (const RIJNDAEL_context *ctx,
                 "pshufb %[mask], %%xmm2\n\t"
                 "movdqa %%xmm2, %[ctr]\n"       /* Update CTR.         */
 
-                "movl   %[key], %%esi\n\t"      /* esi  := keyschenc */
-                "movdqa (%%esi), %%xmm1\n\t"    /* xmm1 := key[0]    */
+                "movdqa (%[key]), %%xmm1\n\t"    /* xmm1 := key[0]    */
                 "pxor   %%xmm1, %%xmm0\n\t"     /* xmm0 ^= key[0]    */
-                "movdqa 0x10(%%esi), %%xmm1\n\t"
+                "movdqa 0x10(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x20(%%esi), %%xmm1\n\t"
+                "movdqa 0x20(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x30(%%esi), %%xmm1\n\t"
+                "movdqa 0x30(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x40(%%esi), %%xmm1\n\t"
+                "movdqa 0x40(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x50(%%esi), %%xmm1\n\t"
+                "movdqa 0x50(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x60(%%esi), %%xmm1\n\t"
+                "movdqa 0x60(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x70(%%esi), %%xmm1\n\t"
+                "movdqa 0x70(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x80(%%esi), %%xmm1\n\t"
+                "movdqa 0x80(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0x90(%%esi), %%xmm1\n\t"
+                "movdqa 0x90(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xa0(%%esi), %%xmm1\n\t"
+                "movdqa 0xa0(%[key]), %%xmm1\n\t"
                 "cmp $10, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xb0(%%esi), %%xmm1\n\t"
+                "movdqa 0xb0(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xc0(%%esi), %%xmm1\n\t"
+                "movdqa 0xc0(%[key]), %%xmm1\n\t"
                 "cmp $12, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xd0(%%esi), %%xmm1\n\t"
+                "movdqa 0xd0(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
-                "movdqa 0xe0(%%esi), %%xmm1\n"
+                "movdqa 0xe0(%[key]), %%xmm1\n"
 
                 ".Lenclast%=:\n\t"
                 aesenclast_xmm1_xmm0
@@ -958,7 +952,7 @@ do_aesni_ctr (const RIJNDAEL_context *ctx,
 
                 : [ctr] "+m" (*ctr), [dst] "=m" (*b)
                 : [src] "m" (*a),
-                  [key] "g" (ctx->keyschenc),
+                  [key] "r" (ctx->keyschenc),
                   [rounds] "g" (ctx->rounds),
                   [mask] "m" (*be_mask)
                 : "%esi", "cc", "memory");
@@ -1012,82 +1006,81 @@ do_aesni_ctr_4 (const RIJNDAEL_context *ctx,
                 "pshufb %[mask], %%xmm5\n\t"    /* xmm5 := be(xmm5) */
                 "movdqa %%xmm5, %[ctr]\n"       /* Update CTR.      */
 
-                "movl   %[key], %%esi\n\t"      /* esi  := keyschenc */
-                "movdqa (%%esi), %%xmm1\n\t"    /* xmm1 := key[0]    */
+                "movdqa (%[key]), %%xmm1\n\t"    /* xmm1 := key[0]    */
                 "pxor   %%xmm1, %%xmm0\n\t"     /* xmm0 ^= key[0]    */
                 "pxor   %%xmm1, %%xmm2\n\t"     /* xmm2 ^= key[0]    */
                 "pxor   %%xmm1, %%xmm3\n\t"     /* xmm3 ^= key[0]    */
                 "pxor   %%xmm1, %%xmm4\n\t"     /* xmm4 ^= key[0]    */
-                "movdqa 0x10(%%esi), %%xmm1\n\t"
+                "movdqa 0x10(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0x20(%%esi), %%xmm1\n\t"
+                "movdqa 0x20(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0x30(%%esi), %%xmm1\n\t"
+                "movdqa 0x30(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0x40(%%esi), %%xmm1\n\t"
+                "movdqa 0x40(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0x50(%%esi), %%xmm1\n\t"
+                "movdqa 0x50(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0x60(%%esi), %%xmm1\n\t"
+                "movdqa 0x60(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0x70(%%esi), %%xmm1\n\t"
+                "movdqa 0x70(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0x80(%%esi), %%xmm1\n\t"
+                "movdqa 0x80(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0x90(%%esi), %%xmm1\n\t"
+                "movdqa 0x90(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0xa0(%%esi), %%xmm1\n\t"
+                "movdqa 0xa0(%[key]), %%xmm1\n\t"
                 "cmp $10, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0xb0(%%esi), %%xmm1\n\t"
+                "movdqa 0xb0(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0xc0(%%esi), %%xmm1\n\t"
+                "movdqa 0xc0(%[key]), %%xmm1\n\t"
                 "cmp $12, %[rounds]\n\t"
                 "jz .Lenclast%=\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0xd0(%%esi), %%xmm1\n\t"
+                "movdqa 0xd0(%[key]), %%xmm1\n\t"
                 aesenc_xmm1_xmm0
                 aesenc_xmm1_xmm2
                 aesenc_xmm1_xmm3
                 aesenc_xmm1_xmm4
-                "movdqa 0xe0(%%esi), %%xmm1\n"
+                "movdqa 0xe0(%[key]), %%xmm1\n"
 
                 ".Lenclast%=:\n\t"
                 aesenclast_xmm1_xmm0
@@ -1113,7 +1106,7 @@ do_aesni_ctr_4 (const RIJNDAEL_context *ctx,
 
                 : [ctr] "+m" (*ctr), [dst] "=m" (*b)
                 : [src] "m" (*a),
-                  [key] "g" (ctx->keyschenc),
+                  [key] "r" (ctx->keyschenc),
                   [rounds] "g" (ctx->rounds),
                   [mask] "m" (*be_mask)
                 : "%esi", "cc", "memory");
diff --git a/src/hwfeatures.c b/src/hwfeatures.c
index 606f3e7..89d7685 100644
--- a/src/hwfeatures.c
+++ b/src/hwfeatures.c
@@ -292,9 +292,6 @@ _gcry_detect_hw_features (unsigned int disabled_features)
 # ifdef __GNUC__
   {
     detect_x86_64_gnuc ();
-    /* We don't have AESNI support for 64 bit yet.  Thus we should not
-       announce it.  */
-    hw_features &= ~HWF_INTEL_AESNI;
   }
 # endif
 #endif

commit 9e1552517f68459a165ddebbba85e7cf37ff4f0c
Author: Jussi Kivilinna <jussi.kivilinna at mbnet.fi>
Date:   Fri Nov 16 10:44:49 2012 +0200

    Fix cpuid vendor-id check for i386 and x86-64
    
    * src/hwfeatures.c (detect_x86_64_gnuc, detect_ia32_gnuc): Allow
    Intel features be detect from CPU by other vendors too.
    --
    
    detect_x86_64_gnuc() and detect_ia32_gnuc() incorrectly exclude Intel
    features on all other vendor CPUs. What we want here, is to detect if
    CPU from any vendor support said Intel feature (in this case AES-NI).
    
    [v2]
     - Add GNU style changelog
    
    Signed-off-by: Jussi Kivilinna <jussi.kivilinna at mbnet.fi>

diff --git a/src/hwfeatures.c b/src/hwfeatures.c
index 456c07a..606f3e7 100644
--- a/src/hwfeatures.c
+++ b/src/hwfeatures.c
@@ -112,24 +112,26 @@ detect_x86_64_gnuc (void)
   else if (!strcmp (vendor_id, "GenuineIntel"))
     {
       /* This is an Intel CPU.  */
-      asm volatile
-        ("movl $1, %%eax\n\t"           /* Get CPU info and feature flags.  */
-         "cpuid\n"
-         "testl $0x02000000, %%ecx\n\t" /* Test bit 25.  */
-         "jz .Lno_aes%=\n\t"            /* No AES support.  */
-         "orl $256, %0\n"               /* Set our HWF_INTEL_AES bit.  */
-
-         ".Lno_aes%=:\n"
-         : "+r" (hw_features)
-         :
-         : "%eax", "%ebx", "%ecx", "%edx", "cc"
-         );
     }
   else if (!strcmp (vendor_id, "AuthenticAMD"))
     {
       /* This is an AMD CPU.  */
-
     }
+
+  /* Detect Intel features, that might be supported also by other vendors
+   * also. */
+  asm volatile
+    ("movl $1, %%eax\n\t"           /* Get CPU info and feature flags.  */
+     "cpuid\n"
+     "testl $0x02000000, %%ecx\n\t" /* Test bit 25.  */
+     "jz .Lno_aes%=\n\t"            /* No AES support.  */
+     "orl $256, %0\n"               /* Set our HWF_INTEL_AES bit.  */
+
+     ".Lno_aes%=:\n"
+     : "+r" (hw_features)
+     :
+     : "%eax", "%ebx", "%ecx", "%edx", "cc"
+     );
 }
 #endif /* __x86_64__ && __GNUC__ */
 
@@ -237,26 +239,29 @@ detect_ia32_gnuc (void)
   else if (!strcmp (vendor_id, "GenuineIntel"))
     {
       /* This is an Intel CPU.  */
-      asm volatile
-        ("pushl %%ebx\n\t"	        /* Save GOT register.  */
-         "movl $1, %%eax\n\t"           /* Get CPU info and feature flags.  */
-         "cpuid\n"
-         "popl %%ebx\n\t"	        /* Restore GOT register. */
-         "testl $0x02000000, %%ecx\n\t" /* Test bit 25.  */
-         "jz .Lno_aes%=\n\t"            /* No AES support.  */
-         "orl $256, %0\n"               /* Set our HWF_INTEL_AES bit.  */
-
-         ".Lno_aes%=:\n"
-         : "+r" (hw_features)
-         :
-         : "%eax", "%ecx", "%edx", "cc"
-         );
     }
   else if (!strcmp (vendor_id, "AuthenticAMD"))
     {
       /* This is an AMD CPU.  */
 
     }
+
+  /* Detect Intel features, that might be supported also by other vendors
+   * also. */
+  asm volatile
+    ("pushl %%ebx\n\t"	        /* Save GOT register.  */
+     "movl $1, %%eax\n\t"           /* Get CPU info and feature flags.  */
+     "cpuid\n"
+     "popl %%ebx\n\t"	        /* Restore GOT register. */
+     "testl $0x02000000, %%ecx\n\t" /* Test bit 25.  */
+     "jz .Lno_aes%=\n\t"            /* No AES support.  */
+     "orl $256, %0\n"               /* Set our HWF_INTEL_AES bit.  */
+
+     ".Lno_aes%=:\n"
+     : "+r" (hw_features)
+     :
+     : "%eax", "%ecx", "%edx", "cc"
+     );
 }
 #endif /* __i386__ && SIZEOF_UNSIGNED_LONG == 4 && __GNUC__ */
 

commit 19b9efd1f47a5de9c450ce8212dfa3174a029c7a
Author: Jussi Kivilinna <jussi.kivilinna at mbnet.fi>
Date:   Fri Nov 16 10:44:44 2012 +0200

    Fix hwdetect assembler clobbers
    
    * src/hwfeatures.c (detect_x86_64_gnuc): Add missing %ebx assembler
    clobbers.
    (detect_x86_64_gnuc, detect_ia32_gnuc) [ENABLE_PADLOCK_SUPPORT]: Add
    missing %ecx assembler clobbers.
    --
    
    detect_x86_64_gnuc() and detect_ia32_gnuc() have missing clobbers in
    assembler statements. "%ebx" is missing in x86-64, probably because
    copy-paste error (i386 code saves and restores %ebx to/from stack).
    "%ecx" is missing from PadLock detection.
    
    [v2]
     - add GNU style changelog
    
    Signed-off-by: Jussi Kivilinna <jussi.kivilinna at mbnet.fi>

diff --git a/src/hwfeatures.c b/src/hwfeatures.c
index cf80fe0..456c07a 100644
--- a/src/hwfeatures.c
+++ b/src/hwfeatures.c
@@ -56,7 +56,7 @@ detect_x86_64_gnuc (void)
      "movl  %%ecx, 8(%0)\n\t"
      :
      : "S" (&vendor_id[0])
-     : "%eax", "%ecx", "%edx", "cc"
+     : "%eax", "%ebx", "%ecx", "%edx", "cc"
      );
   vendor_id[12] = 0;
 
@@ -105,7 +105,7 @@ detect_x86_64_gnuc (void)
          ".Lready%=:\n"
          : "+r" (hw_features)
          :
-         : "%eax", "%edx", "cc"
+         : "%eax", "%ebx", "%ecx", "%edx", "cc"
          );
     }
 #endif /*ENABLE_PADLOCK_SUPPORT*/
@@ -122,7 +122,7 @@ detect_x86_64_gnuc (void)
          ".Lno_aes%=:\n"
          : "+r" (hw_features)
          :
-         : "%eax", "%ecx", "%edx", "cc"
+         : "%eax", "%ebx", "%ecx", "%edx", "cc"
          );
     }
   else if (!strcmp (vendor_id, "AuthenticAMD"))
@@ -230,7 +230,7 @@ detect_ia32_gnuc (void)
          ".Lready%=:\n"
          : "+r" (hw_features)
          :
-         : "%eax", "%edx", "cc"
+         : "%eax", "%ecx", "%edx", "cc"
          );
     }
 #endif /*ENABLE_PADLOCK_SUPPORT*/

commit 6368ed542150956ff4ba8170a15bbc534143675c
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Nov 21 11:47:35 2012 +0100

    Use configure test for aligned attribute.
    
    * configure.ac (HAVE_GCC_ATTRIBUTE_ALIGNED): New test and ac_define.
    * cipher/cipher-internal.h, cipher/rijndael.c, random/rndhw.c: Use new
    macro instead of a fixed test for __GNUC__.
    --
    
    We assume that compilers that grok "__attribute__ ((aligned (16)))"
    implement that in the same way as gcc does.  In case it turns out
    that this is not the case we will need to do two more things: Detect
    such different behaviour and come up with a construct to allows the
    use of that other style of alignment forcing.

diff --git a/cipher/cipher-internal.h b/cipher/cipher-internal.h
index 437e9c0..025bf2e 100644
--- a/cipher/cipher-internal.h
+++ b/cipher/cipher-internal.h
@@ -31,7 +31,7 @@
    We use the aligned attribute, thus it is only possible to implement
    this with gcc.  */
 #undef NEED_16BYTE_ALIGNED_CONTEXT
-#if defined (__GNUC__)
+#ifdef HAVE_GCC_ATTRIBUTE_ALIGNED
 # define NEED_16BYTE_ALIGNED_CONTEXT 1
 #endif
 
diff --git a/cipher/rijndael.c b/cipher/rijndael.c
index a2aedf0..b9ee8ad 100644
--- a/cipher/rijndael.c
+++ b/cipher/rijndael.c
@@ -52,7 +52,7 @@
 
 
 /* Helper macro to force alignment to 16 bytes.  */
-#ifdef __GNUC__
+#ifdef HAVE_GCC_ATTRIBUTE_ALIGNED
 # define ATTR_ALIGNED_16  __attribute__ ((aligned (16)))
 #else
 # define ATTR_ALIGNED_16
@@ -63,7 +63,7 @@
    code.  */
 #undef USE_PADLOCK
 #ifdef ENABLE_PADLOCK_SUPPORT
-# ifdef __GNUC__
+# ifdef HAVE_GCC_ATTRIBUTE_ALIGNED
 #  if (defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4) || defined(__x86_64__)
 #   define USE_PADLOCK 1
 #  endif
diff --git a/configure.ac b/configure.ac
index 0e99ca5..a2235a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -789,6 +789,21 @@ if test "$gcry_cv_visibility_attribute" = "yes" \
 fi
 
 
+#
+# Check whether the compiler supports the GCC style aligned attribute
+#
+AC_CACHE_CHECK([whether the GCC style aligned attribute is supported],
+       [gcry_cv_gcc_attribute_aligned],
+       [gcry_cv_gcc_attribute_aligned=no
+        AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+          [[struct { int a; } foo __attribute__ ((aligned (16)));]])],
+          [gcry_cv_gcc_attribute_aligned=yes])])
+if test "$gcry_cv_gcc_attribute_aligned" = "yes" ; then
+   AC_DEFINE(HAVE_GCC_ATTRIBUTE_ALIGNED,1,
+     [Defined if a GCC style "__attribute__ ((aligned (n))" is supported])
+fi
+
+
 #######################################
 #### Checks for library functions. ####
 #######################################
@@ -1286,6 +1301,15 @@ cat <<G10EOF
 G10EOF
 fi
 
+if test "$gcry_cv_gcc_attribute_aligned" != "yes" ; then
+cat <<G10EOF
+
+   Please not that your compiler does not support the GCC style
+   aligned attribute. Using this software may evoke bus errors.
+
+G10EOF
+fi
+
 if test -n "$gpl"; then
   echo "Please note that you are building a version of Libgcrypt with"
   echo "  $gpl"
diff --git a/random/rndhw.c b/random/rndhw.c
index 0a5c9fa..775d90f 100644
--- a/random/rndhw.c
+++ b/random/rndhw.c
@@ -27,7 +27,7 @@
 
 #undef USE_PADLOCK
 #ifdef ENABLE_PADLOCK_SUPPORT
-# ifdef __GNUC__
+# ifdef HAVE_GCC_ATTRIBUTE_ALIGNED
 #  if (defined (__i386__) && SIZEOF_UNSIGNED_LONG == 4) || defined(__x86_64__)
 #   define USE_PADLOCK 1
 #  endif

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

Summary of changes:
 AUTHORS                  |    1 +
 cipher/camellia-glue.c   |    4 +-
 cipher/cipher-internal.h |    2 +-
 cipher/rijndael.c        |  239 ++++++++++++++++++++++------------------------
 configure.ac             |   24 +++++
 random/rndhw.c           |    2 +-
 src/hwfeatures.c         |   74 ++++++++-------
 7 files changed, 186 insertions(+), 160 deletions(-)


hooks/post-receive
-- 
The GNU crypto library
http://git.gnupg.org




More information about the Gnupg-commits mailing list