summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2015-07-09rsa: clarify the RSA secret parametersfixesPeter Wu1-2/+7
* cipher/rsa.c: Clarify meaning of the 'u' parameter. Fix error in comments. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2015-07-07Add LSan annotation to ignore a memory leakPeter Wu2-1/+21
* src/g10lib.h: Add annotate_leaked_object macro that ignores leaked objects. This avoids LSan from reporting deliberately leaked memory. * mpi/mpiutil.c: Mark "constant" MPIs as leaked. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2015-07-07Fix undefined behavior wrt memcpyPeter Wu2-1/+4
* cipher/cipher-gcm.c: Do not copy zero bytes from an empty buffer. Let the function continue to add padding as needed though. * cipher/mac-poly1305.c: If the caller requested to finish the hash function without a copy of the result, return immediately. -- Caught by UndefinedBehaviorSanitizer. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2015-07-07build: ignore scissor line for the commit-msg hookPeter Wu1-0/+6
* build-aux/git-hooks/commit-msg: Stop processing more lines when the scissor line is encountered. -- This allows the command `git commit -v` to work even if the code is longer than 72 characters. Note that comments are already ignored by the previous line. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2015-07-07ecc: fix memory leakPeter Wu1-0/+1
* cipher/ecc.c: Release memory which was allocated before by _gcry_pk_util_preparse_sigval. -- Caught by LeakSanitizer (LSan). Now the test suite (make check) passes with no memleaks. Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2015-07-07sexp: fix invalid deallocation in error pathPeter Wu1-1/+1
* src/sexp.c: Fix wrong condition in error path. -- This appears to be a copy and paste error and could result in wrong memory being freed in the error path (when arrayisdesx[idx] == 2, the condition ((!2) == 1) is false). Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2015-07-06ecc: fix memory leaks.NIIBE Yutaka1-16/+8
cipher/ecc.c (ecc_generate): Fix memory leak on error of _gcry_pk_util_parse_flaglist and _gcry_ecc_eddsa_encodepoint. (ecc_check_secret_key): Fix memory leak on error of _gcry_ecc_update_curve_param. (ecc_sign, ecc_verify, ecc_encrypt_raw, ecc_decrypt_raw): Remove unnecessary sexp_release and fix memory leak on error of _gcry_ecc_fill_in_curve. (ecc_decrypt_raw): Fix double free of the point kG and memory leak on error of _gcry_ecc_os2ec.
2015-06-11mpi: Support FreeBSD 10 or later.NIIBE Yutaka1-5/+7
* mpi/config.links: Include FreeBSD 10 to 29. -- Thanks to Yuta SATOH. GnuPG-bug-id: 1936, 1974
2015-05-21ecc: Add key generation flag "no-keytest".Werner Koch8-20/+95
* src/cipher.h (PUBKEY_FLAG_NO_KEYTEST): New. * cipher/pubkey-util.c (_gcry_pk_util_parse_flaglist): Add flag "no-keytest". Return an error for invalid flags of length 10. * cipher/ecc.c (nist_generate_key): Replace arg random_level by flags set random level depending on flags. * cipher/ecc-eddsa.c (_gcry_ecc_eddsa_genkey): Ditto. * cipher/ecc.c (ecc_generate): Pass flags to generate fucntion and remove var random_level. (nist_generate_key): Implement "no-keytest" flag. * tests/keygen.c (check_ecc_keys): Add tests for transient-key and no-keytest. -- After key creation we usually run a test to check whether the keys really work. However for transient keys this might be too time consuming and given that a failed test would anyway abort the process the optional use of a flag to skip the test is appropriate. Using Ed25519 for EdDSA and the "no-keytest" flags halves the time to create such a key. This was measured by looping the last test from check_ecc_keys() 1000 times with and without the flag. Due to a bug in the flags parser unknown flags with a length of 10 characters were not detected. Thus the "no-keytest" flag can be employed by all software even for libraries before this. That bug is however solved with this version. Signed-off-by: Werner Koch <wk@gnupg.org>
2015-05-21ecc: Avoid double conversion to affine coordinates in keygen.Werner Koch1-38/+67
* cipher/ecc.c (nist_generate_key): Add args r_x and r_y. (ecc_generate): Rename vars. Convert to affine coordinates only if not returned by the lower level generation function. -- nist_generate_key already needs to convert to affine coordinates to implement Jivsov's trick. Thus we can return them and avoid calling it in ecc_generate again. Signed-off-by: Werner Koch <wk@gnupg.org>
2015-05-21random: Change initial extra seeding from 2400 bits to 128 bits.Werner Koch1-2/+2
* random/random-csprng.c (read_pool): Reduce initial seeding. -- See discussion starting at https://lists.gnupg.org/pipermail/gnupg-devel/2015-April/029750.html and also in May. Signed-off-by: Werner Koch <wk@gnupg.org>
2015-05-14Enable AMD64 Twofish implementation on WIN64Jussi Kivilinna2-21/+100
* cipher/twofish-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/twofish.c (USE_AMD64_ASM): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS] (call_sysv_fn): New. (twofish_amd64_encrypt_block, twofish_amd64_decrypt_block) (twofish_amd64_ctr_enc, twofish_amd64_cbc_dec) (twofish_amd64_cfb_dec): New wrapper functions for AMD64 assembly functions. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14Enable AMD64 Serpent implementations on WIN64Jussi Kivilinna3-30/+58
* cipher/serpent-avx2-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/serpent-sse2-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/chacha20.c (USE_SSE2, USE_AVX2): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. [USE_SSE2 || USE_AVX2] (ASM_FUNC_ABI): New. (_gcry_serpent_sse2_ctr_enc, _gcry_serpent_sse2_cbc_dec) (_gcry_serpent_sse2_cfb_dec, _gcry_serpent_avx2_ctr_enc) (_gcry_serpent_avx2_cbc_dec, _gcry_serpent_avx2_cfb_dec): Add ASM_FUNC_ABI. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14Enable AMD64 Salsa20 implementation on WIN64Jussi Kivilinna2-10/+33
* cipher/salsa20-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/salsa20.c (USE_AMD64): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. [USE_AMD64] (ASM_FUNC_ABI, ASM_EXTRA_STACK): New. (_gcry_salsa20_amd64_keysetup, _gcry_salsa20_amd64_ivsetup) (_gcry_salsa20_amd64_encrypt_blocks): Add ASM_FUNC_ABI. [USE_AMD64] (salsa20_core): Add ASM_EXTRA_STACK. (salsa20_do_encrypt_stream) [USE_AMD64]: Add ASM_EXTRA_STACK. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14Enable AMD64 Poly1305 implementations on WIN64Jussi Kivilinna4-34/+70
* cipher/poly1305-avx2-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/poly1305-sse2-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/poly1305-internal.h (POLY1305_SYSV_FUNC_ABI): New. (POLY1305_USE_SSE2, POLY1305_USE_AVX2): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (OPS_FUNC_ABI): New. (poly1305_ops_t): Use OPS_FUNC_ABI. * cipher/poly1305.c (_gcry_poly1305_amd64_sse2_init_ext) (_gcry_poly1305_amd64_sse2_finish_ext) (_gcry_poly1305_amd64_sse2_blocks, _gcry_poly1305_amd64_avx2_init_ext) (_gcry_poly1305_amd64_avx2_finish_ext) (_gcry_poly1305_amd64_avx2_blocks, _gcry_poly1305_armv7_neon_init_ext) (_gcry_poly1305_armv7_neon_finish_ext) (_gcry_poly1305_armv7_neon_blocks, poly1305_init_ext_ref32) (poly1305_blocks_ref32, poly1305_finish_ext_ref32) (poly1305_init_ext_ref8, poly1305_blocks_ref8) (poly1305_finish_ext_ref8): Use OPS_FUNC_ABI. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14Enable AMD64 3DES implementation on WIN64Jussi Kivilinna2-15/+75
* cipher/des-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/des.c (USE_AMD64_ASM): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS] (call_sysv_fn): New. (tripledes_ecb_crypt) [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS]: Call assembly function through 'call_sysv_fn'. (tripledes_amd64_ctr_enc, tripledes_amd64_cbc_dec) (tripledes_amd64_cfb_dec): New wrapper functions for bulk assembly functions. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14Enable AMD64 ChaCha20 implementations on WIN64Jussi Kivilinna4-19/+63
* cipher/chacha20-avx2-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/chacha20-sse2-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/chacha20-ssse3-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/chacha20.c (USE_SSE2, USE_SSSE3, USE_AVX2): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ASM_FUNC_ABI, ASM_EXTRA_STACK): New. (chacha20_blocks_t, _gcry_chacha20_amd64_sse2_blocks) (_gcry_chacha20_amd64_ssse3_blocks, _gcry_chacha20_amd64_avx2_blocks) (_gcry_chacha20_armv7_neon_blocks, chacha20_blocks): Add ASM_FUNC_ABI. (chacha20_core): Add ASM_EXTRA_STACK. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14Enable AMD64 CAST5 implementation on WIN64Jussi Kivilinna2-24/+86
* cipher/cast5-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (RIP): Remove. (GET_EXTERN_POINTER): Use 'leaq' version on WIN64. (ELF): New macro to mask lines with ELF specific commands. * cipher/cast5.c (USE_AMD64_ASM): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS] (call_sysv_fn): New. (do_encrypt_block, do_decrypt_block) [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS]: Call assembly function through 'call_sysv_fn'. (cast5_amd64_ctr_enc, cast5_amd64_cbc_dec) (cast5_amd64_cfb_dec): New wrapper functions for bulk assembly functions. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14Enable AMD64 Camellia implementations on WIN64Jussi Kivilinna3-46/+85
* cipher/camellia-aesni-avx-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/camellia-aesni-avx2-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/camellia-glue.c (USE_AESNI_AVX, USE_AESNI_AVX2): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. [USE_AESNI_AVX || USE_AESNI_AVX2] (ASM_FUNC_ABI, ASM_EXTRA_STACK): New. (_gcry_camellia_aesni_avx_ctr_enc, _gcry_camellia_aesni_avx_cbc_dec) (_gcry_camellia_aesni_avx_cfb_dec, _gcry_camellia_aesni_avx_keygen) (_gcry_camellia_aesni_avx2_ctr_enc, _gcry_camellia_aesni_avx2_cbc_dec) (_gcry_camellia_aesni_avx2_cfb_dec): Add ASM_FUNC_ABI. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14Enable AMD64 Blowfish implementation on WIN64Jussi Kivilinna2-23/+97
* cipher/blowfish-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/blowfish.c (USE_AMD64_ASM): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS] (call_sysv_fn): New. (do_encrypt, do_encrypt_block, do_decrypt_block) [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS]: Call assembly function through 'call_sysv_fn'. (blowfish_amd64_ctr_enc, blowfish_amd64_cbc_dec) (blowfish_amd64_cfb_dec): New wrapper functions for bulk assembly functions. .. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14Enable AMD64 arcfour implementation on WIN64Jussi Kivilinna2-4/+26
* cipher/arcfour-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/arcfour.c (USE_AMD64_ASM): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (do_encrypt, do_decrypt) [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS]: Use assembly block to call AMD64 assembly function. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14Update documentation for Poly1305-ChaCha20 AEAD, RFC-7539Jussi Kivilinna2-5/+6
* cipher/cipher-poly1305.c: Add RFC-7539 to header. * doc/gcrypt.texi: Update Poly1305 AEAD documentation with mention of RFC-7539; Drop Salsa from supported stream ciphers for Poly1305 AEAD. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14hwf-x86: use edi for passing value to ebx for i386 cpuidJussi Kivilinna1-1/+1
* src/hwf-x86.c [__i386__] (get_cpuid): Use '=D' for regs[1] instead of '=r'. -- On Win32, %ebx can be assigned for '=r' (regs[1]). This results invalid assembly: pushl %ebx movl %ebx, %ebx cpuid movl %ebx, %ebx popl %ebx So use '=D' (%esi) for regs[1] instead. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-14hwf-x86: add EDX as output register for xgetbv asm blockJussi Kivilinna1-4/+4
* src/hwf-x86.c (get_xgetbv): Add EDX as output. -- XGETBV instruction modifies EAX:EDX register pair, so we need to mark EDX as output to let compiler know that contents in this register are lost. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-04build: Update build-aux files.Werner Koch9-956/+2300
Signed-off-by: Werner Koch <wk@gnupg.org>
2015-05-04Fix possible regression on old 32 bit mingw compilers.Werner Koch1-1/+1
* acinclude.m4: Add new pattern for mingw32. Signed-off-by: Werner Koch <wk@gnupg.org>
2015-05-04build: Add new file.Werner Koch1-0/+1
* mpi/amd64/distfiles: Add func_abi.h. Signed-off-by: Werner Koch <wk@gnupg.org>
2015-05-03Fix WIN64 assembly glue for AESJussi Kivilinna1-20/+24
* cipher/rinjdael.c (do_encrypt, do_decrypt) [!HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS]: Change input operands to input+output to mark volatile nature of the used registers. -- Function arguments cannot be passed to assembly block as input operands as target function modifies those input registers. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-03Add '1 million a characters' test vectorsJussi Kivilinna1-0/+15
* tests/basic.c (check_digests): Add "!" test vectors for MD5, SHA-384, SHA-512, RIPEMD160 and CRC32. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-03More optimized CRC implementationsJussi Kivilinna2-160/+660
* cipher/crc.c (crc32_table, crc24_table): Replace with new table contents. (update_crc32, CRC24_INIT, CRC24_POLY): Remove. (crc32_next, crc32_next4, crc24_init, crc24_next, crc24_next4) (crc24_final): New. (crc24rfc2440_init): Use crc24_init. (crc32_write): Rewrite to use crc32_next & crc32_next4. (crc24_write): Rewrite to use crc24_next & crc24_next4. (crc32_final, crc32rfc1510_final): Use buf_put_be32. (crc24rfc2440_final): Use crc24_final & buf_put_le32. * tests/basic.c (check_digests): Add CRC "123456789" tests. -- Patch adds more optimized CRC implementations generated with universal_crc tool by Danjel McGougan: http://www.mcgougan.se/universal_crc/ Benchmark on Intel Haswell (no-turbo, 3200 Mhz): Before: CRC32 | 2.52 ns/B 378.3 MiB/s 8.07 c/B CRC32RFC1510 | 2.52 ns/B 378.1 MiB/s 8.07 c/B CRC24RFC2440 | 46.62 ns/B 20.46 MiB/s 149.2 c/B After: CRC32 | 0.918 ns/B 1039.3 MiB/s 2.94 c/B CRC32RFC1510 | 0.918 ns/B 1039.0 MiB/s 2.94 c/B CRC24RFC2440 | 0.918 ns/B 1039.4 MiB/s 2.94 c/B Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-02Enable AMD64 AES implementation for WIN64Jussi Kivilinna3-6/+48
* cipher/rijndael-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/rijndael-internal.h (USE_AMD64_ASM): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (do_encrypt, do_decrypt) [USE_AMD64_ASM && !HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS]: Use assembly block to call AMD64 assembly encrypt/decrypt function. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-02Enable AMD64 Whirlpool implementation for WIN64Jussi Kivilinna2-6/+22
* cipher/whirlpool-sse2-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/whirlpool.c (USE_AMD64_ASM): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. [USE_AMD64_ASM] (ASM_FUNC_ABI, ASM_EXTRA_STACK): New. [USE_AMD64_ASM] (_gcry_whirlpool_transform_amd64): Add ASM_FUNC_ABI to prototype. [USE_AMD64_ASM] (whirlpool_transform): Add ASM_EXTRA_STACK to stack burn value. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-02Enable AMD64 SHA512 implementations for WIN64Jussi Kivilinna4-21/+72
* cipher/sha512-avx-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/sha512-avx-bmi2-amd64.S: Ditto. * cipher/sha512-ssse3-amd64.S: Ditto. * cipher/sha512.c (USE_SSSE3, USE_AVX, USE_AVX2): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. [USE_SSSE3 || USE_AVX || USE_AVX2] (ASM_FUNC_ABI) (ASM_EXTRA_STACK): New. (_gcry_sha512_transform_amd64_ssse3, _gcry_sha512_transform_amd64_avx) (_gcry_sha512_transform_amd64_avx_bmi2): Add ASM_FUNC_ABI to prototypes. (transform): Add ASM_EXTRA_STACK to stack burn value. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-02Enable AMD64 SHA256 implementations for WIN64Jussi Kivilinna4-21/+72
* cipher/sha256-avx-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/sha256-avx2-bmi2-amd64.S: Ditto. * cipher/sha256-ssse3-amd64.S: Ditto. * cipher/sha256.c (USE_SSSE3, USE_AVX, USE_AVX2): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. [USE_SSSE3 || USE_AVX || USE_AVX2] (ASM_FUNC_ABI) (ASM_EXTRA_STACK): New. (_gcry_sha256_transform_amd64_ssse3, _gcry_sha256_transform_amd64_avx) (_gcry_sha256_transform_amd64_avx2): Add ASM_FUNC_ABI to prototypes. (transform): Add ASM_EXTRA_STACK to stack burn value. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-02Enable AMD64 SHA1 implementations for WIN64Jussi Kivilinna4-18/+69
* cipher/sha1-avx-amd64.S: Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. (ELF): New macro to mask lines with ELF specific commands. * cipher/sha1-avx-bmi2-amd64.S: Ditto. * cipher/sha1-ssse3-amd64.S: Ditto. * cipher/sha1.c (USE_SSSE3, USE_AVX, USE_BMI2): Enable when HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS defined. [USE_SSSE3 || USE_AVX || USE_BMI2] (ASM_FUNC_ABI) (ASM_EXTRA_STACK): New. (_gcry_sha1_transform_amd64_ssse3, _gcry_sha1_transform_amd64_avx) (_gcry_sha1_transform_amd64_avx_bmi2): Add ASM_FUNC_ABI to prototypes. (transform): Add ASM_EXTRA_STACK to stack burn value. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Enable AES/AES-NI, AES/SSSE3 and GCM/PCLMUL implementations on WIN64Jussi Kivilinna6-43/+317
* cipher/cipher-gcm-intel-pclmul.c (_gcry_ghash_intel_pclmul) ( _gcry_ghash_intel_pclmul) [__WIN64__]: Store non-volatile vector registers before use and restore after. * cipher/cipher-internal.h (GCM_USE_INTEL_PCLMUL): Remove dependency on !defined(__WIN64__). * cipher/rijndael-aesni.c [__WIN64__] (aesni_prepare_2_6_variable, aesni_prepare, aesni_prepare_2_6, aesni_cleanup) ( aesni_cleanup_2_6): New. [!__WIN64__] (aesni_prepare_2_6_variable, aesni_prepare_2_6): New. (_gcry_aes_aesni_do_setkey, _gcry_aes_aesni_cbc_enc) (_gcry_aesni_ctr_enc, _gcry_aesni_cfb_dec, _gcry_aesni_cbc_dec) (_gcry_aesni_ocb_crypt, _gcry_aesni_ocb_auth): Use 'aesni_prepare_2_6'. * cipher/rijndael-internal.h (USE_SSSE3): Enable if HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS or HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS. (USE_AESNI): Remove dependency on !defined(__WIN64__) * cipher/rijndael-ssse3-amd64.c [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS] (vpaes_ssse3_prepare, vpaes_ssse3_cleanup): New. [!HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS] (vpaes_ssse3_prepare): New. (vpaes_ssse3_prepare_enc, vpaes_ssse3_prepare_dec): Use 'vpaes_ssse3_prepare'. (_gcry_aes_ssse3_do_setkey, _gcry_aes_ssse3_prepare_decryption): Use 'vpaes_ssse3_prepare' and 'vpaes_ssse3_cleanup'. [HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS] (X): Add masking macro to exclude '.type' and '.size' markers from assembly code, as they are not support on WIN64/COFF objects. * configure.ac (gcry_cv_gcc_attribute_ms_abi) (gcry_cv_gcc_attribute_sysv_abi, gcry_cv_gcc_default_abi_is_ms_abi) (gcry_cv_gcc_default_abi_is_sysv_abi) (gcry_cv_gcc_win64_platform_as_ok): New checks. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Add W64 support for mpi amd64 assemblyJussi Kivilinna10-6/+46
acinclude.m4 (GNUPG_SYS_SYMBOL_UNDERSCORE): Set 'ac_cv_sys_symbol_underscore=no' on MingW-W64. mpi/amd64/func_abi.h: New. mpi/amd64/mpih-add1.S (_gcry_mpih_add_n): Add FUNC_ENTRY and FUNC_EXIT. mpi/amd64/mpih-lshift.S (_gcry_mpih_lshift): Ditto. mpi/amd64/mpih-mul1.S (_gcry_mpih_mul_1): Ditto. mpi/amd64/mpih-mul2.S (_gcry_mpih_addmul_1): Ditto. mpi/amd64/mpih-mul3.S (_gcry_mpih_submul_1): Ditto. mpi/amd64/mpih-rshift.S (_gcry_mpih_rshift): Ditto. mpi/amd64/mpih-sub1.S (_gcry_mpih_sub_n): Ditto. mpi/config.links [host=x86_64-*mingw*]: Enable assembly modules. [host=x86_64-*-*]: Append mpi/amd64/func_abi.h to mpi/asm-syntax.h. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01DES: Silence compiler warnings on WindowsJussi Kivilinna1-1/+3
* cipher/des.c (working_memcmp): Make pointer arguments 'const void *'. -- Following warning seen on Windows target build: des.c: In function 'is_weak_key': des.c:1019:40: warning: pointer targets in passing argument 1 of 'working_memcmp' differ in signedness [-Wpointer-sign] if ( !(cmp_result=working_memcmp(work, weak_keys[middle], 8)) ) ^ des.c:149:1: note: expected 'const char *' but argument is of type 'unsigned char *' working_memcmp( const char *a, const char *b, size_t n ) ^ des.c:1019:46: warning: pointer targets in passing argument 2 of 'working_memcmp' differ in signedness [-Wpointer-sign] if ( !(cmp_result=working_memcmp(work, weak_keys[middle], 8)) ) ^ des.c:149:1: note: expected 'const char *' but argument is of type 'unsigned char *' working_memcmp( const char *a, const char *b, size_t n ) ^ Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Cast pointers to integers using uintptr_t instead of longJussi Kivilinna2-3/+3
2015-05-01Fix rndhw for 64-bit Windows buildJussi Kivilinna2-2/+3
* configure.ac: Add sizeof check for 'void *'. * random/rndhw.c (poll_padlock): Check for SIZEOF_VOID_P == 8 instead of defined(__LP64__). (RDRAND_LONG): Check for SIZEOF_UNSIGNED_LONG == 8 instead of defined(__LP64__). -- __LP64__ is not predefined for 64-bit mingw64-gcc, which caused wrong assembly code selections. Do selection based on type sizes instead, to support x86_64, x32 and win64 properly. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Prepare random/win32.c fast poll for 64-bit WindowsJussi Kivilinna1-31/+52
* random/win32.c (_gcry_rndw32_gather_random_fast) [ADD]: Rename to ADDINT. (_gcry_rndw32_gather_random_fast): Add ADDPTR. (_gcry_rndw32_gather_random_fast): Disable entropy gathering from GetQueueStatus(QS_ALLEVENTS). (_gcry_rndw32_gather_random_fast): Change minimumWorkingSetSize and maximumWorkingSetSize to SIZE_T from DWORD. (_gcry_rndw32_gather_random_fast): Only add lower 32-bits of minimumWorkingSetSize and maximumWorkingSetSize to random poll. (_gcry_rndw32_gather_random_fast) [__WIN64__]: Read TSC directly using intrinsic. -- Introduce entropy gatherer changes related to 64-bit Windows platform as done in cryptlib fast poll: - Change ADD macro to ADDPTR/ADDINT to handle pointer values. ADDPTR discards high 32-bits of 64-bit pointer values. - minimum/maximumWorkingSetSize changed to SIZE_T type to avoid stack corruption on 64-bit; only low 32-bits are used for entropy. - Use __rdtsc() intrinsic on 64-bit (as TSC is always available). Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Disable GCM and AES-NI assembly implementations for WIN64Jussi Kivilinna2-2/+6
* cipher/cipher-internal.h (GCM_USE_INTEL_PCLMUL): Do not enable when __WIN64__ defined. * cipher/rijndael-internal.h (USE_AESNI): Ditto. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Disable building mpi assembly routines on WIN64Jussi Kivilinna1-0/+5
* mpi/config.links: Disable assembly for host 'x86_64-*mingw32*'. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Fix packed attribute check for Windows targetsJussi Kivilinna1-1/+3
* configure.ac (gcry_cv_gcc_attribute_packed): Move 'long b' to its own packed structure. -- Change packed attribute test so that it works with both MS ABI and SYSV ABI. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Fix tail handling in buf_xor_1Jussi Kivilinna1-1/+1
* cipher/bufhelp.h (buf_xor_1): Increment source pointer at tail handling. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Add --disable-hwf for basic testsJussi Kivilinna1-0/+15
* tests/basic.c (main): Add handling for '--disable-hwf'. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Use more odd chuck sizes for check_one_mdJussi Kivilinna1-3/+21
* tests/basic.c (check_one_md): Make chuck size vary oddly, instead of using fixed length of 1000 bytes. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Enable more modes in basic ciphers testJussi Kivilinna2-8/+68
* src/gcrypt.h.in (GCRY_OCB_BLOCK_LEN): New. * tests/basic.c (check_one_cipher_core_reset): New. (check_one_cipher_core): Use check_one_cipher_core_reset inplace of gcry_cipher_reset. (check_ciphers): Add CCM and OCB modes for block cipher tests. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Fix reseting cipher in OCB modeJussi Kivilinna1-0/+2
* cipher/cipher.c (cipher_reset): Setup default taglen for OCB after clearing state. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-04-30Fix buggy RC4 AMD64 assembly and add test to notice similar issuesJussi Kivilinna2-2/+154
* cipher/arcfour-amd64.S (_gcry_arcfour_amd64): Fix swapped store of 'x' and 'y'. * tests/basic.c (get_algo_mode_blklen): New. (check_one_cipher_core): Add new tests for split buffer input on encryption and decryption. -- Reported-by: Dima Kukulniak <dima.ky@gmail.com> Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>