Giter VIP home page Giter VIP logo

mimoo / disco Goto Github PK

View Code? Open in Web Editor NEW
200.0 10.0 15.0 2.67 MB

a protocol to encrypt communications and a cryptographic library based on Disco

Home Page: https://www.discocrypto.com

License: BSD Zero Clause License

HTML 9.48% CSS 1.22% Go 45.98% Makefile 0.55% TeX 0.36% JavaScript 9.20% Vue 33.14% Dockerfile 0.08%
crypto noise-protocol-framework sha-3 strobe strobe-protocol-framework noise tls library keccak disco

disco's Introduction

disco's People

Contributors

actuallyachraf avatar dependabot[bot] avatar fasjeit avatar lukechampine avatar mimoo avatar rozbb avatar titanous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

disco's Issues

post-handshake authentication

Disco could benefit from an NN pattern that enforces verification of a fingerprint post-handshake in order to "unlock" the session.

Add text on different ways of using Disco

you can use disco via:

  • plug-and-play Dial/Listen+Accept for TCP
  • same thing for UDP
  • framing messages yourself (you need to call WriteMessage and ReadMessage yourself)

None of these are documented. Perhaps it's better to only document the first two and leave the third one for knowledgeable people.

story around signatures in disco

We've seemed to have settled on schnorr signatures over ristretto22519. (See this PR #45)

Other choices were:

  • qDSA. Too new.
  • EdDSA. Makes use of SHA-512.
  • ECDSA. Why not, but not really specified for Curve25519.
  • schnorr over P-256. We already use Curve25519, so we should leverage this.

My two concerns are:

  • ristretto. Too new, and not well-supported.
  • schnorr signatures are not specified anywhere.

What references are there out there? I think we should follow the scheme defined by a proof:

https://crypto.stackexchange.com/questions/48616/prove-the-security-of-schnorrs-signature-scheme

Disco Whitepaper

I think a whitepaper containing:

  • the rational behind Disco
  • benchmark and codesize results in different implementations (especially in C)
  • some tamarin symbolic proof

would be great. If anyone wants to collaborate :)

clear secrets as soon as possible

what are the secrets to delete?

  • psk
  • ephemeral keys
  • long-term keys

when to delete? Probably when Split() is called? Although GetHandshakeState() might still require some stuff?

There is a clear() function to clear secrets btw.

Also note that it doesn't seem possible to completely wipe secrets in Go

GetHandshakeHash needs to be more verbose

In the spec, GetHandshakeHash is quite different from the one in the Noise spec:

  1. it changes the state
  2. it will give out a different result depending when it is called

so we need to add some more information in the spec? fix:

  1. perhaps we should clone the state before calling it?
  2. both peers need to call it at the same time to obtain the same result

Because the fix in 2. also fixes 1., perhaps we should just keep fix 2.

No checking for N pattern

We don't check in checkRequirements or elsewhere that handshake patterns have the correct keys set during initialization. Probably this should be done when calling Initialize on the handshakeState?

For example Noise_N should have the rs set for the initiator and the s set for the responder.

On the other hand, maybe we do check that when we have to send them? In any case it should be checked somewhere.

Create a merge between Noise and the Disco spec

Right now one needs to read both the Noise and the Disco spec.

One could create a Self-contained Disco spec that would be much smaller than the Noise spec. I think this would be a good thing to facilitate implementation of Disco.

License clarification

What's the license for library as well as other code in this repo? Would be nice to have explicit license/copying file and SPDX tags inside source files.

Document APIs

There are several APIs that need to be documented:

  • isRemoteAuthenticated()
  • remotePublicKey()
  • ListenDisco() & AcceptDisco()

more info

The documentation also needs to update the APIs of GenerateKeyPair and LoadKeyPair that now take a passphrase.

Document non-PKI ways of using Disco

Currently, handshake patterns with I and X (key is transmitted as part of the handshake) seem to enforce signatures and a PKI. For example NX:

Noise_NX is a handshake pattern similar to a typical browser ↔ HTTPS server scenario where the client does not authenticate itself and the server authenticates its public key via a signature from an authoritative signing key.

This is not at all the only way of using this handshake patterns. TOFU (trust on first use) or (a whitelist of) key pinning are also possibilities.

How to do it? Your StaticPublicKeyProof() function can return an empty string and your PublicKeyVerifier() can always return true or match public keys against a whitelist.

Furthermore, to obtain the public key received from the connection, one must either use the Disco functions directly (and they are currently not exported) or must use the ListenDisco/AcceptDisco() functions that return a libdisco.Conn instead of a net.Conn; giving access to extra functions like RemotePublicKey().

I am also trying to think of a way a net.Conn could be used to retrieve that public key. The problem is that its interface is limited to modifying its RemoteAddr() function (which is supposed to return the ip:port tuple of the peer). Perhaps, a flag in the configuration of Disco could tweak this to return a publickey:ip:port tuple instead?

PKI: signed identity needs to be signed

