From 897ccd21b7221982806b5c024518f4e989152f14 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 18 Mar 2016 18:57:19 +0100 Subject: Always require a 64 bit integer type * configure.ac (available_digests_64): Merge with available_digests. (available_kdfs_64): Merge with available_kdfs. <64 bit datatype test>: Bail out if no such type is available. * src/types.h: Emit #error if no u64 can be defined. (PROPERLY_ALIGNED_TYPE): Always add u64 type. * cipher/bithelp.h: Remove all code paths which handle the case of !HAVE_U64_TYPEDEF. * cipher/bufhelp.h: Ditto. * cipher/cipher-ccm.c: Ditto. * cipher/cipher-gcm.c: Ditto. * cipher/cipher-internal.h: Ditto. * cipher/cipher.c: Ditto. * cipher/hash-common.h: Ditto. * cipher/md.c: Ditto. * cipher/poly1305.c: Ditto. * cipher/scrypt.c: Ditto. * cipher/tiger.c: Ditto. * src/g10lib.h: Ditto. * tests/basic.c: Ditto. * tests/bench-slope.c: Ditto. * tests/benchmark.c: Ditto. -- Given that SHA-2 and some other algorithms require a 64 bit type it does not make anymore sense to conditionally compile some part when the platform does not provide such a type. GnuPG-bug-id: 1815. Signed-off-by: Werner Koch --- cipher/bithelp.h | 22 ++--- cipher/bufhelp.h | 6 +- cipher/cipher-ccm.c | 78 ----------------- cipher/cipher-gcm.c | 4 +- cipher/cipher-internal.h | 7 +- cipher/cipher.c | 10 --- cipher/hash-common.h | 2 +- cipher/md.c | 2 - cipher/poly1305.c | 214 ----------------------------------------------- cipher/scrypt.c | 5 -- cipher/tiger.c | 5 -- configure.ac | 18 ++-- src/g10lib.h | 9 +- src/types.h | 4 +- tests/basic.c | 2 - tests/bench-slope.c | 4 - tests/benchmark.c | 4 - 17 files changed, 26 insertions(+), 370 deletions(-) diff --git a/cipher/bithelp.h b/cipher/bithelp.h index 258ab2f4..45753805 100644 --- a/cipher/bithelp.h +++ b/cipher/bithelp.h @@ -47,33 +47,27 @@ _gcry_bswap32(u32 x) } #endif -#ifdef HAVE_U64_TYPEDEF -# ifdef HAVE_BUILTIN_BSWAP64 -# define _gcry_bswap64 __builtin_bswap64 -# else +#ifdef HAVE_BUILTIN_BSWAP64 +# define _gcry_bswap64 __builtin_bswap64 +#else static inline u64 _gcry_bswap64(u64 x) { return ((u64)_gcry_bswap32(x) << 32) | (_gcry_bswap32(x >> 32)); } -# endif #endif /* Endian dependent byte swap operations. */ #ifdef WORDS_BIGENDIAN # define le_bswap32(x) _gcry_bswap32(x) # define be_bswap32(x) ((u32)(x)) -# ifdef HAVE_U64_TYPEDEF -# define le_bswap64(x) _gcry_bswap64(x) -# define be_bswap64(x) ((u64)(x)) -# endif +# define le_bswap64(x) _gcry_bswap64(x) +# define be_bswap64(x) ((u64)(x)) #else # define le_bswap32(x) ((u32)(x)) # define be_bswap32(x) _gcry_bswap32(x) -# ifdef HAVE_U64_TYPEDEF -# define le_bswap64(x) ((u64)(x)) -# define be_bswap64(x) _gcry_bswap64(x) -# endif +# define le_bswap64(x) ((u64)(x)) +# define be_bswap64(x) _gcry_bswap64(x) #endif @@ -104,7 +98,6 @@ _gcry_ctz (unsigned int x) /* Count trailing zero bits in an u64. We return an int because that is what gcc's builtin does. Returns the number of bits in X if X is 0. */ -#ifdef HAVE_U64_TYPEDEF static inline int _gcry_ctz64(u64 x) { @@ -118,7 +111,6 @@ _gcry_ctz64(u64 x) return 32 + _gcry_ctz (x >> 32); #endif } -#endif /*HAVE_U64_TYPEDEF*/ #endif /*GCRYPT_BITHELP_H*/ diff --git a/cipher/bufhelp.h b/cipher/bufhelp.h index aec4f1cb..df355947 100644 --- a/cipher/bufhelp.h +++ b/cipher/bufhelp.h @@ -318,7 +318,7 @@ static inline void buf_put_le32(void *_buf, u32 val) out[0] = val; } -#ifdef HAVE_U64_TYPEDEF + /* Functions for loading and storing unaligned u64 values of different endianness. */ static inline u64 buf_get_be64(const void *_buf) @@ -364,7 +364,6 @@ static inline void buf_put_le64(void *_buf, u64 val) out[1] = val >> 8; out[0] = val; } -#endif /*HAVE_U64_TYPEDEF*/ #else /*BUFHELP_FAST_UNALIGNED_ACCESS*/ @@ -397,7 +396,6 @@ static inline void buf_put_le32(void *_buf, u32 val) out->a = le_bswap32(val); } -#ifdef HAVE_U64_TYPEDEF typedef struct bufhelp_u64_s { @@ -427,7 +425,7 @@ static inline void buf_put_le64(void *_buf, u64 val) bufhelp_u64_t *out = _buf; out->a = le_bswap64(val); } -#endif /*HAVE_U64_TYPEDEF*/ + #endif /*BUFHELP_FAST_UNALIGNED_ACCESS*/ diff --git a/cipher/cipher-ccm.c b/cipher/cipher-ccm.c index 3d5f2209..4d8f8167 100644 --- a/cipher/cipher-ccm.c +++ b/cipher/cipher-ccm.c @@ -28,9 +28,6 @@ #include "bufhelp.h" #include "./cipher-internal.h" -/* We need a 64 bit type for this code. */ -#ifdef HAVE_U64_TYPEDEF - #define set_burn(burn, nburn) do { \ unsigned int __nburn = (nburn); \ @@ -364,78 +361,3 @@ _gcry_cipher_ccm_decrypt (gcry_cipher_hd_t c, unsigned char *outbuf, return err; } - -#else - -/* - * Provide dummy functions so that we avoid adding too much #ifdefs in - * cipher.c. - */ - -gcry_err_code_t -_gcry_cipher_ccm_encrypt(gcry_cipher_hd_t c, unsigned char *outbuf, - size_t outbuflen, const unsigned char *inbuf, - size_t inbuflen) -{ - (void)c; - (void)outbuf; - (void)outbuflen; - (void)inbuf; - (void)inbuflen; - return GPG_ERR_NOT_SUPPORTED; -} - -gcry_err_code_t -_gcry_cipher_ccm_decrypt(gcry_cipher_hd_t c, unsigned char *outbuf, - size_t outbuflen, const unsigned char *inbuf, - size_t inbuflen) -{ - (void)c; - (void)outbuf; - (void)outbuflen; - (void)inbuf; - (void)inbuflen; - return GPG_ERR_NOT_SUPPORTED; -} - -gcry_err_code_t -_gcry_cipher_ccm_set_nonce(gcry_cipher_hd_t c, const unsigned char *nonce, - size_t noncelen) -{ - (void)c; - (void)nonce; - (void)noncelen; - return GPG_ERR_NOT_SUPPORTED; -} - -gcry_err_code_t -_gcry_cipher_ccm_authenticate(gcry_cipher_hd_t c, const unsigned char *abuf, - size_t abuflen) -{ - (void)c; - (void)abuf; - (void)abuflen; - return GPG_ERR_NOT_SUPPORTED; -} - -gcry_err_code_t -_gcry_cipher_ccm_get_tag(gcry_cipher_hd_t c, unsigned char *outtag, - size_t taglen) -{ - (void)c; - (void)outtag; - (void)taglen; - return GPG_ERR_NOT_SUPPORTED; -} - -gcry_err_code_t -_gcry_cipher_ccm_check_tag(gcry_cipher_hd_t c, const unsigned char *intag, - size_t taglen) -{ - (void)c; - (void)intag; - (void)taglen; - return GPG_ERR_NOT_SUPPORTED; -} - -#endif /*HAVE_U64_TYPEDEF*/ diff --git a/cipher/cipher-gcm.c b/cipher/cipher-gcm.c index 3711a1df..d390ef84 100644 --- a/cipher/cipher-gcm.c +++ b/cipher/cipher-gcm.c @@ -171,7 +171,7 @@ do_ghash (unsigned char *result, const unsigned char *buf, const u64 *gcmM) sizeof(int)*2 + sizeof(void*)*5); } -#else +#else /*!GCM_TABLES_USE_U64*/ static void bshift (u32 * M, int i) @@ -284,7 +284,7 @@ do_ghash (unsigned char *result, const unsigned char *buf, const u32 *gcmM) return (sizeof(V) + sizeof(T) + sizeof(tmp) + sizeof(int)*2 + sizeof(void*)*6); } -#endif /* !HAVE_U64_TYPEDEF || SIZEOF_UNSIGNED_LONG != 8 */ +#endif /*!GCM_TABLES_USE_U64*/ #define fillM(c) \ do_fillM (c->u_mode.gcm.u_ghash_key.key, c->u_mode.gcm.gcm_table) diff --git a/cipher/cipher-internal.h b/cipher/cipher-internal.h index 29c6f338..80e7c092 100644 --- a/cipher/cipher-internal.h +++ b/cipher/cipher-internal.h @@ -168,7 +168,6 @@ struct gcry_cipher_handle int unused; /* Number of unused bytes in LASTIV. */ union { -#ifdef HAVE_U64_TYPEDEF /* Mode specific storage for CCM mode. */ struct { u64 encryptlen; @@ -185,7 +184,6 @@ struct gcry_cipher_handle unsigned int lengths:1; /* Set to 1 if CCM length parameters has been processed. */ } ccm; -#endif /* Mode specific storage for Poly1305 mode. */ struct { @@ -248,8 +246,7 @@ struct gcry_cipher_handle /* Pre-calculated table for GCM. */ #ifdef GCM_USE_TABLES - #if defined(HAVE_U64_TYPEDEF) && (SIZEOF_UNSIGNED_LONG == 8 \ - || defined(__x86_64__)) + #if (SIZEOF_UNSIGNED_LONG == 8 || defined(__x86_64__)) #define GCM_TABLES_USE_U64 1 u64 gcm_table[2 * 16]; #else @@ -362,10 +359,8 @@ gcry_err_code_t _gcry_cipher_ccm_set_nonce size_t noncelen); gcry_err_code_t _gcry_cipher_ccm_authenticate /* */ (gcry_cipher_hd_t c, const unsigned char *abuf, size_t abuflen); -#ifdef HAVE_U64_TYPEDEF gcry_err_code_t _gcry_cipher_ccm_set_lengths /* */ (gcry_cipher_hd_t c, u64 encryptedlen, u64 aadlen, u64 taglen); -#endif gcry_err_code_t _gcry_cipher_ccm_get_tag /* */ (gcry_cipher_hd_t c, unsigned char *outtag, size_t taglen); diff --git a/cipher/cipher.c b/cipher/cipher.c index a0138466..3a8597f5 100644 --- a/cipher/cipher.c +++ b/cipher/cipher.c @@ -397,15 +397,11 @@ _gcry_cipher_open_internal (gcry_cipher_hd_t *handle, switch (mode) { case GCRY_CIPHER_MODE_CCM: -#ifdef HAVE_U64_TYPEDEF if (spec->blocksize != GCRY_CCM_BLOCK_LEN) err = GPG_ERR_INV_CIPHER_MODE; if (!spec->encrypt || !spec->decrypt) err = GPG_ERR_INV_CIPHER_MODE; break; -#else - err = GPG_ERR_NOT_SUPPORTED; -#endif case GCRY_CIPHER_MODE_ECB: case GCRY_CIPHER_MODE_CBC: @@ -743,11 +739,9 @@ cipher_reset (gcry_cipher_hd_t c) memset (&c->u_mode.poly1305, 0, sizeof c->u_mode.poly1305); break; -#ifdef HAVE_U64_TYPEDEF case GCRY_CIPHER_MODE_CCM: memset (&c->u_mode.ccm, 0, sizeof c->u_mode.ccm); break; -#endif case GCRY_CIPHER_MODE_OCB: memset (&c->u_mode.ocb, 0, sizeof c->u_mode.ocb); @@ -1264,7 +1258,6 @@ _gcry_cipher_ctl (gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen) break; case GCRYCTL_SET_CCM_LENGTHS: -#ifdef HAVE_U64_TYPEDEF { u64 params[3]; size_t encryptedlen; @@ -1286,9 +1279,6 @@ _gcry_cipher_ctl (gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen) rc = _gcry_cipher_ccm_set_lengths (h, encryptedlen, aadlen, authtaglen); } -#else - rc = GPG_ERR_NOT_SUPPORTED; -#endif break; case GCRYCTL_SET_TAGLEN: diff --git a/cipher/hash-common.h b/cipher/hash-common.h index 27d670d8..23f81ed7 100644 --- a/cipher/hash-common.h +++ b/cipher/hash-common.h @@ -33,7 +33,7 @@ typedef unsigned int (*_gcry_md_block_write_t) (void *c, const unsigned char *blks, size_t nblks); -#if defined(HAVE_U64_TYPEDEF) && (defined(USE_SHA512) || defined(USE_WHIRLPOOL)) +#if (defined(USE_SHA512) || defined(USE_WHIRLPOOL)) /* SHA-512 and Whirlpool needs u64. SHA-512 needs larger buffer. */ # define MD_BLOCK_MAX_BLOCKSIZE 128 # define MD_NBLOCKS_TYPE u64 diff --git a/cipher/md.c b/cipher/md.c index 281db120..5b4f0c13 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -1228,7 +1228,6 @@ md_stop_debug( gcry_md_hd_t md ) md->ctx->debug = NULL; } -#ifdef HAVE_U64_TYPEDEF { /* a kludge to pull in the __muldi3 for Solaris */ volatile u32 a = (u32)(uintptr_t)md; volatile u64 b = 42; @@ -1236,7 +1235,6 @@ md_stop_debug( gcry_md_hd_t md ) c = a * b; (void)c; } -#endif } diff --git a/cipher/poly1305.c b/cipher/poly1305.c index 1adf0e7b..7ae35923 100644 --- a/cipher/poly1305.c +++ b/cipher/poly1305.c @@ -98,8 +98,6 @@ static const poly1305_ops_t poly1305_armv7_neon_ops = { #endif -#ifdef HAVE_U64_TYPEDEF - /* Reference unoptimized poly1305 implementation using 32 bit * 32 bit = 64 bit * multiplication and 64 bit addition. */ @@ -358,218 +356,6 @@ static const poly1305_ops_t poly1305_default_ops = { poly1305_finish_ext_ref32 }; -#else /* !HAVE_U64_TYPEDEF */ - -/* Reference unoptimized poly1305 implementation using 8 bit * 8 bit = 16 bit - * multiplication and 16 bit addition, used when we don't have 'u64'. - */ - -typedef struct poly1305_state_ref8_t -{ - byte h[17]; - byte r[17]; - byte pad[17]; - byte final; -} poly1305_state_ref8_t; - - -static OPS_FUNC_ABI void -poly1305_init_ext_ref8 (void *state, const poly1305_key_t * key) -{ - poly1305_state_ref8_t *st = (poly1305_state_ref8_t *) state; - size_t i; - - /* h = 0 */ - for (i = 0; i < 17; i++) - st->h[i] = 0; - - /* r &= 0xffffffc0ffffffc0ffffffc0fffffff */ - st->r[0] = key->b[0]; - st->r[1] = key->b[1]; - st->r[2] = key->b[2]; - st->r[3] = key->b[3] & 0x0f; - st->r[4] = key->b[4] & 0xfc; - st->r[5] = key->b[5]; - st->r[6] = key->b[6]; - st->r[7] = key->b[7] & 0x0f; - st->r[8] = key->b[8] & 0xfc; - st->r[9] = key->b[9]; - st->r[10] = key->b[10]; - st->r[11] = key->b[11] & 0x0f; - st->r[12] = key->b[12] & 0xfc; - st->r[13] = key->b[13]; - st->r[14] = key->b[14]; - st->r[15] = key->b[15] & 0x0f; - st->r[16] = 0; - - /* save pad for later */ - for (i = 0; i < 16; i++) - st->pad[i] = key->b[i + 16]; - st->pad[16] = 0; - - st->final = 0; -} - - -static void -poly1305_add_ref8 (byte h[17], const byte c[17]) -{ - u16 u; - unsigned int i; - for (u = 0, i = 0; i < 17; i++) - { - u += (u16) h[i] + (u16) c[i]; - h[i] = (byte) u & 0xff; - u >>= 8; - } -} - - -static void -poly1305_squeeze_ref8 (byte h[17], u32 hr[17]) -{ - u32 u; - unsigned int i; - u = 0; - for (i = 0; i < 16; i++) - { - u += hr[i]; - h[i] = (byte) u & 0xff; - u >>= 8; - } - u += hr[16]; - h[16] = (byte) u & 0x03; - u >>= 2; - u += (u << 2); /* u *= 5; */ - for (i = 0; i < 16; i++) - { - u += h[i]; - h[i] = (byte) u & 0xff; - u >>= 8; - } - h[16] += (byte) u; -} - - -static void -poly1305_freeze_ref8 (byte h[17]) -{ - static const byte minusp[17] = { - 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xfc - }; - byte horig[17], negative; - unsigned int i; - - /* compute h + -p */ - for (i = 0; i < 17; i++) - horig[i] = h[i]; - poly1305_add_ref8 (h, minusp); - - /* select h if h < p, or h + -p if h >= p */ - negative = -(h[16] >> 7); - for (i = 0; i < 17; i++) - h[i] ^= negative & (horig[i] ^ h[i]); -} - - -static OPS_FUNC_ABI unsigned int -poly1305_blocks_ref8 (void *state, const byte * m, size_t bytes) -{ - poly1305_state_ref8_t *st = (poly1305_state_ref8_t *) state; - const byte hibit = st->final ^ 1; /* 1 << 128 */ - - while (bytes >= POLY1305_REF_BLOCKSIZE) - { - u32 hr[17], u; - byte c[17]; - unsigned int i, j; - - /* h += m */ - for (i = 0; i < 16; i++) - c[i] = m[i]; - c[16] = hibit; - poly1305_add_ref8 (st->h, c); - - /* h *= r */ - for (i = 0; i < 17; i++) - { - u = 0; - for (j = 0; j <= i; j++) - { - u += (u16) st->h[j] * st->r[i - j]; - } - for (j = i + 1; j < 17; j++) - { - u32 v = (u16) st->h[j] * st->r[i + 17 - j]; - v = ((v << 8) + (v << 6)); /* v *= (5 << 6); */ - u += v; - } - hr[i] = u; - } - - /* (partial) h %= p */ - poly1305_squeeze_ref8 (st->h, hr); - - m += POLY1305_REF_BLOCKSIZE; - bytes -= POLY1305_REF_BLOCKSIZE; - } - - /* burn_stack */ - return (18 + 2) * sizeof (u32) + 18 + 6 * sizeof (void *) + - 6 * sizeof (void *); -} - - -static OPS_FUNC_ABI unsigned int -poly1305_finish_ext_ref8 (void *state, const byte * m, size_t remaining, - byte mac[POLY1305_TAGLEN]) -{ - poly1305_state_ref8_t *st = (poly1305_state_ref8_t *) state; - size_t i; - unsigned int burn = 0; - - /* process the remaining block */ - if (remaining) - { - byte final[POLY1305_REF_BLOCKSIZE] = { 0 }; - for (i = 0; i < remaining; i++) - final[i] = m[i]; - final[remaining] = 1; - st->final = 1; - burn = poly1305_blocks_ref8 (st, final, POLY1305_REF_BLOCKSIZE); - } - - /* fully reduce h */ - poly1305_freeze_ref8 (st->h); - - /* h = (h + pad) % (1 << 128) */ - poly1305_add_ref8 (st->h, st->pad); - for (i = 0; i < 16; i++) - mac[i] = st->h[i]; - - /* zero out the state */ - for (i = 0; i < 17; i++) - st->h[i] = 0; - for (i = 0; i < 17; i++) - st->r[i] = 0; - for (i = 0; i < 17; i++) - st->pad[i] = 0; - - /* burn_stack */ - return POLY1305_REF_BLOCKSIZE + 18 + 16 * sizeof (void *) + burn; -} - - -static const poly1305_ops_t poly1305_default_ops = { - POLY1305_REF_BLOCKSIZE, - poly1305_init_ext_ref8, - poly1305_blocks_ref8, - poly1305_finish_ext_ref8 -}; - -#endif /* HAVE_U64_TYPEDEF */ diff --git a/cipher/scrypt.c b/cipher/scrypt.c index a05b5bfd..13fd1cf0 100644 --- a/cipher/scrypt.c +++ b/cipher/scrypt.c @@ -50,8 +50,6 @@ #include "bufhelp.h" /* We really need a 64 bit type for this code. */ -#ifdef HAVE_U64_TYPEDEF - #define SALSA20_INPUT_LENGTH 16 #define ROTL32(n,x) (((x)<<(n)) | ((x)>>(32-(n)))) @@ -322,6 +320,3 @@ _gcry_kdf_scrypt (const unsigned char *passwd, size_t passwdlen, return ec; } - - -#endif /* HAVE_U64_TYPEDEF */ diff --git a/cipher/tiger.c b/cipher/tiger.c index 516bd44b..b60ec162 100644 --- a/cipher/tiger.c +++ b/cipher/tiger.c @@ -31,9 +31,6 @@ #include "bithelp.h" #include "bufhelp.h" -/* We really need a 64 bit type for this code. */ -#ifdef HAVE_U64_TYPEDEF - typedef struct { gcry_md_block_ctx_t bctx; @@ -853,5 +850,3 @@ gcry_md_spec_t _gcry_digest_spec_tiger2 = tiger2_init, _gcry_md_block_write, tiger_final, tiger_read, NULL, sizeof (TIGER_CONTEXT) }; - -#endif /* HAVE_U64_TYPEDEF */ diff --git a/configure.ac b/configure.ac index ff72e3fd..8ed8d26b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # Configure.ac script for Libgcrypt # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, # 2007, 2008, 2009, 2011 Free Software Foundation, Inc. -# Copyright (C) 2012, 2013 g10 Code GmbH +# Copyright (C) 2012, 2013, 2014, 2015 g10 Code GmbH # # This file is part of Libgcrypt. # @@ -198,12 +198,11 @@ enabled_pubkey_ciphers="" # Definitions for message digests. available_digests="crc gostr3411-94 md2 md4 md5 rmd160 sha1 sha256" -available_digests_64="sha512 sha3 tiger whirlpool stribog" +available_digests="$available_digests sha512 sha3 tiger whirlpool stribog" enabled_digests="" # Definitions for kdfs (optional ones) -available_kdfs="s2k pkdf2" -available_kdfs_64="scrypt" +available_kdfs="s2k pkdf2 scrypt" enabled_kdfs="" # Definitions for random modules. @@ -368,13 +367,14 @@ if test "$ac_cv_sizeof_unsigned_int" != "8" \ && test "$ac_cv_sizeof_unsigned_long" != "8" \ && test "$ac_cv_sizeof_unsigned_long_long" != "8" \ && test "$ac_cv_sizeof_uint64_t" != "8"; then - AC_MSG_WARN([No 64-bit types. Disabling TIGER/192, SCRYPT, SHA-384, \ - SHA-512 and GOST R 34.11-12]) -else - available_digests="$available_digests $available_digests_64" - available_kdfs="$available_kdfs $available_kdfs_64" + AC_MSG_ERROR([[ +*** +*** No 64-bit integer type available. +*** It is not possible to build Libgcrypt on this platform. +***]]) fi + # If not specified otherwise, all available algorithms will be # included. default_ciphers="$available_ciphers" diff --git a/src/g10lib.h b/src/g10lib.h index af688700..1070d9e9 100644 --- a/src/g10lib.h +++ b/src/g10lib.h @@ -318,13 +318,8 @@ void __gcry_burn_stack (unsigned int bytes); } while(0) #define wipememory(_ptr,_len) wipememory2(_ptr,0,_len) -#ifdef HAVE_U64_TYPEDEF - #define FASTWIPE_T u64 - #define FASTWIPE_MULT (U64_C(0x0101010101010101)) -#else - #define FASTWIPE_T u32 - #define FASTWIPE_MULT (0x01010101U) -#endif +#define FASTWIPE_T u64 +#define FASTWIPE_MULT (U64_C(0x0101010101010101)) /* Following architectures can handle unaligned accesses fast. */ #if defined(HAVE_GCC_ATTRIBUTE_PACKED) && \ diff --git a/src/types.h b/src/types.h index dcdba4ff..645ddd62 100644 --- a/src/types.h +++ b/src/types.h @@ -123,6 +123,8 @@ typedef uint64_t u64; # define U64_C(c) (UINT64_C(c)) # define HAVE_U64_TYPEDEF +# else +# error No way to declare a 64 bit integer type # endif #endif @@ -132,9 +134,7 @@ typedef union short b; char c[1]; long d; -#ifdef HAVE_U64_TYPEDEF u64 e; -#endif float f; double g; } PROPERLY_ALIGNED_TYPE; diff --git a/tests/basic.c b/tests/basic.c index 63fbcf6b..c633ae96 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -2039,7 +2039,6 @@ check_poly1305_cipher (void) static void check_ccm_cipher (void) { -#ifdef HAVE_U64_TYPEDEF static const struct tv { int algo; @@ -2816,7 +2815,6 @@ check_ccm_cipher (void) if (verbose) fprintf (stderr, " Completed CCM checks.\n"); #endif -#endif /*HAVE_U64_TYPEDEF*/ } diff --git a/tests/bench-slope.c b/tests/bench-slope.c index 3a2aa38e..8938f18c 100644 --- a/tests/bench-slope.c +++ b/tests/bench-slope.c @@ -741,7 +741,6 @@ static struct bench_ops decrypt_ops = { }; -#ifdef HAVE_U64_TYPEDEF static void bench_ccm_encrypt_do_bench (struct bench_obj *obj, void *buf, size_t buflen) { @@ -904,7 +903,6 @@ static struct bench_ops ccm_authenticate_ops = { &bench_encrypt_free, &bench_ccm_authenticate_do_bench }; -#endif /*HAVE_U64_TYPEDEF*/ static void @@ -1167,11 +1165,9 @@ static struct bench_cipher_mode cipher_modes[] = { {GCRY_CIPHER_MODE_OFB, "OFB dec", &decrypt_ops}, {GCRY_CIPHER_MODE_CTR, "CTR enc", &encrypt_ops}, {GCRY_CIPHER_MODE_CTR, "CTR dec", &decrypt_ops}, -#ifdef HAVE_U64_TYPEDEF {GCRY_CIPHER_MODE_CCM, "CCM enc", &ccm_encrypt_ops}, {GCRY_CIPHER_MODE_CCM, "CCM dec", &ccm_decrypt_ops}, {GCRY_CIPHER_MODE_CCM, "CCM auth", &ccm_authenticate_ops}, -#endif {GCRY_CIPHER_MODE_GCM, "GCM enc", &gcm_encrypt_ops}, {GCRY_CIPHER_MODE_GCM, "GCM dec", &gcm_decrypt_ops}, {GCRY_CIPHER_MODE_GCM, "GCM auth", &gcm_authenticate_ops}, diff --git a/tests/benchmark.c b/tests/benchmark.c index 1258b81c..53b83b1b 100644 --- a/tests/benchmark.c +++ b/tests/benchmark.c @@ -724,7 +724,6 @@ mac_bench ( const char *algoname ) } -#ifdef HAVE_U64_TYPEDEF static void ccm_aead_init(gcry_cipher_hd_t hd, size_t buflen, int authlen) { const int _L = 4; @@ -756,7 +755,6 @@ static void ccm_aead_init(gcry_cipher_hd_t hd, size_t buflen, int authlen) exit (1); } } -#endif static void @@ -786,10 +784,8 @@ cipher_bench ( const char *algoname ) { GCRY_CIPHER_MODE_CFB, " CFB", 0 }, { GCRY_CIPHER_MODE_OFB, " OFB", 0 }, { GCRY_CIPHER_MODE_CTR, " CTR", 0 }, -#ifdef HAVE_U64_TYPEDEF { GCRY_CIPHER_MODE_CCM, " CCM", 0, ccm_aead_init, GCRY_CCM_BLOCK_LEN, 8 }, -#endif { GCRY_CIPHER_MODE_GCM, " GCM", 0, NULL, GCRY_GCM_BLOCK_LEN, GCRY_GCM_BLOCK_LEN }, { GCRY_CIPHER_MODE_OCB, " OCB", 1, -- cgit v1.2.1