Commit Graph

83 Commits

Author SHA1 Message Date
Keith Winstein 57c4904ed8 Switch to OpenSSL base64 routines 2012-07-20 16:00:21 -04:00
Keith Winstein 6616d936f6 Revert "Include config.h in base64.cc to get restrict def (may address #241)"
This reverts commit f4c8417672.

config.h was already included via base64.h, and problem is older autoconf.
2012-04-25 12:42:34 -04:00
Keith Winstein f4c8417672 Include config.h in base64.cc to get restrict def (may address #241) 2012-04-25 12:20:53 -04:00
Keith Winstein 22e7cf60d3 Keep aligned buffers around, instead of allocing on each packet
Fixes #238 github issue.
Also fixes armel "Bad alignment" problem.
2012-04-24 18:40:01 -04:00
Keith Winstein e8236c5fd4 Use AlignedBuffer stedda posix_memalign(). Should work on PPC OS X 10.5.
Fixes #233 github issue.
2012-04-22 22:46:49 -04:00
Keegan McAllister a289a2319e Preserve RLIMIT_CORE hard limit, and restore soft limit before exec
Closes #196.
2012-04-16 20:03:04 -04:00
Keegan McAllister c2a5941f88 Fall back to naive built-in byte-swap routines
EL5 lacks htobe64 and friends.  Using its byteswap.h requires an endianness
check in our headers, which is fragile and compiler-dependent.  It's a fair
amount of code [1], and is only useful on EL5.

So instead, let's include a fallback implementation of these functions, and use
it whenever we can't find the (now-)standard Linux or OS X routines.  The
fallback is endianness-independent and should work on any platform.

[1] https://github.com/rurban/mosh/commit/da1a5abd1e09f0c1e9295357bb480a643d9dc8e3
2012-04-15 23:42:15 -04:00
Keegan McAllister d2434d1a79 Check compiler support for -fno-default-inline and -pipe
clang was spewing warnings about the unrecognized -fno-default-inline.  (Oddly,
it warns only with -c, not when compiling directly to an executable.)  For
completeness we also check -pipe, even though clang is OK with that one.

It should be fine to omit either flag.  gcc -fno-default-inline drops the
implicit 'inline' annotation on functions defined inside a class scope, but
'inline' is only a hint anyway.  -fno-default-inline does not change linkage.
-pipe is merely a compile speed optimization.
2012-04-13 12:27:27 -04:00
Keegan McAllister 349e2d20c8 Use the hardening flags
Closes #79.
2012-04-13 12:25:09 -04:00
Keegan McAllister c354a69ee6 Test the Mosh crypto layer 2012-04-06 23:43:42 -04:00
Keegan McAllister d1c4b0a5d7 Test the OCB-AES reference implementation
This tests cryptographic primitives implemented by others.  It uses the same
interfaces and indeed the same compiled object code as the Mosh client and
server.  It does not particularly test any code written for the Mosh project.
2012-04-06 23:43:42 -04:00
Keegan McAllister 3b61581bcd Make aligned allocation without posix_memalign more robust
Instead of guessing the right function to use, we malloc() 15 bytes more than
we need, and compute the aligned offset within.  The AlignedBuffer class takes
care of passing the original pointer to free().
2012-04-06 23:43:41 -04:00
Keegan McAllister 0734640e14 Add a class for aligned buffers
This simplifies the core crypto routines, especially the error handling.  In
fact there was already one error path where we were failing to call free().
2012-04-06 23:43:41 -04:00
Benjamin Kaduk 424e2b53e1 Allow <sys/endian.h> as well as <endian.h>
On FreeBSD, the header which defines htobe64() is the sys/ variant,
unlike Linux.
2012-04-05 18:19:37 -04:00
Keegan McAllister b4ef664bc0 Kill the session after encrypting 2^47 blocks
"Both the privacy and the authenticity properties of OCB degrade as
 per s^2 / 2^128, where s is the total number of blocks that the
 adversary acquires.... In order to ensure that s^2 / 2^128 remains
 small, a given key should be used to encrypt at most 2^48 blocks (2^55
 bits or 4 petabytes)"

-- http://tools.ietf.org/html/draft-krovetz-ocb-03

We deem it unlikely that a legitimate user will send 4 PB through a Mosh
session.  If it happens, we simply kill the session.  The server and
client use the same key, so we actually need to die after 2^47 blocks.

Closes #77.
2012-03-31 16:19:33 -04:00
Keegan McAllister ba6387f36c Allow CryptoExceptions to be fatal 2012-03-31 16:19:33 -04:00
Keith Winstein edf6ec9052 Insert missing "if-then" instruction in OCB ARM assem so works with Thumb-2.
(closes #86 github issue)

(approved by Ted Krovetz, author of OCB reference implementation)
2012-03-31 14:31:22 -04:00
Quentin Smith 3b2604b81c Handle early gcc compilers that are missing __builtin_bswap64 or __builtin_ctz
(closes #84)
2012-03-26 21:26:33 -04:00
Quentin Smith d867a716b7 Use uintptr_t instead of size_t, since size_t is not guaranteed to be pointer-sized. 2012-03-26 21:18:55 -04:00
Keegan McAllister f46bad0aa0 Rename sse_alloc to aligned_alloc
SSE is x86-specific, but we use this function on all archs.
2012-03-26 20:07:34 -04:00
Quentin Smith 10332ec61f Handle platforms (like Darwin 9) that do not have posix_memalign 2012-03-23 02:17:29 -04:00
Keegan McAllister 9f38c76699 Explicitly disable dumping core (closes #72)
This is a precaution to avoid saving sensitive data to disk, e.g. session keys.
We expect that corefiles are not world readable, but they're still sitting on
the physical disk and it's safer just to disable creating them.

GitHub issue #71 deals with a similar concern.
2012-03-21 18:41:51 -04:00
Keith Winstein 40d69da5e6 Add PRNG reading from /dev/urandom
[Keegan: various small changes]
2012-03-19 23:12:07 -04:00
Keith Winstein df3eec1397 Allow explicit UDP port option, confine ports to range 60000..61000 2012-03-10 03:34:47 -05:00
Quentin Smith 17d6962af8 Check for proper byteorder functions
[andersk@mit.edu: Add byteorder.h to libmoshcrypto_a_SOURCES]
2012-03-07 03:05:36 -05:00
Anders Kaseorg aad760e7d6 Make warning CXXFLAGS configurable
This turns off -Werror by default except in the Debian package.
-Werror is inherently unportable and breaks things on OS X.  While it
can cause problems in Debian too, this is at least a little better.

It also turns off -pedantic in src/protobufs, because apparently
protoc output doesn’t compile with -pedantic on all platforms.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2012-03-07 03:05:35 -05:00
Keith Winstein ba6329e528 Better fix to alignment issue 2012-02-19 21:53:13 -05:00
Keith Winstein b06204e72b Fix alignment problem under clang (per nelhage) 2012-02-19 21:48:59 -05:00
Anders Kaseorg 689eedc271 Compile without --std=c++0x
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2012-02-17 21:29:51 -05:00
Anders Kaseorg 6c52c1d306 Purge ‘using namespace std’ from header files
std::bind and boost::lambda::bind don’t mix.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2012-02-17 20:22:12 -05:00
Anders Kaseorg af649a035c Add missing #includes
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2012-02-17 19:24:51 -05:00
Keith Winstein 3781a290c8 Add copyright/license notices 2012-02-06 20:52:48 -05:00
Keith Winstein 38c9e99882 Separate modules by subdirectory 2012-02-06 18:26:45 -05:00