Commit Graph

208 Commits

Author SHA1 Message Date
julian88110 ebd000db1e
tls: use ALPN to negotiate the stream multiplexer (#1772)
* Muxer selection in TLS handshake first cut

* Clean up some part of the code

* Change earlydata to ConnectionState for security connection.

* resolve merging conflicts

* Add stubs for noise

* clean up code

* Switch over to passing muxers to security transport constructors

* Address feedback points

* Update p2p/net/upgrader/upgrader.go

Co-authored-by: Marten Seemann <martenseemann@gmail.com>

* clean up accidental checked file.

* Review points round 2

* Address some go nit points

* Update tls transport test to address review points

Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2022-10-07 10:34:58 -07:00
Marten Seemann 69a574cb56
tls: add tests for test vector from the spec (#1788) 2022-10-06 23:21:02 -07:00
Marten Seemann 2c1e54083a
tls: fix flaky handshake cancellation test (#1779) 2022-09-23 11:25:08 -07:00
Marten Seemann edf655a503 noise / webtransport: use the Noise Extension Registry for cert hashes 2022-09-20 20:55:37 +03:00
Marten Seemann a73d8e28af noise: use proto2 for the protobuf 2022-09-20 20:55:37 +03:00
Marten Seemann c1bdab429f
noise: make it possible for the server to send early data (#1750)
* noise: make it possible for the server to send early data

* noise: use separate early data handlers for initiator and responder

* noise: use a 2 kb buffer for all handshake operations

* Add comments around EarlyData(Handler)

* noise: send early data with 2nd and 3rd handshake message

* Update p2p/security/noise/session_transport.go

Co-authored-by: Marco Munizaga <git@marcopolo.io>
2022-09-19 09:16:10 +03:00
Marten Seemann ddfb6f9240
noise: don't fail handshake when early data is received without handler (#1746) 2022-09-13 11:42:51 -07:00
Marten Seemann 8be14f480d noise: implement an API to send and receive early data 2022-09-03 11:06:52 +03:00
Marten Seemann 40a0d93e29 noise: add documentation for the Prologue option 2022-09-02 10:16:33 +03:00
Marten Seemann 4623690009 switch from github.com/libp2p/go-libp2p-core to core 2022-08-17 17:13:02 +03:00
web3-bot eff72c4afa
sync: update CI config files (#1678)
* bump go.mod to Go 1.18 and run go fix

* bump go.mod to Go 1.18 and run go fix

* bump go.mod to Go 1.18 and run go fix

* bump go.mod to Go 1.18 and run go fix

* run gofmt -s

* update .github/workflows/go-test.yml

* update .github/workflows/go-check.yml

* stop using the deprecated io/ioutil package

Co-authored-by: web3-bot <web3-bot@users.noreply.github.com>
Co-authored-by: Marten Seemann <martenseemann@gmail.com>
2022-08-17 01:05:51 -07:00
Chinmay Kousik b845164d2f
Allow adding prologue to noise connections (#1663)
* Allow adding prologue to noise connections

* Expose session transport

* Expose session transport

* cleanup noise prologue test

* fix staticheck error
2022-08-09 04:05:25 -07:00
Peter Argue 8a8734387f
Support generating custom x509 certificates (#1481)
* Support generating custom x509 certificates

* add unit tests

* updates from review with tests

* fix type in test email
2022-08-02 08:13:46 -07:00
Steven Allen 36c13f9397
feat: switch noise to use minio's SHA256 implementation (#1657)
On my 11th gen Intel laptop, this library is 3x faster than the default
one (and is the one we use in go-multihash).

See below (GEN_ is the builtin version, SHA_ is this library).

    BenchmarkHash/SHA_/8Bytes-8           94.31 ns/op	  84.82 MB/s
    BenchmarkHash/SHA_/1K-8               926.9 ns/op	1104.74 MB/s
    BenchmarkHash/SHA_/8K-8                6793 ns/op	1205.98 MB/s
    BenchmarkHash/SHA_/1M-8              883694 ns/op	1186.58 MB/s
    BenchmarkHash/SHA_/5M-8             4347298 ns/op	1206.01 MB/s
    BenchmarkHash/SHA_/10M-8            8810864 ns/op	1190.09 MB/s
    BenchmarkHash/GEN_/8Bytes-8           283.2 ns/op	  28.25 MB/s
    BenchmarkHash/GEN_/1K-8                3587 ns/op	 285.48 MB/s
    BenchmarkHash/GEN_/8K-8               27706 ns/op	 295.68 MB/s
    BenchmarkHash/GEN_/1M-8             3414827 ns/op	 307.07 MB/s
    BenchmarkHash/GEN_/5M-8            16789216 ns/op	 312.28 MB/s
    BenchmarkHash/GEN_/10M-8           34073478 ns/op	 307.74 MB/s
2022-07-13 10:32:00 +00:00
Marco Munizaga 452ddfbb76
Add canonical peer status logs (#1624)
* Add canonical peer status logs

* Move logs to swarm

* Remove quic log

* Update deps
2022-07-01 12:52:39 -07:00
Marco Munizaga 8cb44cbd4e
logging: Add canonical log for misbehaving peers (#1600)
* Add misbehaving log

* Add logging when security handshake or muxer fails

* Update go-libp2p-core

* Log at the security handshake level

* Remove misbehaving log from setup muxer
2022-06-26 03:37:57 -07:00
Marten Seemann ce5ff06a6f tls: catch cases where Windows doesn't deliver the TLS error in tests 2022-05-28 22:25:17 +02:00
Marten Seemann dacdb5fc0f tls: set TCP linger to 0 on tests on Windows
Otherwise we can't reliably establish a few TCP connections in short
succession.
2022-05-28 22:25:17 +02:00
Marten Seemann 2f109aea68 tls: fix error reporting in TestInvalidCerts 2022-05-28 22:25:17 +02:00
Marten Seemann 9cb3cd1149
tls: fix flaky handshake cancelation test (#1503) 2022-05-18 12:11:39 -07:00
Marten Seemann 27cfd3f4ed switch from github.com/libp2p/go-libp2p-tls to p2p/security/tls 2022-04-27 12:00:11 +02:00
Marten Seemann 57ea0057d0 move go-libp2p-tls here 2022-04-27 11:56:38 +02:00
Marten Seemann 04b43c81b9 noise: use golang.org/x/crypto/chacha20poly1305 instead of golang.org/x/crypto/poly1305 2022-04-27 11:07:08 +02:00
Marten Seemann 935905753a switch from github.com/libp2p/go-libp2p-noise to p2p/security/noise 2022-04-26 19:59:10 +02:00
Marten Seemann abde8f37f7 catch panics during the handshake (#111) 2022-04-19 03:01:46 -07:00
Steven Allen 6d7a3968cd feat: catch panics in TLS negotiation
Part of https://github.com/libp2p/go-libp2p/issues/1389
2022-04-19 11:42:05 +02:00
Marten Seemann 7ee67dd8d4 use tls.Conn.HandshakeContext instead of tls.Conn.Handshake (#106)
* use tls.Conn.HandshakeContext instead of tls.Conn.Handshake

* make sure that crypto/tls picks up the handshake ctx cancelation in tests
2022-04-10 06:30:15 -07:00
Marten Seemann 5ffe478c08 remove the Ginkgo test suite 2022-01-04 13:05:32 +04:00
Marten Seemann 07909fc545 migrate the transport tests away from Ginkgo 2022-01-04 13:05:30 +04:00
Marten Seemann 414ea4c984 migrate the extension tests away from Ginkgo 2022-01-04 13:04:57 +04:00
Marten Seemann 433e650113 set an actual NotBefore time on the certificate 2021-11-23 11:59:38 +04:00
Marten Seemann 1b09f16b42 set a random certificate issuer
According to RFC3280, the issuer field must not be empty.
2021-11-23 11:59:36 +04:00
Marten Seemann a05bdd710b add the peer ID to SecureInbound 2021-09-08 12:41:33 +01:00
Marten Seemann 2bf69fb8d4 add the peer ID to SecureInbound 2021-09-08 12:22:46 +01:00
Marten Seemann 958fc8e5b1 fix keys used for generating cert chain in tests 2021-09-05 12:28:09 +01:00
Marten Seemann 1e7a4d7b35 fix: don't fail the handshake when the libp2p extension is critical 2021-08-07 11:45:29 +01:00
Marten Seemann 4bd2ad608f update go-libp2p-core, remove integration test 2021-07-25 11:19:31 +02:00
Marten Seemann aa3fa7d693 fix deprecated call to key.Bytes 2021-07-23 12:09:01 +02:00
Steven Allen 061a86e0cc fix: remove deprecated call to pk.Bytes 2021-07-22 15:30:42 -07:00
Steven Allen 9832fdeeeb Merge pull request #95 from titanous/update-noise
Update github.com/flynn/noise to address nonce handling security issues
2021-05-04 19:38:25 -07:00
Marten Seemann 5ee5b95b9a add a comment why we ignore the payload on the first message 2021-05-05 09:34:25 +07:00
Marten Seemann f046ec6d71 fix staticcheck 2021-04-23 10:47:47 +07:00
Jonathan Rudenberg f4be0fe818 chore: update github.com/flynn/noise to v1 2021-04-22 17:30:03 -04:00
Steven Allen 65ff13bd45 chore: update deps
And rebuild protobuf definitions.
2021-03-30 07:50:01 -07:00
Marten Seemann aaa62b9eed fix usage of deprecated peer.IDB58Decode 2021-03-30 11:20:09 +07:00
Steven Allen a27e362d55 chore: relicense MIT/Apache-2.0 2021-03-24 20:52:59 -07:00
Raúl Kripalani 86b4893f9a optimize: reduce syscalls using a buffered reader.
Previously, each noise message read would make two syscalls:
1. one to read the length prefix.
2. one to read the encrypted payload.

This patch adds bufio.Reader mediation to cushion syscalls, and
significantly enhaces throughput in read-dominated connections, such
as file transfers.
2020-10-07 10:23:18 +01:00
Marten Seemann 8aa3448da2 remove setting of the TLS 1.3 GODEBUG flag 2020-07-30 12:25:36 +07:00
Aarsh Shah 64edfa60be test read decryption fails 2020-05-07 12:08:12 +05:30
Aarsh Shah 68f0604b8c changes as per review 2020-05-07 11:20:31 +05:30