Quantcast

[git] GCRYPT - branch, master, updated. libgcrypt-1.7.3-66-ge7b941c

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[git] GCRYPT - branch, master, updated. libgcrypt-1.7.3-66-ge7b941c

by NIIBE Yutaka
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  e7b941c3de9c9b6319298c02f844cc0cadbf8562 (commit)
       via  92b4a29d2453712192ced2d7226abc49679dcb1e (commit)
       via  4f31d816dcc1e95dc647651e92acbdfed53f5c14 (commit)
       via  55cf1b5588705cab5f45e2817c4aa1d204dc0042 (commit)
       via  b29b1b9f576f501d4b993be0a751567045274a1a (commit)
       via  136c8416ea540dd126be3997d94d7063b3aaf577 (commit)
       via  d1ae52a0e23308f33b78cffeba56005b687f23c0 (commit)
      from  a351fbde8548ce3f57298c618426f043844fbc78 (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 e7b941c3de9c9b6319298c02f844cc0cadbf8562
Author: Jussi Kivilinna <[hidden email]>
Date:   Sat Jan 28 11:26:02 2017 +0200

    bufhelp: use unaligned dword and qword types for endianess helpers
   
    * cipher/bufhelp.h (BUFHELP_UNALIGNED_ACCESS): New, defined
    if attributes 'packed', 'aligned' and 'may_alias' are supported.
    (BUFHELP_FAST_UNALIGNED_ACCESS): Define if have
    BUFHELP_UNALIGNED_ACCESS.
    --
   
    Now that compiler is properly told that reads from these types
    may do not follow strict-aliasing and may be unaligned, we
    enable use of these for all architectures and compiler will
    emit more optimized, yet correct, code (for example, use
    special unaligned read/write instructions instead of accessing
    byte-by-byte).
   
    Signed-off-by: Jussi Kivilinna <[hidden email]>

diff --git a/cipher/bufhelp.h b/cipher/bufhelp.h
index 1c52db5..3110a1d 100644
--- a/cipher/bufhelp.h
+++ b/cipher/bufhelp.h
@@ -23,10 +23,19 @@
 #include "bithelp.h"
 
 
-#undef BUFHELP_FAST_UNALIGNED_ACCESS
+#undef BUFHELP_UNALIGNED_ACCESS
 #if defined(HAVE_GCC_ATTRIBUTE_PACKED) && \
     defined(HAVE_GCC_ATTRIBUTE_ALIGNED) && \
-    defined(HAVE_GCC_ATTRIBUTE_MAY_ALIAS) && \
+    defined(HAVE_GCC_ATTRIBUTE_MAY_ALIAS)
+/* Compiler is supports attributes needed for automatically issuing unaligned
+   memory access instructions.
+ */
+# define BUFHELP_UNALIGNED_ACCESS 1
+#endif
+
+
+#undef BUFHELP_FAST_UNALIGNED_ACCESS
+#if defined(BUFHELP_UNALIGNED_ACCESS) && \
     (defined(__i386__) || defined(__x86_64__) || \
      (defined(__arm__) && defined(__ARM_FEATURE_UNALIGNED)) || \
      defined(__aarch64__))
@@ -290,7 +299,7 @@ buf_eq_const(const void *_a, const void *_b, size_t len)
 }
 
 
-#ifndef BUFHELP_FAST_UNALIGNED_ACCESS
+#ifndef BUFHELP_UNALIGNED_ACCESS
 
 /* Functions for loading and storing unaligned u32 values of different
    endianness.  */
@@ -373,7 +382,7 @@ static inline void buf_put_le64(void *_buf, u64 val)
   out[0] = val;
 }
 
-#else /*BUFHELP_FAST_UNALIGNED_ACCESS*/
+#else /*BUFHELP_UNALIGNED_ACCESS*/
 
 typedef struct bufhelp_u32_s
 {
@@ -435,6 +444,6 @@ static inline void buf_put_le64(void *_buf, u64 val)
 }
 
 
