summaryrefslogtreecommitdiff
path: root/cipher/bithelp.h
AgeCommit message (Collapse)AuthorFilesLines
2016-03-18Always require a 64 bit integer typeWerner Koch1-15/+7
* 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 <wk@gnupg.org>
2015-03-16Make uintptr_t global available.Werner Koch1-6/+5
* cipher/bufhelp.h: Move include for uintptr_t to ... * src/types.h: here. Check that config.h has been included. Signed-off-by: Werner Koch <wk@gnupg.org>
2015-01-15Add functions to count trailing zero bits in a word.Werner Koch1-0/+45
* cipher/bithelp.h (_gcry_ctz, _gcry_ctz64): New. * configure.ac (HAVE_BUILTIN_CTZ): Add new test. -- Note that these functions return the number of bits in the word when passing 0. Signed-off-by: Werner Koch <wk@gnupg.org>
2014-01-13Fix macro conflict in NetBSDWerner Koch1-9/+11
* cipher/bithelp.h (bswap32): Rename to _gcry_bswap32. (bswap64): Rename to _gcry_bswap64. -- NetBSD provides system macros bswap32 and bswap64 which conflicts with our macros. Prefixing them with _gcry_ is easier than to come up with a proper test. GnuPG-bug-id: 1600 Signed-off-by: Werner Koch <wk@gnupg.org> (cherry picked from commit 36214bfa8f612cd2faa4de217d1a12a8b5faadbf)
2013-10-30bithelp: fix undefined behaviour with rol and rorJussi Kivilinna1-3/+3
* cipher/bithelp.h (rol, ror): Mask shift with 31. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-09-21Remove i386 inline assembly version of rotation functionsJussi Kivilinna1-22/+4
* cipher/bithelp.h (rol, ror): Remove i386 version, change macros to inline functions. * src/hmac256.c (ror): Ditto. -- (Current) compilers can optimize '(x << c) | (x >> (32-c))' to rotation instruction. So remove i386 specific assembly for manually doing this. Furthermore, compiler can generate faster code in case where 'c' is constant and can use rotate with immediate value rather than rotate with %cl register. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-09-21Optimize and cleanup 32-bit and 64-bit endianess transformsJussi Kivilinna1-0/+40
* cipher/bithelp.h (bswap32, bswap64, le_bswap32, be_bswap32) (le_bswap64, be_bswap64): New. * cipher/bufhelp.h (buf_get_be32, buf_get_le32, buf_put_le32) (buf_put_be32, buf_get_be64, buf_get_le64, buf_put_be64) (buf_put_le64): New. * cipher/blowfish.c (do_encrypt_block, do_decrypt_block): Use new endian conversion helpers. (do_bf_setkey): Turn endian specific code to generic. * cipher/camellia.c (GETU32, PUTU32): Use new endian conversion helpers. * cipher/cast5.c (rol): Remove, use rol from bithelp. (F1, F2, F3): Fix to use rol from bithelp. (do_encrypt_block, do_decrypt_block, do_cast_setkey): Use new endian conversion helpers. * cipher/des.c (READ_64BIT_DATA, WRITE_64BIT_DATA): Ditto. * cipher/md4.c (transform, md4_final): Ditto. * cipher/md5.c (transform, md5_final): Ditto. * cipher/rmd160.c (transform, rmd160_final): Ditto. * cipher/salsa20.c (LE_SWAP32, LE_READ_UINT32): Ditto. * cipher/scrypt.c (READ_UINT64, LE_READ_UINT64, LE_SWAP32): Ditto. * cipher/seed.c (GETU32, PUTU32): Ditto. * cipher/serpent.c (byte_swap_32): Remove. (serpent_key_prepare, serpent_encrypt_internal) (serpent_decrypt_internal): Use new endian conversion helpers. * cipher/sha1.c (transform, sha1_final): Ditto. * cipher/sha256.c (transform, sha256_final): Ditto. * cipher/sha512.c (__transform, sha512_final): Ditto. * cipher/stribog.c (transform, stribog_final): Ditto. * cipher/tiger.c (transform, tiger_final): Ditto. * cipher/twofish.c (INPACK, OUTUNPACK): Ditto. * cipher/whirlpool.c (buffer_to_block, block_to_buffer): Ditto. * configure.ac (gcry_cv_have_builtin_bswap32): Check for compiler provided __builtin_bswap32. (gcry_cv_have_builtin_bswap64): Check for compiler provided __builtin_bswap64. -- Patch add helper functions that provide conversions to/from integers and buffers of different endianess. Benefits are code cleanup and optimization for architectures that have byte-swaping instructions and/or can do fast unaligned memory accesses. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-07-10Fix i386/amd64 inline assembly "cc" clobbersJussi Kivilinna1-2/+4
* cipher/bithelp.h [__GNUC__, __i386__] (rol, ror): add "cc" globber for inline assembly. * cipher/cast5.c [__GNUC__, __i386__] (rol): Ditto. * random/rndhw.c [USE_DRNG] (rdrand_long): Ditto. * src/hmac256.c [__GNUC__, __i386__] (ror): Ditto. * mpi/longlong.c [__i386__] (add_ssaaaa, sub_ddmmss, umul_ppmm) (udiv_qrnnd, count_leading_zeros, count_trailing_zeros): Ditto. -- These assembly snippets modify cflags but do not mark "cc" clobber. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2003-01-20* basic.c (check_one_md): Kludge to check a one million "a".Werner Koch1-2/+15
(check_digests): Add checks for SHA-256. * sha256.c: New. * bithelp.h (ror): New. * Makfile.am: Add sha256.c. * md.c (oid_table): Add values for SHA256 et al. (gcry_md_get_algo_dlen): Likewise * configure.ac (LIBGCRYPT_LT_REVISION): Bumbed up.
2002-05-14Change the license to the LGPL.Werner Koch1-7/+7
2000-12-21Changed program name in all filesWerner Koch1-3/+3
1999-09-13See ChangeLog: Mon Sep 13 10:55:14 CEST 1999 Werner KochWerner Koch1-0/+41