in handshake patterns with X or I when the key needs to be signed: we also need to sign the server "identity name" which the client needs to know in advance.

Benchmarks

We need benchmarks, possibly taken from crypto/tls

(Of course benchmarks in a C implementation would be better)

"go test" failed

$ go test
# _/home/mpech/disco/libdisco
./conn_test.go:71:25: conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
FAIL	_/home/mpech/disco/libdisco [build failed]
$ go version
go version go1.15.5 linux/amd64

conn.Read return value is ambiguous

Looks like int return value can be either the number of output bytes, written to output buffer, or in case of exception, number of input bytes, read from socket, including length.

In case of correct decryption this output helps user truncate the buffer and get correct output,
But in case of exception I don't see any useful ways to utilize this integer return value.

So, is this ambiguity intended, and if so why user need it? Maybe it will be better just return 0 for all exceptions?

move website to a different repo

Ideally the website should cover the protocol + all the implementations in different languages, so it'd be good to have it live in a different repository

Christmas Wish: Retrofitting Disco to other sponge constructions

Dear Santa,

I am a very good boy, and I don't like 3D array based sponge functions that much.
Can I have a 2D array based cryptographic library? NORX already exists so I want that.

Please I would like this Rave abstraction for experimentation.

Love,
D

(For serious though, Disco's model can be used to fit ANY sufficiently sized sponge function, maybe Fugue or Luffa for SHA3 candidates? pi-cipher or ICEPOLE for CAESAR parallelization candidates? Ascon or PRIMATEs or STRIBOB for non parallelization candidates? SPONGENT or PHOTON or QUARK for a more modern twist?)

More implementations

To become useful, Disco needs to be widely supported. This means a libdisco needs to exist in:

For now, no interop tests have been done. If people are interested we could have a date setup to plan for that.

There's also Xisco which doesn't use Strobe but Xoodyak

Furthermore, it needs to be integrated in load balancers and proxies:

  • HAProxy
  • Apache
  • Nginx

handshake patterns missing

While I might not want to document them all, especially as some are insecure, it would be nice for protocol builders to support all the handshake patterns. I could also just implement them as they are requested here.

Computing X25519 Secret Keys

Hello!
Nice project, i love the code.

I am reading here :
func GenerateKeypair(privateKey *[32]byte) *KeyPair

that it reads from crypto/rand and returns a random result for the private key.

but, i am also reading here: https://cr.yp.to/ecdh.html

Computing secret keys. Inside your program, to generate a 32-byte Curve25519 secret key, start by generating 32 secret random bytes from a cryptographically safe source: mysecret[0], mysecret[1], ..., mysecret[31]. Then do

     mysecret[0] &= 248;
     mysecret[31] &= 127;
     mysecret[31] |= 64;

is this byte manipulation required?

Authenticating static keys

I'm not sure we need to send a tag after sending a static key, this is because the whole message pattern is authenticated at the end by the payload (empty or not)

Initialize should take []byte for remote keys

Here's Initialize():

func Initialize(handshakeType noiseHandshakeType, initiator bool, prologue []byte, s, e, rs, re *KeyPair)

It doesn't make sense to take *KeyPair for rs and re. We should just accept []byte (which can be set to nil as well).

Disco the library needs a spec

  • the noise part has a spec (https://discocrypto.com/disco.html)
  • the non-noise part doesn't. How does one implement that? For example we want to use schnorr over ristretto for signatures, but there is no real schnorr spec. We also don't take an IV for encryption and generate it ourselves. etc.

plus: disco obfuscates things compared to Noise

one additional argument for disco is that static keys that are sent not encrypted in Noise, are sent obfuscated in Disco. This is good against passive observing of middle boxes or others.

udp?

What happens if you call Dial("udp", ...) instead of "tcp"?

(it should not work!)

keccak-f[400] with Disco

Disco should really shine with embedded devices, and there it should make sense to use keccak-f[400] instead of keccak-f[1600] (which we currently use).

The Strobe version also doesn't include what permutation is used, I think it should be but my suggestions on the list didn't go too far.

should we toggle "initiator" in Split()?

Split() clones the Strobe state and creates two different Strobe state at the end of the handshake.
At this point they are differentiated and one is used for the client to encrypt, the other is used for the server to encrypt.
But both will have the initiator=true value set on their Strobe objects!
It doesn't matter much I think, but to be cleaner, shouldn't we set their initiator value according to their role vis-a-vis of each Strobe object?

WorkGroup/RFC

Would be good to have an internet draft/RFC for disco at some point

enhancing usability

I think I made many mistakes when designing the www.discocrypto.com webpage:

  • too much jargon on the landing page
  • too many keys to understand

Ideally:

  • get to the point: the technical stuff should be either further down the page or on a different page
  • technical terms: things should be renamed with what normal users understand, for example "long-term keys" can be renamed "identities"
  • to many options: remove things like "half duplex" that are probably not going to be useful to most people.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.