Re: [tor-dev] Proposal 332: Ntor protocol with extra data, version 3.

2021-07-16 Thread Trevor Perrin
On Fri, Jul 16, 2021 at 5:31 AM Ian Goldberg  wrote:
>
> On Tue, Jul 13, 2021 at 11:34:47AM -0700, Trevor Perrin wrote:
> > You also wanted to add an (optional) pre-shared key, which Noise supports:
> >
> > NKpsk0:
> >   <- s
> >   ...
> >   -> psk, e, es
> >   <- e, ee
>
> Out of curiosity, Trevor, what properties does this Noise protocol
> provide for low-entropy psk?

The Noise PSK is intended for 256-bit secrets, however:

 * A low-entropy (even malicious) PSK can't reduce the security of the
rest of the handshake.  I.e. NKpsk0 with a bad PSK has all the
security properties of NK.

 * The handshake will only complete successfully if both parties use
the same PSK.

This is *NOT* a PAKE: the legitimate recipient of the first NKpsk0
handshake message will be able to try offline guesses for the PSK.

Noise doesn't have a PAKE feature.  You could generically combine a
Noise handshake with an Oblivious PRF to produce a PAKE (like Hugo's
OPAQUE).  Integrating a "balanced" PAKE, like in OTR, would be more
complicated.


> If you want the protocol to work with Walking Onions, it needs to be
> *post-specified peer*.  That is, contrary to:
>
> > The client knows:
> >   * B: a public "onion key" for S
>
> The client will in fact _not_ know B in advance in a Walking Onions
> setting, but rather will learn it at the end of the handshake.

I don't know the requirements here, but fwiw here's what pre-specified
peer (NK or NK1) vs post-specified peer (NX) looks like for a Noise
handshake:

NK:
  <- s
  ...
  -> e, es
  <- e, ee

NX:
  -> e
  <- e, ee, s, es

Trevor
___
tor-dev mailing list
tor-dev@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev


Re: [tor-dev] Proposal 332: Ntor protocol with extra data, version 3.

2021-07-13 Thread Trevor Perrin
Hi Nick, you might look at the Noise framework:

http://noiseprotocol.org/noise.html

Noise has a naming scheme for "handshake patterns".  Ntor matches what
we call NK1.  Your new scheme I think matches NK (the 1 in NK1
indicates a "deferred" pattern where the DH operation that
authenticates the server is performed prior to the 2nd message rather
than the first).

NK1:
  <- s
  ...
  -> e
  <- e, ee, es


(read as: initiator has pre-knowledge of server's static public key s;
initiator sends their ephemeral in first message; responder sends
their ephemeral in second message, then performs the two 2 DH
operations, hashing them together and using the result for encrypting
future data).

In NK, the ephemeral-static DH is performed earlier so that the first
message's handshake payload can be encrypted:

NK:
  <- s
  ...
  -> e, es
  <- e, ee

You also wanted to add an (optional) pre-shared key, which Noise supports:

NKpsk0:
  <- s
  ...
  -> psk, e, es
  <- e, ee


Some advantages of Noise are that you could reuse existing libraries
and Noise's growing body of security analysis.

Also, we're working on KEM extensions for post-quantum, signatures,
and other things, so Noise might make it easier to evolve the protocol
(eg NK1 vs NK vs NKpsk0).

Trevor

