Commit Graph

601 Commits

Author SHA1 Message Date
Brian Warner
bfa429cc5a munin/wormhhole_transit: fix key name 2016-05-26 18:04:52 -07:00
Brian Warner
4b840a37fe munin: show events-per-hour, not events-per-second 2016-05-26 17:59:42 -07:00
Brian Warner
6aa1747b46 munin: fix dbfile finding 2016-05-26 17:54:43 -07:00
Brian Warner
6578d39c9b quick draft of munin plugins 2016-05-26 17:46:16 -07:00
Brian Warner
1c963170c3 wormhole-server: add count-channels, count-events 2016-05-26 17:45:41 -07:00
Brian Warner
56fec496e2 send transit abilities to far end too, for the future
This will allow a future peer to figure out what transit modes we can
and cannot do, and thus avoid spinning up expensive modes that we won't
be able to use (e.g. WebRTC).
2016-05-26 16:26:00 -07:00
Brian Warner
db31ffe075 minor shuffles 2016-05-26 15:49:45 -07:00
Brian Warner
7acb68d2ee allow WelcomeError to interrupt input_code() 2016-05-26 15:38:19 -07:00
Brian Warner
905ec05696 fix welcome-error signalling
The handler was calling _signal_error() incorrectly.
2016-05-26 15:37:24 -07:00
Brian Warner
80c88387ef improve formatting of error messages 2016-05-26 15:36:44 -07:00
Brian Warner
2cf11e85d3 un-pin Twisted, require autobahn >=0.14.1
The new autobahn release removes the Twisted pin, so we no longer need
one. Depend on the new autobahn to flush out any environments that are
still using the old one (and thus can't use the current Twisted).

Thanks https://github.com/crossbario/autobahn-python/issues/680 !
2016-05-26 13:01:43 -07:00
Brian Warner
19702e01ac make send pay attention to receiver errors correctly
Errors like "Refusing to overwrite existing file" would leave the sender
hanging, because it was looking for the "error" key in the wrong place.
2016-05-25 22:44:18 -07:00
Brian Warner
de627ccbef fix --dump-timing= on py3, wants a text-mode file 2016-05-25 22:06:26 -07:00
Brian Warner
06d2a0be68 update docs 2016-05-25 20:58:53 -07:00
Brian Warner
708bcf36d4 INCOMPATIBILITY: send+expect hash of data after xfer
This enhances the ACK that wormhole-receive returns when it finishes
receiving all the data to be a dictionary. The dict includes the SHA256
hash of everything it received, and the sender checks this for a match
before declaring the transfer to be a success. This guards against data
being shuffled somehow during transit.
2016-05-25 19:36:56 -07:00
Brian Warner
d8f6126916 transit.writeToFile: add hasher= argument 2016-05-25 19:35:50 -07:00
Brian Warner
01ec5fb2a6 rename test_transit_twisted.py, drop the twisted 2016-05-25 19:21:54 -07:00
Brian Warner
75877effef finish renaming "confirm" to "version" 2016-05-25 19:13:56 -07:00
Brian Warner
dcdddc9d60 INCOMPATIBILITY: rename "confirm" phase to "version"
This better reflects the purpose of the message. Key confirmation is a
side-effect.

This patch only changes the "phase:" name and the key-derivation string.
A subsequent patch will modify the function and variable names to match.
2016-05-25 19:13:56 -07:00
Brian Warner
424474cd7e remove unused _derive_confirmation_key() 2016-05-25 19:13:56 -07:00
Brian Warner
7f43561a50 INCOMPATIBILITY: change "confirm" message to include version dict
This gives the two Wormholes a way to signal capabilities to each other,
before the applications start sending their own messages.
2016-05-25 18:27:37 -07:00
Brian Warner
e1c488247f remove redundant test 2016-05-25 18:27:24 -07:00
Brian Warner
edebf4d787 update events.dot with check-verifier logic 2016-05-25 18:06:08 -07:00
Brian Warner
5553729a87 w.verify() now stalls until confirmation message is checked
If it succeeds, you get back the verifier string, which can be compared
against the other side. If it fails, the wormhole code didn't match.
2016-05-25 18:05:02 -07:00
Brian Warner
8b56892a76 drop peer messages if we're closing
This should remove a few Unhandled Errors when the code was wrong.
2016-05-25 16:29:56 -07:00
Brian Warner
a251e58967 oops, fix tests to use /v1 too 2016-05-25 00:34:13 -07:00
Brian Warner
1fabf18f0e INCOMPATIBILITY: move relay url to /v1
This should make it cleaner to add a /v2 in the future.
2016-05-25 00:29:23 -07:00
Brian Warner
f2050c5fd4 internal renaming: hint objects vs hint structs 2016-05-25 00:23:12 -07:00
Brian Warner
7aa55e6b65 INCOMPATIBILITY: deliver hints as JSON, not strings
The file-send protocol now sends a "hints-v1" key in the "transit"
message, which contains a list of JSON data structures that describe the
connection hints (a mixture of direct, tor, and relay hints, for now).
Previously the direct/tor and relay hints were sent in different keys,
and all were sent as strings like "tcp:hostname:1234" which had to be
parsed by the recipient.

The new structures include a version string, to make it easier to add
new types in the future. Transit logs+ignores hints it cannot
understand.
2016-05-25 00:11:17 -07:00
Brian Warner
afdbbe84c3 cmd_send: allow multiple things in a single message 2016-05-24 19:30:55 -07:00
Brian Warner
8e7c6f16cb cmd_receive: tolerate unrecognized messages
at the expense of not failing quickly when the sender doesn't send an
offer
2016-05-24 19:30:21 -07:00
Brian Warner
1b5f3e125e cmd_receive: add underscore prefix to all internal methods 2016-05-24 19:14:56 -07:00
Brian Warner
812fd0b4da INCOMPATIBILITY: send "transit" message before offer/answer
In the future, both sides should expect to receive "transit" messages at
any time, and they will add to the list of hints that they should try.
For now, each side only sends a single transit message, before they send
the offer (sender) or answer (receiver).
2016-05-24 18:59:04 -07:00
Brian Warner
1a9e565fc3 cmd_send: turn into a self-contained class
This will make it easier to maintain state.
2016-05-24 17:44:41 -07:00
Brian Warner
ac1db705fe INCOMPATIBLE CHANGE: put offer/answer in their own keys
This moves us slowly towards a file-transfer protocol that exchanges
multiple messages, with a single offer (sender->receiver) and
answer (receiver->sender), and one or more connection hint messages (in
either direction) that appear gradually over time as connection
providers come online.

At present the protocol still expects the whole hint list to be present
in the offer/answer message.
2016-05-24 17:32:30 -07:00
Brian Warner
96f25ec7a2 rename phase1 to offer/answer
rearrange cmd_send a bit to do less before the Wormhole is built
2016-05-24 16:41:13 -07:00
Brian Warner
2c7e1529dd Merge branch 'remove-wormhole.twisted' 2016-05-24 16:27:12 -07:00
Brian Warner
0414051df2 remove wormhole/twisted/ 2016-05-24 16:26:17 -07:00
Brian Warner
c06bc83d3f remove unused twisted/eventual.py 2016-05-24 16:25:37 -07:00
Brian Warner
c218b939c0 move wormhole.twisted.tor_manager up to wormhole/ 2016-05-24 16:25:12 -07:00
Brian Warner
7140565b99 move wormhole.twisted.ipaddrs up to wormhole/ 2016-05-24 16:23:52 -07:00
Brian Warner
0e1a4dd513 move wormhole.twisted.transit up to wormhole.transit 2016-05-24 16:22:37 -07:00
Brian Warner
4b3d53ba4e log+ignore unrecognized phase messages
This should enable forwards-compatibility with clients which send extra
data, like a pre-PAKE "auxdata" message that hints we should spin up a
tor client (because they can connect to it) while we're waiting for the
user to type in the wormhole code.
2016-05-24 16:15:43 -07:00
Brian Warner
f6a5581f92 move events diagram (.dot) into docs/ 2016-05-24 16:15:19 -07:00
Brian Warner
783cd984f6 add 'coverage' environment for tox 2016-05-24 16:03:39 -07:00
Brian Warner
88696dd0ed INCOMPATIBLE CHANGE: Merge branch 'new-proto'
This is a very large branch that replaces many aspects of the wormhole
protocol. Clients that use code before this change (including the 0.7.6
release) will not be able to talk to clients after this change. They
won't even be able to talk to the relay.

Things that have changed:

* The server protocol has changed. A new public relay has been set up,
  which listens on a different port.
* The blocking (non-Twisted) implementation has been removed. It will
  return, built on top of the Twisted falvor, using the Crochet library.
* Persistence (state = wormhole.serialize()) has been removed. It will
  return, in a form that works better for constantly-evolving Wormholes.
* API changes:
  * 'from wormhole.wormhole import wormhole', rather than from
    wormhole.twisted.transcribe (this is likely to change further)
  * Create the Wormhole with the wormhole() function, rather than the
    Wormhole() class constructor. You *must* pass reactor= to get a
    Twisted-flavor wormhole (omitting reactor= will, in the future, give
    you a blocking-flavor wormhole).
  * w.get() and w.send(data), instead of w.get_data(phase) and
    w.send_data(data, phase). Wormhole is now a sequential record pipe,
    rather than a named-record channel. Internally, these APIs produce
    numbered phases.
  * verifier = yield w.verify(), instead of get_verifier(). The new
    verify() defers until the connection has received the
    key-confirmation message, and will errback with WrongPasswordError
    if that message doesn't match.
  * w.derive_key(purpose, length) now requires a length, instead of
    defaulting to the NaCl SecretBox key size.
  * w.close() now always defers until all outbound messages have been
    delivered to the relay server, and the connection has closed. It
    always returns a Deferred. Application code should close() before
    calling os.exit(), to make sure your ACKs have been delivered.
  * Any errors (WrongPasswordError, websocket dropped early) will cause
    all pending Deferreds to errback, the nameplate and mailbox will be
    released, and the websocket connection will be closed. w.close() is
    still the right thing to call after an error, as it will defer until
    the connection is finally dropped.
* The Wormhole object starts working as soon as wormhole() is called,
  rather than waiting until an API method is invoked.
* There are more opportunities for parallelism, which should avoid a few
  roundtrips and make things faster.
* We now use SPAKE2-0.7, which changes the key-derivation function to
  one that hopefully matches a proposed SJCL implementation, enabling
  future interoperability between python and javascript clients.
* We derive per-message keys differently, to prevent a particular kind
  of reflection attack that was mitigated differently before.
* The server now manages "nameplates" and "mailboxes" separately (the
  old server/protocol didn't make a distinction). A "nameplate" is a
  channel with a short name (the number from the wormhole code) and
  which only contains one value (a pointer to a mailbox). A "mailbox"
  has a long random name and contains the usual queue of messages being
  sent from one client to the other. This lets us drop the nameplate as
  soon as the second side has connected (and switches to the mailbox),
  so long file transfers don't hog the short wormhole codes for longer
  than necessary.
* There is room for "nameplate attributes", which will (in the future)
  be used to indicate the wordlist being used for the wormhole code,
  allowing tab-completion for alternate wordlists, including languages
  other than english.
* The new expectation is that nameplates and mailboxes will be deleted
  if nobody is connected to them for a while (although this is not yet
  implemented in the server). Applications which need extended offline
  persistent channels will be able to ask for them when claiming the
  nameplate.
2016-05-24 15:26:26 -07:00
Brian Warner
90e6d23c17 change server default port to match new public relay 2016-05-24 14:12:10 -07:00
Brian Warner
30ab940034 INCOMPATIBLE: change derivation of phase keys to include side
Previously the encryption key used for "phase messages" (anything sent
from one side to the other, protected by the shared PAKE-generated
session key) was derived just from the session key and the phase name.
The two sides would use the same key for their first message (but with
random, thus different, nonces).

This uses the sending side's string (a random 5-byte/10-character hex
string) in the derivation process too, so the two sides use different
keys. This gives us an easy way to reject reflected messages. We already
ignore messages that claim to use a "side" which matches our own (to
ignore server echoes of our own outbound messages). With this change, an
attacker (or the server) can't swap in the payload of an outbound
message, change the "side" to make it look like a peer message, and then
let us decrypt it correctly.

It also changes the derivation function to combine the phase and side
values safely. This didn't matter much when we only had one
externally-provided string, but with two, there's an opportunity for
format confusion if they were combined with a simple delimiter. Now we
hash both values before concatenating them.

This breaks interoperability with clients from before this change. They
will always get WrongPasswordErrors.
2016-05-24 13:47:15 -07:00
Brian Warner
97c5d08b6a internally, _derive_key now takes bytes
The w.derive_key(purpose) API still requires unicode.
2016-05-24 13:31:03 -07:00
Brian Warner
7c8e5fb062 factor out key-derivation, prepare for change 2016-05-24 13:26:08 -07:00