-#endif /*BUFHELP_FAST_UNALIGNED_ACCESS*/
+#endif /*BUFHELP_UNALIGNED_ACCESS*/
 
 #endif /*GCRYPT_BUFHELP_H*/

commit 92b4a29d2453712192ced2d7226abc49679dcb1e
Author: Jussi Kivilinna <[hidden email]>
Date:   Sat Jan 28 11:26:02 2017 +0200

    rijndael-aesni: fix u128_t strict-aliasing rule breaking
   
    * cipher/rijndael-aesni.c (u128_t): Add attributes to tell GCC and clang
    that casting from 'char *' to 'u128_t *' is ok.
    --
   
    Signed-off-by: Jussi Kivilinna <[hidden email]>

diff --git a/cipher/rijndael-aesni.c b/cipher/rijndael-aesni.c
index 7852e19..735e5cd 100644
--- a/cipher/rijndael-aesni.c
+++ b/cipher/rijndael-aesni.c
@@ -41,7 +41,10 @@
 #endif
 
 
-typedef struct u128_s { u32 a, b, c, d; } u128_t;
+typedef struct u128_s
+{
+  u32 a, b, c, d;
+} __attribute__((packed, aligned(1), may_alias)) u128_t;
 
 
 /* Two macros to be called prior and after the use of AESNI

commit 4f31d816dcc1e95dc647651e92acbdfed53f5c14
Author: Jussi Kivilinna <[hidden email]>
Date:   Sat Jan 28 11:26:02 2017 +0200

    cipher-xts: fix pointer casting to wrong alignment and aliasing
   
    * cipher/cipher-xts.c (xts_gfmul_byA, xts_inc128): Use buf_get_le64
    and buf_put_le64 for accessing data; Change parameter pointers to
    'unsigned char *' type.
    (_gcry_cipher_xts_crypt): Do not cast buffer pointers to 'u64 *'
    for helper functions.
    --
   
    Signed-off-by: Jussi Kivilinna <[hidden email]>

diff --git a/cipher/cipher-xts.c b/cipher/cipher-xts.c
index 7a7181b..4da89e5 100644
--- a/cipher/cipher-xts.c
+++ b/cipher/cipher-xts.c
@@ -29,29 +29,29 @@
 #include "./cipher-internal.h"
 
 
-static inline void xts_gfmul_byA (u64 *out, const u64 *in)
+static inline void xts_gfmul_byA (unsigned char *out, const unsigned char *in)
 {
-  u64 hi = le_bswap64 (in[1]);
-  u64 lo = le_bswap64 (in[0]);
+  u64 hi = buf_get_le64 (in + 8);
+  u64 lo = buf_get_le64 (in + 0);
   u64 carry = -(hi >> 63) & 0x87;
 
   hi = (hi << 1) + (lo >> 63);
   lo = (lo << 1) ^ carry;
 
-  out[1] = le_bswap64 (hi);
-  out[0] = le_bswap64 (lo);
+  buf_put_le64 (out + 8, hi);
+  buf_put_le64 (out + 0, lo);
 }
 
 
-static inline void xts_inc128 (u64 *seqno)
+static inline void xts_inc128 (unsigned char *seqno)
 {
-  u64 lo = le_bswap64 (seqno[0]);
-  u64 hi = le_bswap64 (seqno[1]);
+  u64 lo = buf_get_le64 (seqno + 0);
+  u64 hi = buf_get_le64 (seqno + 8);
 
   hi += !(++lo);
 
-  seqno[0] = le_bswap64 (lo);
-  seqno[1] = le_bswap64 (hi);
+  buf_put_le64 (seqno + 0, lo);
+  buf_put_le64 (seqno + 8, hi);
 }
 
 
@@ -117,7 +117,7 @@ _gcry_cipher_xts_crypt (gcry_cipher_hd_t c,
       nblocks--;
 
       /* Generate next tweak. */
-      xts_gfmul_byA ((u64 *)c->u_ctr.ctr, (u64 *)c->u_ctr.ctr);
+      xts_gfmul_byA (c->u_ctr.ctr, c->u_ctr.ctr);
     }
 
   /* Handle remaining data with ciphertext stealing. */
