Commit Graph

132 Commits

Author SHA1 Message Date
Yawning Angel
e993003792 Clean import of keccak-tiny (https://github.com/coruus/keccak-tiny)
As of commit: 64b6647514212b76ae7bca0dea9b7b197d1d8186
2015-12-18 20:32:10 +00:00
cypherpunks
824a6a2a90 Replace usage of INLINE with inline
This patch was generated using;

  sed -i -e "s/\bINLINE\b/inline/" src/*/*.[ch] src/*/*/*.[ch]
2015-12-15 11:34:00 -05:00
Nick Mathewson
7186e2a943 Merge remote-tracking branch 'public/feature17694_strongest_027' 2015-12-10 09:02:10 -05:00
Nick Mathewson
2259de0de7 Always hash crypto_strongest_rand() along with some prng
(before using it for anything besides feeding the PRNG)

Part of #17694
2015-12-08 10:54:42 -05:00
Yawning Angel
b71f6d6a47 Fix SipHash-2-4 performance for non multiple of 8 buffers.
Code cribbed from Andrew Moon's Public Domain SipHash-2-4
implementation (which IMO is also cleaner).

Fixes bug 17544.
2015-11-05 18:21:43 +00:00
Sebastian Hahn
98da122ab4 Don't enable SSE2 on X86-64.
This removes a comment presumably introduced for debugging that was left
in accidentally. Bug not in any released version of Tor. Fixes bug
17092.
2015-09-16 14:08:38 +02:00
Nick Mathewson
81e3deeb54 Fix an alignment issue in our extensions to ed25519_donna
Apparently this only happens with clang (or with some particular
clang versions), and only on i386.

Fixes 16970; bug not in any released Tor.

Found by Teor; fix from Yawning.
2015-09-04 09:30:59 -04:00
Nick Mathewson
53c99cce5e Add a comment about CID 1311630 and why we won't worry about it. 2015-09-01 09:43:37 -04:00
Nick Mathewson
988d208814 Update to latest trunnel 2015-08-18 09:47:36 -04:00
Yawning Angel
971eba0fcd Fixup: Force enable SSE2 before undefining ALIGN if SSE2 is disabled.
This should fix the x86 build, since variables that require 16 byte
alignment will now actually be 16 byte aligned.
2015-08-17 19:21:51 +00:00
Yawning Angel
a77616f605 Enable ed25519-donna's SSE2 code when possible for 32 bit x86.
This probably requires the user to manually set CFLAGS, but should
result in a net gain on 32 bit x86. Enabling SSE2 support would be
possible on x86_64, but will result in slower performance.

Implements feature #16535.
2015-08-17 18:41:41 +00:00
Yawning Angel
78fad380cd Use ed25519-donna's batch verification support when applicable.
The code was always in our Ed25519 wrappers, so enable it when using
the ed25519-donna backend, and deal with the mocking related
crypto_rand silliness.

Implements feature 16533.
2015-08-12 16:01:28 +00:00
Yawning Angel
c0106118fa Fix ed25519-donna with SSP on non-x86.
The only reason 16 byte alignment is required is for SSE2 load and
store operations, so only align datastructures to 16 byte boundaries
when building with SSE2 support.

This fixes builds with GCC SSP on platforms that don't have special
case code to do dynamic stack re-alignment (everything not x86/x86_64).

Fixes bug #16666.
2015-07-27 00:49:11 +00:00
Nick Mathewson
3323615dd2 Re-run trunnel to capture change for msvc. 2015-07-23 12:05:06 -04:00
Nick Mathewson
b06759edfd Try to convince coverity not to worry about this loop either 2015-07-12 17:01:17 -04:00
Nick Mathewson
7892aff3a8 Try to convince coverity not to worryh about this loop 2015-07-12 17:00:45 -04:00
Nick Mathewson
920c63877c Tell coverity to tolerate ed25519_verify 2015-07-12 16:59:37 -04:00
Nick Mathewson
d835264690 Disable -Wstack-protector diagnostics in curve25519-donna-helpers.h
This was causing a false positive on our arm builders.
2015-07-12 14:48:48 -04:00
Nick Mathewson
3301b7a1af Repair make dist-check 2015-07-09 13:04:53 -04:00
Yawning Angel
be113f0bce Add Curve25519->Ed25519 support to ed25519-donna (Not yet used).
This needs to be done to allow for the possibility of removing the
ref10 code at a later date, though it is not performance critical.
When integrated by kludging it into tor, it passes unit tests, and is
twice as fast.
2015-07-06 09:48:00 +00:00
Yawning Angel
b7aa3074fc Add blinding support to ed25519-donna (Not yet used).
Integrating it the "wrong" way into common/crypto_ed25519.c passes
`make check`, and there appear to be some known answer tests for this,
so I assume I got it right.

Blinding a public key goes from 139.10 usec to 70.78 usec using
ed25519-donna (NB: Turboboost/phase of moon), though the code isn't
critical path, so supporting it is mostly done for completeness.
2015-07-06 09:44:43 +00:00
Yawning Angel
0f3eeca9b8 Integrate ed25519-donna (Not yet used).
Integrate ed25519-donna into the build process, and provide an
interface that matches the `ref10` code.  Apart from the blinding and
Curve25519 key conversion, this functions as a drop-in replacement for
ref10 (verified by modifying crypto_ed25519.c).

Tests pass, and the benchmarks claim it is quite a bit faster, however
actually using the code requires additional integration work.
2015-07-06 09:40:28 +00:00
Yawning Angel
7b10741be4 Import Andrew Moon's ed25519-donna.
This is a clean copy of ed25519-donna as of commit:

  8757bd4cd209cb032853ece0ce413f122eef212c

https://github.com/floodyberry/ed25519-donna
2015-07-06 08:00:01 +00:00
Nick Mathewson
f491aed8d0 Whoops; fix linux build again 2015-06-27 22:41:39 -04:00
Nick Mathewson
229bb7e50f Fix some compilation issues. 2015-06-27 14:27:00 -04:00
Nick Mathewson
b9b658e727 Add the openssh 6.8p1 readpassphrase implementation
This way glibc users don't have to fall back to getpass.

Windows users are still out of luck
2015-06-17 10:41:22 -04:00
Nick Mathewson
8d44ce910d Add readpassphrase.c in src/ext
This is taken verbatim from openssh 6.8p1, which appears to have
lightly tweaked it from the openbsd version.
2015-06-17 10:19:40 -04:00
Nick Mathewson
e045c3e1e8 Update trunnel code.
This gets the minor change in trunnel 1.4.1, which should avoid
deadcode warnings from Coverity.
2015-05-28 12:44:52 -04:00
Nick Mathewson
190ed66b06 Merge remote-tracking branch 'origin/maint-0.2.6' 2015-03-23 09:25:35 -04:00
Nick Mathewson
c113544a94 Merge remote-tracking branch 'public/bug15436_025' into maint-0.2.6 2015-03-23 09:25:15 -04:00
Yawning Angel
732f522a42 Fix unaligned access in SipHash-2-4.
The compiler is allowed to assume that a "uint64_t *" is aligned
correctly, and will inline a version of memcpy that acts as such.

Use "uint8_t *", so the compiler does the right thing.
2015-03-23 09:20:02 -04:00
cypherpunks
5176f6f103 Remove relative paths to header files.
The paths are already in the directory search path of the compiler therefore no
need to include them in the source code.
2015-03-14 13:00:05 -04:00
Nick Mathewson
7620c613e8 Have tinytest tolerate systems where char has > 8 bytes
CID 1064418
2015-02-17 08:40:55 -05:00
Nick Mathewson
f6afb04abb Use HT_BUCKET_NUM_ in more places
(patch from sysrqb)
2015-01-29 15:10:23 -05:00
Nick Mathewson
5faa017b86 Merge remote-tracking branch 'public/ticket11737' 2015-01-29 15:09:55 -05:00
Nick Mathewson
f54e54b0b4 Bump copyright dates to 2015, in case someday this matters. 2015-01-02 14:27:39 -05:00
Nick Mathewson
a3dafd3f58 Replace operators used as macro arguments with OP_XX macros
Part of fix for 13172
2014-11-12 13:28:07 -05:00
Nick Mathewson
6344345140 Add correctness assertions for hashtable iteration
This is meant to prevent memory corruption bugs from doing
unspeakable infinite-loop-like things to the hashtables.  Addresses
ticket 11737.  We should disable these if they turn out to be
expensive.
2014-11-06 13:57:17 -05:00
Nick Mathewson
e20fc286c0 Re-run latest git trunnel to get fix from teor for #13577 2014-10-31 08:56:14 -04:00
teor
13298d90a9 Silence spurious clang warnings
Silence clang warnings under --enable-expensive-hardening, including:
  + implicit truncation of 64 bit values to 32 bit;
  + const char assignment to self;
  + tautological compare; and
  + additional parentheses around equality tests. (gcc uses these to
    silence assignment, so clang warns when they're present in an
    equality test. But we need to use extra parentheses in macros to
    isolate them from other code).
2014-10-30 22:34:46 +11:00
Nick Mathewson
fcdcb377a4 Add another year to our copyright dates.
Because in 95 years, we or our successors will surely care about
enforcing the BSD license terms on this code.  Right?
2014-10-28 15:30:16 -04:00
Nick Mathewson
a0be2f1350 Automake syntax error :/ 2014-09-29 10:10:37 -04:00
Nick Mathewson
9455f45ae3 Add missing ed25519_ref10 headers to NOINST_HEADERS. 2014-09-29 10:10:08 -04:00
teor
b7eab94a90 Stop ed25519 8-bit signed left shift overflowing
Standardise usage in ge_scalarmult_base.c for 1 new fix.
2014-09-28 20:44:00 -04:00
Nick Mathewson
6129ff320e Use SHL{8,32,64} in ed25519/ref10 to avoid left-shifting negative values
This helps us avoid undefined behavior. It's based on a patch from teor,
except that I wrote a perl script to regenerate the patch:

  #!/usr/bin/perl -p -w -i

  BEGIN { %vartypes = (); }

  if (/^[{}]/) {
      %vartypes = ();
  }

  if (/^ *crypto_int(\d+) +([a-zA-Z_][_a-zA-Z0-9]*)/) {
      $vartypes{$2} = $1;
  } elsif (/^ *(?:signed +)char +([a-zA-Z_][_a-zA-Z0-9]*)/) {
      $vartypes{$1} = '8';
  }

  # This fixes at most one shift per line. But that's all the code does.
  if (/([a-zA-Z_][a-zA-Z_0-9]*) *<< *(\d+)/) {
      $v = $1;
      if (exists $vartypes{$v}) {
  	s/$v *<< *(\d+)/SHL$vartypes{$v}($v,$1)/;
      }
  }

  # remove extra parenthesis
  s/\(SHL64\((.*)\)\)/SHL64\($1\)/;
  s/\(SHL32\((.*)\)\)/SHL32\($1\)/;
  s/\(SHL8\((.*)\)\)/SHL8\($1\)/;
2014-09-28 20:41:05 -04:00
teor
6b155dc1a6 Stop signed left shifts overflowing in ed25519: Macros
The macros let us use unsigned types for potentially overflowing left
shifts. Create SHL32() and SHL64() and SHL8() macros for convenience.
2014-09-28 20:38:12 -04:00
Nick Mathewson
27bd1ef100 Comment-out dead code in ed25519/ref10
There are some loops of the form

       for (i=1;i<1;++i) ...

And of course, if the loop index is initialized to 1, it will never
be less than 1, and the loop body will never be executed.  This
upsets coverity.

Patch fixes CID 1221543 and 1221542
2014-09-26 09:07:44 -04:00
Nick Mathewson
9190468246 Fix warnings on 32-bit builds.
When size_t is the most memory you can have, make sure that things
referring to real parts of memory are size_t, not uint64_t or off_t.

But not on any released Tor.
2014-09-25 17:50:13 -04:00
Nick Mathewson
1c5d680b3d Merge branch 'ed25519_ref10_squashed'
Conflicts:
	src/common/include.am
	src/ext/README
2014-09-25 15:11:34 -04:00
Nick Mathewson
46cda485bc Comments and tweaks based on review by asn
Add some documentation

Rename "derive" -> "blind"

Check for failure on randombytes().
2014-09-25 15:08:32 -04:00