Jason A. Donenfeld
Jason at zx2c4.com
Fri Dec 1 14:45:09 CET 2017
Some people have been asking me about delivering configurations to
users in the web browser. I usually try to keep sensitive crypto out
it struck me that in the absence of something better, commercial
providers might be tempted to generate private keys server side using
random(3) and send them to their poor users.
To preempt this mistake, I made this example code:
It generates a private key in the browser, makes a request to the
server with the corresponding public key, and then creates a
downloadable configuration file for the user. It's extremely simple.
It's certainly better than generating keys server side, though it does
come with these caveats:
- Curve25519, for deriving the public key, is compiled using
emscripten. Who knows what kind of code this actually generates, or
what all those optimization options wind up doing.
- You have to trust window.crypto.getRandomValues(). If you don't, you
could always hash together one block each of output from
window.crypto.getRandomValues() and some /dev/urandom data delivered
by the server. Or do that hilarious thing where you're asked to shake
your mouse around inside a box to "make some randomness", but please
don't actually do this; the 90s called and wants its DHTML snow flake
mouse trails back.
On the plus side, one could imagine some pretty easy-to-use
interfaces. Buttons like:
[Download .zip of configurations for all locations]
[Download .conf of us1] [Download .conf of nl1] [Download .conf of se1]
So, it's there now. Do with it what you will.
More information about the WireGuard