@@ -129,7 +129,7 @@ _gcry_cipher_xts_crypt (gcry_cipher_hd_t c,
   gcry_assert (inbuflen < GCRY_XTS_BLOCK_LEN * 2);
 
   /* Generate last tweak. */
-  xts_gfmul_byA (tmp.x64, (u64 *)c->u_ctr.ctr);
+  xts_gfmul_byA (tmp.x1, c->u_ctr.ctr);
 
   /* Decrypt last block first. */
   buf_xor (outbuf, inbuf, tmp.x64, GCRY_XTS_BLOCK_LEN);
@@ -158,7 +158,7 @@ _gcry_cipher_xts_crypt (gcry_cipher_hd_t c,
     }
 
   /* Auto-increment data-unit sequence number */
-  xts_inc128 ((u64 *)c->u_iv.iv);
+  xts_inc128 (c->u_iv.iv);
 
   wipememory (&tmp, sizeof(tmp));
   wipememory (c->u_ctr.ctr, sizeof(c->u_ctr.ctr));

commit 55cf1b5588705cab5f45e2817c4aa1d204dc0042
Author: Jussi Kivilinna <[hidden email]>
Date:   Sat Jan 28 11:26:02 2017 +0200

    crc-intel-pclmul: fix undefined behavior with unaligned access
   
    * cipher/crc-intel-pclmul.c (u16_unaligned_s): New.
    (crc32_reflected_less_than_16, crc32_less_than_16): Use
    'u16_unaligned_s' for unaligned memory access.
    --
   
    GnuPG-bug-id: 2292
    Signed-off-by: Jussi Kivilinna <[hidden email]>

diff --git a/cipher/crc-intel-pclmul.c b/cipher/crc-intel-pclmul.c
index 7a344e2..8ff08ec 100644
--- a/cipher/crc-intel-pclmul.c
+++ b/cipher/crc-intel-pclmul.c
@@ -44,6 +44,12 @@
 #define ALIGNED_16 __attribute__ ((aligned (16)))
 
 
+struct u16_unaligned_s
+{
+  u16 a;
+} __attribute__((packed, aligned (1), may_alias));
+
+
 /* Constants structure for generic reflected/non-reflected CRC32 CLMUL
  * functions. */
 struct crc32_consts_s
@@ -345,14 +351,14 @@ crc32_reflected_less_than_16 (u32 *pcrc, const byte *inbuf, size_t inlen,
  }
       else if (inlen == 2)
  {
-  data = *((const u16 *)inbuf);
+  data = ((const struct u16_unaligned_s *)inbuf)->a;
   data ^= crc;
   data <<= 16;
   crc >>= 16;
  }
       else
  {
-  data = *((const u16 *)inbuf);
+  data = ((const struct u16_unaligned_s *)inbuf)->a;
   data |= inbuf[2] << 16;
   data ^= crc;
   data <<= 8;
@@ -709,14 +715,14 @@ crc32_less_than_16 (u32 *pcrc, const byte *inbuf, size_t inlen,
  }
       else if (inlen == 2)
  {
-  data = *((const u16 *)inbuf);
+  data = ((const struct u16_unaligned_s *)inbuf)->a;
   data ^= crc;
   data = _gcry_bswap32(data << 16);
   crc = _gcry_bswap32(crc >> 16);
  }
       else
  {
-  data = *((const u16 *)inbuf);
+  data = ((const struct u16_unaligned_s *)inbuf)->a;
   data |= inbuf[2] << 16;
   data ^= crc;
   data = _gcry_bswap32(data << 8);

commit b29b1b9f576f501d4b993be0a751567045274a1a
Author: Jussi Kivilinna <[hidden email]>
Date:   Sat Jan 28 11:26:02 2017 +0200

    configure.ac: fix attribute checks
   
    * configure.ac: Add -Werror flag for attribute checks.
    --
   
    Compilter ignores unknown attributes and just shows warning. Therefore
    attribute checks need to be run with -Werror.
   
    Signed-off-by: Jussi Kivilinna <[hidden email]>

diff --git a/configure.ac b/configure.ac
index d2b863c..bc5bed4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -958,6 +958,12 @@ if test "$gcry_cv_visibility_attribute" = "yes" \
 fi
 
 
+# Following attribute tests depend on warnings to cause compile to fail,
+# so set -Werror temporarily.
+_gcc_cflags_save=$CFLAGS
+CFLAGS="$CFLAGS -Werror"
+
+
 #
 # Check whether the compiler supports the GCC style aligned attribute
 #
@@ -1009,6 +1015,10 @@ if test "$gcry_cv_gcc_attribute_may_alias" = "yes" ; then
 fi
 
 
+# Restore flags.
+CFLAGS=$_gcc_cflags_save;
+
+
 #
 # Check whether the compiler supports 'asm' or '__asm__' keyword for
 # assembler blocks.

commit 136c8416ea540dd126be3997d94d7063b3aaf577
Author: Jussi Kivilinna <[hidden email]>
Date:   Sat Jan 28 11:26:02 2017 +0200

    configure.ac: fix may_alias attribute check
   
    * configure.ac: Test may_alias attribute on type, not on variable.
    --
   
    Signed-off-by: Jussi Kivilinna <[hidden email]>

diff --git a/configure.ac b/configure.ac
index 5dd27ca..d2b863c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1000,7 +1000,8 @@ AC_CACHE_CHECK([whether the GCC style may_alias attribute is supported],
        [gcry_cv_gcc_attribute_may_alias],
        [gcry_cv_gcc_attribute_may_alias=no
         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
-          [[struct { int a; } foo __attribute__ ((may_alias));]])],
+          [[typedef struct foo_s { int a; }
+            __attribute__ ((may_alias)) foo_t;]])],
           [gcry_cv_gcc_attribute_may_alias=yes])])
 if test "$gcry_cv_gcc_attribute_may_alias" = "yes" ; then
    AC_DEFINE(HAVE_GCC_ATTRIBUTE_MAY_ALIAS,1,

commit d1ae52a0e23308f33b78cffeba56005b687f23c0
Author: Jussi Kivilinna <[hidden email]>
Date:   Sat Jan 28 11:26:02 2017 +0200

    bufhelp: add 'may_alias' attribute for properly aligned 'bufhelp_int_t'
   
    * cipher/bufhelp.h [!BUFHELP_FAST_UNALIGNED_ACCESS]
    (bufhelp_int_t): Add 'may_alias' attribute.
    --
   
    Signed-off-by: Jussi Kivilinna <[hidden email]>

diff --git a/cipher/bufhelp.h b/cipher/bufhelp.h
index 3616515..1c52db5 100644
--- a/cipher/bufhelp.h
+++ b/cipher/bufhelp.h
@@ -49,11 +49,18 @@ typedef struct bufhelp_int_s
 /* Define type with default alignment for other architectures (unaligned
    accessed handled in per byte loops).
  */
+#ifdef HAVE_GCC_ATTRIBUTE_MAY_ALIAS
+typedef struct bufhelp_int_s
+{
+  uintptr_t a;
+} __attribute__((may_alias)) bufhelp_int_t;
+#else
 typedef struct bufhelp_int_s
 {
   uintptr_t a;
 } bufhelp_int_t;
 #endif
+#endif
 
 
 /* Optimized function for small buffer copying */

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

Summary of changes:
 cipher/bufhelp.h          | 26 +++++++++++++++++++++-----
 cipher/cipher-xts.c       | 26 +++++++++++++-------------
 cipher/crc-intel-pclmul.c | 14 ++++++++++----
 cipher/rijndael-aesni.c   |  5 ++++-
 configure.ac              | 13 ++++++++++++-
 5 files changed, 60 insertions(+), 24 deletions(-)


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


_______________________________________________
Gnupg-commits mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-commits


_______________________________________________
Gcrypt-devel mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Loading...