summaryrefslogtreecommitdiff
path: root/mpi
AgeCommit message (Collapse)AuthorFilesLines
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-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-01Add W64 support for mpi amd64 assemblyJussi Kivilinna9-5/+42
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-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-04-13mpi: Fix gcry_mpi_copy for NULL opaque data.Werner Koch1-1/+2
* mpi/mpiutil.c (_gcry_mpi_copy): Copy opaque only if needed. -- gcry_mpi_set_opaque allows to store NULL as opaque data. Thus we also need to take care when copying such data. Signed-off-by: Werner Koch <wk@gnupg.org>
2015-03-16mpi: Remove useless condition.Werner Koch1-9/+2
* mpi/mpi-pow.c: Remove condition rp==mp. -- MP has already been allocated and thus can't match RP. The followinf assert would have been triggred anyway due to the prior allocation. Detected by Stack 0.3.
2015-02-27mpi: Avoid data-dependent timing variations in mpi_powm.NIIBE Yutaka1-6/+45
* mpi/mpi-pow.c (mpi_powm): Access all data in the table by mpi_set_cond. -- Access to the precomputed table was indexed by a portion of EXPO, which could be mounted by a side channel attack. This change fixes this particular data-dependent access pattern. Cherry-picked from commit 5e72b6c76ebee720f69b8a5c212f52d38eb50287 in LIBGCRYPT-1-6-BRANCH.
2015-02-27mpi: Revise mpi_powm.NIIBE Yutaka1-42/+18
* mpi/mpi-pow.c (_gcry_mpi_powm): Rename the table to PRECOMP. -- The name of precomputed table was b_2i3 which stands for BASE^(2*I+3). But it's too cryptic, so, it's renamed. Besides, we needed to distinguish the case of I==0, that was not good. Since it's OK to increase the size of table by one, it's BASE^(2*I+1), now.
2015-02-12mpi: Add mpi_set_cond.NIIBE Yutaka1-4/+29
* mpi/mpiutil.c (_gcry_mpi_set_cond): New. (_gcry_mpi_swap_cond): Fix types. * src/mpi.h (mpi_set_cond): New.
2015-01-06Remove the old Manifest filesWerner Koch26-359/+1
-- The Manifest file have been part of an experiment a long time ago to implement source level integrity. I is not maintained for more than a decade and with the advent of git this is superfluous anyway.
2014-11-19ecc: Improve Montgomery curve implementation.NIIBE Yutaka1-16/+27
* cipher/ecc-curves.c (_gcry_ecc_fill_in_curve): Support MPI_EC_MONTGOMERY. * cipher/ecc.c (test_ecdh_only_keys): New. (nist_generate_key): Call test_ecdh_only_keys for MPI_EC_MONTGOMERY. (check_secret_key): Handle Montgomery curve of x-coordinate only. * mpi/ec.c (_gcry_mpi_ec_mul_point): Resize points before the loop. Simplify, using pointers of Q1, Q2, PRD, and SUM. --
2014-10-08mpi: Add gcry_mpi_ec_sub.Markus Teich1-0/+65
* NEWS (gcry_mpi_ec_sub): New. * doc/gcrypt.texi (gcry_mpi_ec_sub): New. * mpi/ec.c (_gcry_mpi_ec_sub, sub_points_edwards): New. (sub_points_montgomery, sub_points_weierstrass): New stubs. * src/gcrypt-int.h (_gcry_mpi_ec_sub): New. * src/gcrypt.h.in (gcry_mpi_ec_sub): New. * src/libgcrypt.def (gcry_mpi_ec_sub): New. * src/libgcrypt.vers (gcry_mpi_ec_sub): New. * src/mpi.h (_gcry_mpi_ec_sub_points): New. * src/visibility.c (gcry_mpi_ec_sub): New. * src/visibility.h (gcry_mpi_ec_sub): New. -- This function subtracts two points on the curve. Only Twisted Edwards curves are supported with this change. Signed-off-by: Markus Teich <markus dot teich at stusta dot mhn dot de>
2014-08-29mpi: Re-indent longlong.h.Werner Koch1-249/+264
-- Indenting the cpp statements should make longlong.h better readable.
2014-08-12ecc: Support Montgomery curve for gcry_mpi_ec_mul_point.NIIBE Yutaka1-8/+139
* mpi/ec.c (_gcry_mpi_ec_get_affine): Support Montgomery curve. (montgomery_ladder): New. (_gcry_mpi_ec_mul_point): Implemention using montgomery_ladder. (_gcry_mpi_ec_curve_point): Check x-coordinate is valid. -- Given Montgomery curve: b * y^2 == x^3 + a * x^2 + x CTX->A has (a-2)/4 and CTX->B has b^-1 Note that _gcry_mpi_ec_add_points is not supported for this curve.
2014-08-08ecc: Add cofactor to domain parameters.NIIBE Yutaka1-0/+1
* src/ec-context.h (mpi_ec_ctx_s): Add cofactor 'h'. * cipher/ecc-common.h (elliptic_curve_t): Add cofactor 'h'. (_gcry_ecc_update_curve_param): New API adding cofactor. * cipher/ecc-curves.c (ecc_domain_parms_t): Add cofactor 'h'. (ecc_domain_parms_t domain_parms): Add cofactors. (_gcry_ecc_fill_in_curve, _gcry_ecc_update_curve_param) (_gcry_ecc_get_curve, _gcry_mpi_ec_new, _gcry_ecc_get_param_sexp) (_gcry_ecc_get_mpi): Handle cofactor. * cipher/ecc-eddsa.c (_gcry_ecc_eddsa_genkey): Likewise. * cipher/ecc-misc.c (_gcry_ecc_curve_free) (_gcry_ecc_curve_copy): Likewise. * cipher/ecc.c (nist_generate_key, ecc_generate) (ecc_check_secret_key, ecc_sign, ecc_verify, ecc_encrypt_raw) (ecc_decrypt_raw, _gcry_pk_ecc_get_sexp, _gcry_pubkey_spec_ecc): Likewise. (compute_keygrip): Handle cofactor, but skip it for its computation. * mpi/ec.c (ec_deinit): Likewise. * tests/t-mpi-point.c (context_param): Likewise. (test_curve): Add cofactors. * tests/curves.c (sample_key_1, sample_key_2): Add cofactors. * tests/keygrip.c (key_grips): Add cofactors. -- We keep compatibility of compute_keygrip in cipher/ecc.c.
2014-08-05mpi: Fix regression for powerpc-apple-darwin detection.Werner Koch1-1/+6
* mpi/config.links: Add separate entry for powerpc-apple-darwin. -- GnuPG-bug-id: 1616
2014-08-05mpi: Use BSD syntax for x86_64-apple-darwinWerner Koch1-0/+6
* mpi/config.links: Add case for x86_64-apple-darwin. -- Suggested by gniibe on 2014-04-24.
2014-08-05Fix building for the x32 target without asm modules.Kristian Fiskerstrand1-9/+7
* mpi/generic/mpi-asm-defs.h: Use a fixed value for the x32 ABI. -- See commit fd6721c235a5bdcb332c8eb708fbd4f96e52e824 for details.
2014-07-25mpi: Extend the internal mpi_get_buffer.Werner Koch1-12/+37
* mpi/mpicoder.c (do_get_buffer): Add arg EXTRAALLOC. (_gcry_mpi_get_buffer_extra): New.
2014-07-16mpi: Add mpi_swap_cond.NIIBE Yutaka1-0/+28
* mpi/mpiutil.c (_gcry_mpi_swap_cond): New. * src/mpi.h (mpi_swap_cond): New. -- This is an internal function for now.
2014-05-09mpi: Fix a subtle bug setting spurious bits with in mpi_set_bit.Werner Koch1-2/+6
* mpi/mpi-bit.c (_gcry_mpi_set_bit, _gcry_mpi_set_highbit): Clear allocated but not used bits before resizing. * tests/t-mpi-bits.c (set_bit_with_resize): New. -- Reported-by: Martin Sewelies. This bug is probably with us for many years. Probably due to different memory allocation patterns, it did first revealed itself with 1.6. It could be the reason for other heisenbugs. Signed-off-by: Werner Koch <wk@gnupg.org>
2014-05-09Comment typo fixWerner Koch1-1/+1
--
2014-01-27mpi: Minor fix for Atari-mint.Werner Koch1-1/+1
* mpi/config.links [m68k-atari-mint]: Do not assume 68020. Suggested by Alan Hourihane. (cherry picked from commit 420f42a5752e90a8b27d58ffa1ddfe6e4ab341e8)
2014-01-24Check compiler features only for the relevant platform.Werner Koch1-5/+22
* mpi/config.links (mpi_cpu_arch): Always set for ARM. Set for HPPA. Set to "undefined" for unknown platforms. (try_asm_modules): Act upon only after having detected the CPU. * configure.ac: Move the call to config.links before the platform specific compiler checks. Check platform specific features only if the platform is targeted. -- There is no need to check x86 options if we are targeting ARM and vice versa. This may only introduce build problems. With this patch the summary output at the end of the compiler also shows more reasonable messages. Signed-off-by: Werner Koch <wk@gnupg.org> (cherry picked from commit 04d478d9b0f92d80105ddaf2c011f40ae8260cfb)
2014-01-15ecc: Fix _gcry_mpi_ec_p_new to allow secp256k1.NIIBE Yutaka1-1/+1
* mpi/ec.c (_gcry_mpi_ec_p_new): Remove checking a!=0. * tests/t-mpi-point.c (context_alloc): Remove two spurious tests. -- It is no problem when a==0. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2014-01-13ecc: Make a macro shorter.Werner Koch1-11/+11
* src/mpi.h (MPI_EC_TWISTEDEDWARDS): Rename to MPI_EC_EDWARDS. CHnage all users. * cipher/ecc-curves.c (domain_parms): Add parameters for Curve3617 as comment. * mpi/ec.c (dup_point_twistededwards): Rename to dup_point_edwards. (add_points_twistededwards): Rename to add_points_edwards. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-12-18Change utf-8 copyright characters to '(C)'Jussi Kivilinna10-10/+10
cipher/blowfish-amd64.S: Change utf-8 encoded copyright character to '(C)'. cipher/blowfish-arm.S: Ditto. cipher/bufhelp.h: Ditto. cipher/camellia-aesni-avx-amd64.S: Ditto. cipher/camellia-aesni-avx2-amd64.S: Ditto. cipher/camellia-arm.S: Ditto. cipher/cast5-amd64.S: Ditto. cipher/cast5-arm.S: Ditto. cipher/cipher-ccm.c: Ditto. cipher/cipher-cmac.c: Ditto. cipher/cipher-gcm.c: Ditto. cipher/cipher-selftest.c: Ditto. cipher/cipher-selftest.h: Ditto. cipher/mac-cmac.c: Ditto. cipher/mac-gmac.c: Ditto. cipher/mac-hmac.c: Ditto. cipher/mac-internal.h: Ditto. cipher/mac.c: Ditto. cipher/rijndael-amd64.S: Ditto. cipher/rijndael-arm.S: Ditto. cipher/salsa20-amd64.S: Ditto. cipher/salsa20-armv7-neon.S: Ditto. cipher/serpent-armv7-neon.S: Ditto. cipher/serpent-avx2-amd64.S: Ditto. cipher/serpent-sse2-amd64.S: Ditto. -- Avoid use of '©' for easier parsing of source for copyright information. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-12-16Change dummy variable in mpih-div.c to mpi_limb_t typeJussi Kivilinna1-2/+2
* mpi/mpih-div.c (_gcry_mpih_mod_1, _gcry_mpih_divmod_1): Change dummy variable to 'mpi_limb_t' type from 'int'. -- Patch attempts to fix problem reported by Matthias Wachs: while updating our buildbots I got another compile error: On a OS X machine: Darwin luke.net.in.tum.de 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64 /bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -I/opt/local/include -I/opt/local/include -g -O2 -Wall -MT mpih-div.lo -MD -MP -MF .deps/mpih-div.Tpo -c -o mpih-div.lo mpih-div.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../src -I../src -I/opt/local/include -I/opt/local/include -g -O2 -Wall -MT mpih-div.lo -MD -MP -MF .deps/mpih-div.Tpo -c mpih-div.c -fno-common -DPIC -o .libs/mpih-div.o mpih-div.c: In function '_gcry_mpih_mod_1': mpih-div.c:183: error: unsupported inline asm: input constraint with a matching output constraint of incompatible type! make[2]: *** [mpih-div.lo] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 The new x86-64 inline assembly for MPI expects outputs to be limb sized variables (64-bit), but mpi/mpih-div.c was using 32-bit dummy variable. Appearently this mismatch between assembly output and variable sizes does not fail on every platform. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-12-12Remove macro hacks for internal vs. external functions. Part 2 and last.Werner Koch6-53/+54
* src/visibility.h: Remove remaining define/undef hacks for symbol visibility. Add macros to detect the use of the public functions. Change all affected functions by replacing them by the x-macros. * src/g10lib.h: Add internal prototypes. (xtrymalloc, xtrycalloc, xtrymalloc_secure, xtrycalloc_secure) (xtryrealloc, xtrystrdup, xmalloc, xcalloc, xmalloc_secure) (xcalloc_secure, xrealloc, xstrdup, xfree): New macros. -- The use of xmalloc/xtrymalloc/xfree is a more common pattern than the gcry_free etc. functions. Those functions behave like those defined by C and thus for better readability we use these macros and not the underscore prefixed functions. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-12-05Remove macro hacks for internal vs. external functions. Part 1.Werner Koch13-136/+127
* src/visibility.h: Remove almost all define/undef hacks for symbol visibility. Add macros to detect the use of the public functions. Change all affected functions by prefixing them explicitly with an underscore and change all internal callers to call the underscore prefixed versions. Provide convenience macros from sexp and mpi functions. * src/visibility.c: Change all functions to use only gpg_err_code_t and translate to gpg_error_t only in visibility.c. -- The use of the macro magic made if hard to follow the function calls in the source. It was not easy to see if an internal or external function (as defined by visibility.c) was called. The change is quite large but hopefully makes Libgcrypt easier to maintain. Some function have not yet been fixed; this will be done soon. Because Libgcrypt does no make use of any other libgpg-error using libraries it is useless to always translate between gpg_error_t and gpg_err_code_t (i.e with and w/o error source identifier). This translation has no mostly be moved to the function wrappers in visibility.c. An additional advantage of using gpg_err_code_t is that comparison can be done without using gpg_err_code(). I am sorry for that large patch, but a series of patches would actually be more work to audit. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-12-04mpi: add inline assembly for x86-64Jussi Kivilinna1-0/+63
* mpi/longlong.h [__x86_64] (add_ssaaaa, sub_ddmmss, umul_ppmm) (udiv_qrnnd, count_leading_zeros, count_trailing_zeros): New. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-12-04mpi: fix gcry_mpi_powm for negative base.NIIBE Yutaka1-2/+2
* mpi/mpi-pow.c (gcry_mpi_powm) [USE_ALGORITHM_SIMPLE_EXPONENTIATION]: Fix for the case where BASE is negative. * tests/mpitests.c (test_powm): Add a test case of (-17)^6 mod 19. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2013-12-03Add aarch64 (arm64) mpi assemblyJussi Kivilinna8-0/+514
* mpi/aarch64/mpi-asm-defs.h: New. * mpi/aarch64/mpih-add1.S: New. * mpi/aarch64/mpih-mul1.S: New. * mpi/aarch64/mpih-mul2.S: New. * mpi/aarch64/mpih-mul3.S: New. * mpi/aarch64/mpih-sub1.S: New. * mpi/config.links [host=aarch64-*-*]: Add configguration for aarch64 assembly. * mpi/longlong.h [__aarch64__] (add_ssaaaa, sub_ddmmss, umul_ppmm) (count_leading_zeros): New. -- Add preliminary aarch64 assembly implementations for mpi. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-12-02ecc: Use constant time point operation for Twisted Edwards.Werner Koch1-4/+23
* mpi/ec.c (_gcry_mpi_ec_mul_point): Try to do a constant time operation if needed. * tests/benchmark.c (main): Add option --use-secmem. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-12-02ecc: Fix gcry_mpi_ec_curve_point for Weierstrass.Werner Koch1-10/+18
* mpi/ec.c (_gcry_mpi_ec_curve_point): Use correct equation. (ec_pow3): New. (ec_p_init): Always copy B. -- The code path was obviously never tested. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-12-02mpi: Introduce 4 user flags for gcry_mpi_t.Werner Koch1-2/+25
* src/gcrypt.h.in (GCRYMPI_FLAG_USER1, GCRYMPI_FLAG_USER2) (GCRYMPI_FLAG_USER3, GCRYMPI_FLAG_USER4): New. * mpi/mpiutil.c (gcry_mpi_set_flag, gcry_mpi_clear_flag) (gcry_mpi_get_flag, _gcry_mpi_free): Implement them. (gcry_mpi_set_opaque): Keep user flags. -- The space for the flags in the MPI struct is free and thus we can help applications to make use of some flags. This is for example useful to indicate that an MPI needs special processing before use. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-11-29Fix armv3 compile errorVladimir 'φ-coder/phcoder' Serbinenko1-1/+1
* mpi/longlong.h [__arm__ && __ARM_ARCH < 4] (umul_ppmm): Use __AND_CLOBBER_CC instead of __CLOBBER_CC. -- ARMv3 code uses __CLOBBER_CC at the end of clobber list while it should have been __AND_CLOBBER_CC. [jk: add changelog, rebase on libgcrypt repository] Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-11-29longlong.h on mips with clangVladimir 'φ-coder/phcoder' Serbinenko1-1/+2
* mpi/longlong.h [__mips__]: Use C-language version with clang. -- clang doesn't recognise =l / =h assembly operand specifiers but apparently handles C version well. [jk: add changelog, rebase on libgcrypt repository, reformat changed line so it does not go over 80 characters] Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-11-05ecc: Fully implement Ed25519 compression in ECDSA mode.Werner Koch1-2/+6
* src/ec-context.h (mpi_ec_ctx_s): Add field FLAGS. * mpi/ec.c (ec_p_init): Add arg FLAGS. Change all callers to pass it. * cipher/ecc-curves.c (point_from_keyparam): Add arg EC, parse as opaque mpi and use eddsa decoding depending on the flag. (_gcry_mpi_ec_new): Rearrange to parse Q and D after knowing the curve. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-10-29Typo fix.Werner Koch1-1/+1
--
2013-10-24ecc: Change algorithm for Ed25519 x recovery.Werner Koch1-1/+1
* cipher/ecc-eddsa.c (scanval): Add as temporary hack. (_gcry_ecc_eddsa_recover_x): Use the algorithm from page 15 of the paper. Return an error code. (_gcry_ecc_eddsa_decodepoint): Take care of the error code. * mpi/mpi-mul.c (gcry_mpi_mulm): Use truncated division. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-10-23mpi: enable assembler on all arm architecturesDmitry Eremin-Solenikov7-18/+13
* mpi/config.links: remove check for arm >= v6 * mpi/armv6 => mpi/arm: rename directory to reflect that is is generic enough -- MPI ARM assembly do not depend on CPU being armv6. Verified on PXA255: Before: Algorithm generate 100*sign 100*verify ------------------------------------------------ RSA 1024 bit 3990ms 57980ms 1680ms RSA 2048 bit 59620ms 389430ms 5690ms RSA 3072 bit 535850ms 1223200ms 12000ms RSA 4096 bit 449350ms 2707370ms 20050ms After: Algorithm generate 100*sign 100*verify ------------------------------------------------ RSA 1024 bit 2190ms 13730ms 320ms RSA 2048 bit 12750ms 67640ms 810ms RSA 3072 bit 110520ms 166100ms 1350ms RSA 4096 bit 100870ms 357560ms 2170ms Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> [ jk: ARMv6 => ARM in header comments ]
2013-10-23mpi: Fix scanning of negative SSH formats and add more tests.Werner Koch2-67/+67
* mpi/mpicoder.c (gcry_mpi_scan): Fix sign setting for SSH format. * tests/t-convert.c (negative_zero): Test all formats. (check_formats): Add tests for PGP and scan tests for SSH and USG. * src/gcrypt.h.in (mpi_is_neg): Fix macro. * mpi/mpi-scan.c (_gcry_mpi_getbyte, _gcry_mpi_putbyte): Comment out these unused functions. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-10-22mpi: allow building with clang on ARMJussi Kivilinna1-14/+13
* mpi/longlong.h [__arm__] (add_ssaaaa, sub_ddmmss, umul_ppmm) (count_leading_zeros): Do not cast assembly output arguments. [__arm__] (umul_ppmm): Remove the extra '%' ahead of assembly comment. [_ARM_ARCH >= 4] (umul_ppmm): Use correct inputs and outputs instead of registers. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-10-17mpi: Do not clear the sign of the mpi_mod result.Werner Koch1-1/+0
* mpi/mpi-mod.c (_gcry_mpi_mod): Remove sign setting. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-10-17ecc: Support Weierstrass curves in gcry_mpi_ec_curve_point.Werner Koch1-2/+17
* mpi/ec.c (_gcry_mpi_ec_curve_point): Support MPI_EC_WEIERSTRASS.
2013-10-16mpi: mpi-pow improvement.NIIBE Yutaka1-0/+454
* mpi/mpi-pow.c (gcry_mpi_powm): New implementation of left-to-right k-ary exponentiation. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org> For the Yarom/Falkner flush+reload cache side-channel attack, we changed the code so that it always calls the multiplication routine (even if we can skip it to get result). This results some performance regression. This change is for recovering performance with efficient algorithm.
2013-10-02Fix errors when building with Clang on PPCDmitry Eremin-Solenikov1-20/+20
* mpi/longlong.h (add_ssaaaa, sub_ddmmss, count_leading_zeros, umul_ppmm): Do not cast asm output to USItype. Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
2013-10-01mpi: Fix gcry_mpi_neg.Werner Koch1-1/+3
* mpi/mpiutil.c (_gcry_mpi_neg): Copy U to W. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-09-30ecc: Prepare for future Ed25519 optimization.Werner Koch5-123/+142
* mpi/ec-ed25519.c: New but empty file. * mpi/ec-internal.h: New. * mpi/ec.c: Include ec-internal.h. (ec_mod): New. (ec_addm): Use ec_mod. (ec_mulm): Remove commented code. Use ec_mod. (ec_subm): Call simple sub. (ec_pow2): Use ec_mulm. (ec_mul2): New. (dup_point_weierstrass): Use ec_mul2. (dup_point_twistededwards): Add special case for a == -1. Use ec_mul2. (add_points_weierstrass): Use ec_mul2. (add_points_twistededwards): Add special case for a == -1. (_gcry_mpi_ec_curve_point): Ditto. (ec_p_init): Add hack to test Barrett functions. * src/ec-context.h (mpi_ec_ctx_s): Add P_BARRETT. * mpi/mpi-mod.c (_gcry_mpi_mod_barrett): Fix sign problem. Signed-off-by: Werner Koch <wk@gnupg.org>