On Mon, Jul 12, 2021 at 9:02 AM Nick Mathewson  wrote:
>
> ```
> Filename: 332-ntor-v3-with-extra-data.md
> Title: Ntor protocol with extra data, version 3.
> Author: Nick Mathewson
> Created: 12 July 2021
> Status: Open
> ```
>
> # Overview
>
> The ntor handshake is our current protocol for circuit
> establishment.
>
> So far we have two variants of the ntor handshake in use: the "ntor
> v1" that we use for everyday circuit extension (see `tor-spec.txt`)
> and the "hs-ntor" that we use for v3 onion service handshake (see
> `rend-spec-v3.txt`).  This document defines a third version of ntor,
> adapting the improvements from hs-ntor for use in regular circuit
> establishment.
>
> These improvements include:
>
>  * Support for sending additional encrypted and authenticated
>protocol-setup handshake data as part of the ntor handshake.  (The
>information sent from the client to the relay does not receive
>forward secrecy.)
>
>  * Support for using an external shared secret that both parties must
>know in order to complete the handshake.  (In the HS handshake, this
>is the subcredential.  We don't use it for circuit extension, but in
>theory we could.)
>
>  * Providing a single specification that can, in the future, be used
>both for circuit extension _and_ HS introduction.
>
> # The improved protocol: an abstract view
>
> Given a client "C" that wants to construct a circuit to a
> relay "S":
>
> The client knows:
>   * B: a public "onion key" for S
>   * ID: an identity for S, represented as a fixed-length
> byte string.
>   * CM: a message that it wants to send to S as part of the
> handshake.
>   * An optional "verification" string.
>
> The relay knows:
>   * A set of [(b,B)...] "onion key" keypairs.  One of them is
> "current", the others are outdated, but still valid.
>   * ID: Its own identity.
>   * A function for computing a server message SM, based on a given
> client message.
>   * An optional "verification" string. This must match the "verification"
> string from the client.
>
> Both parties have a strong source of randomness.
>
> Given this information, the client computes a "client handshake"
> and sends it to the relay.
>
> The relay then uses its information plus the client handshake to see
> if the incoming message is valid; if it is, then it computes a
> "server handshake" to send in reply.
>
> The client processes the server handshake, and either succeeds or fails.
>
> At this point, the client and the relay both have access to:
>   * CM (the message the client sent)
>   * SM (the message the relay sent)
>   * KS (a shared byte stream of arbitrary length, used to compute
> keys to be used elsewhere in the protocol).
>
> Additionally, the client knows that CM was sent _only_ to the relay
> whose public onion key is B, and that KS is shared _only_ with that
> relay.
>
> The relay does not know which client participated in the handshake,
> but it does know that CM came from the same client that generated
> the key X, and that SM and KS were shared _only_ with that client.
>
> Both parties know that CM, SM, and KS were shared correctly, or not
> at all.
>
> Both parties know that they used the same verification string; if
> they did not, they do not learn what the verification string was.
> (This feature is required for HS handshakes.)
>
> # The handshake in detail
>
> ## Notation
>
> We use the following notation:
>
>   * `|` -- concatenation
>   * `"..."` -- a byte string, with no terminating NUL.
>   * `ENCAP(s)` -- an encapsulation function.  We define this
>  as `htonll(len(s)) | s`.  (Note that `len(ENCAP(s)) = len(s) + 8`).
>   * `PARTITION(s, n1, n2, n3, ...)` -- a function that partitions a

Re: [tor-dev] [prop269] Further changes to the hybrid handshake proposal (and NTor)

2016-10-17 Thread Trevor Perrin
On Fri, Oct 14, 2016 at 2:45 PM, isis agora lovecruft
<i...@torproject.org> wrote:
>
> After discussion with John Schanck and Trevor Perrin over the last month,
> we've decided to make some alterations to the specification for hybrid
> handshakes in Tor proposal #269.
>
> It seems that John, Trevor, and I are mostly in agreement about most
> of the construction.

Hi Isis, all,

My main suggestion was to take a look at Noise:

https://noiseprotocol.org

Noise is a framework for DH-based (Ntor-like) key exchange protocols.
You choose a "handshake pattern" plus your favorite crypto and it
fills in the details.  So this would save you from hand-crafting your
key derivation and transcript hashing, as Noise specifies this (e.g.
it uses a chain of HKDF for key derivation, similar to Signal, IPsec,
or TLS 1.3).

For Ntor + hybrid forward secrecy, you could choose something like:

  Noise_NKhfs_25519+NewHope_ChaChaPoly_SHA256
or:
  Noise_NKhfs_25519+NTRU_AESGCM_BLAKE2b
  etc.

The names are a mouthful, but specify the whole protocol:

  NKhfs is a handshake pattern
NK = (N)o client long-term key, (K)nown server long-term key
hfs = hybrid forward secrecy
  25519+NewHope = public-key algorithms
  ChaChaPoly = ChaCha20/Poly1305 for AEAD
  SHA256 = hash for transcript hashing and HKDF


Some other benefits:

 * There are C and Java libraries that can implement this (with
NewHope) by Rhys Weatherley, and hopefully more will pop up.

 * Saves design effort, because it's easy to change patterns to add
client auth, or pre-shared keys, or certificates; or swap out crypto).

 * Also used by WhatsApp and WireGuard, so hopefully the libraries,
tools, and design will continue to improve, benefiting other users.

Noise can be hard to figure out because it's a toolkit, not a single
protocol, but I'd be happy to answer questions about particular use
cases.

Of course, I also think Tor's existing Ntor, the current Tor
proposals, and the changes Isis is mentioning, all seem fine.

Trevor
___
tor-dev mailing list
tor-dev@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev