Skip to content

Commit

Permalink
Merge pull request #6555 from ipfs/feat/update-libp2p
Browse files Browse the repository at this point in the history
Update go-libp2p, fix tests with weak RSA keys
  • Loading branch information
Stebalien committed Aug 24, 2019
2 parents 76b0015 + ce96440 commit e7239fe
Show file tree
Hide file tree
Showing 20 changed files with 106 additions and 184 deletions.
4 changes: 2 additions & 2 deletions cmd/seccat/seccat.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ func main() {
}

func setupPeer(a args) (peer.ID, pstore.Peerstore, error) {
if a.keybits < 1024 {
return "", nil, errors.New("bitsize less than 1024 is considered unsafe")
if a.keybits < 2048 {
return "", nil, errors.New("bitsize less than 2048 is considered unsafe")
}

out("generating key pair...")
Expand Down
2 changes: 1 addition & 1 deletion core/coreapi/test/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int)
for i := 0; i < n; i++ {
var ident config.Identity
if fullIdentity {
sk, pk, err := ci.GenerateKeyPair(ci.RSA, 512)
sk, pk, err := ci.GenerateKeyPair(ci.RSA, 2048)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion core/node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (cfg *BuildCfg) options(ctx context.Context) (fx.Option, *cfg.Config) {

func defaultRepo(dstore repo.Datastore) (repo.Repo, error) {
c := cfg.Config{}
priv, pub, err := ci.GenerateKeyPairWithReader(ci.RSA, 1024, rand.Reader)
priv, pub, err := ci.GenerateKeyPairWithReader(ci.RSA, 2048, rand.Reader)
if err != nil {
return nil, err
}
Expand Down
29 changes: 14 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ require (
github.com/gogo/protobuf v1.2.1
github.com/golangci/golangci-lint v1.17.1
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/golang-lru v0.5.1
github.com/hashicorp/golang-lru v0.5.3
github.com/ipfs/go-bitswap v0.1.6
github.com/ipfs/go-block-format v0.0.2
github.com/ipfs/go-blockservice v0.1.0
github.com/ipfs/go-cid v0.0.2
github.com/ipfs/go-cid v0.0.3
github.com/ipfs/go-cidutil v0.0.2
github.com/ipfs/go-datastore v0.0.5
github.com/ipfs/go-detect-race v0.0.1
Expand Down Expand Up @@ -52,47 +52,46 @@ require (
github.com/ipfs/go-unixfs v0.2.1
github.com/ipfs/go-verifcid v0.0.1
github.com/ipfs/hang-fds v0.0.1
github.com/ipfs/interface-go-ipfs-core v0.1.0
github.com/ipfs/interface-go-ipfs-core v0.2.2
github.com/ipfs/iptb v1.4.0
github.com/ipfs/iptb-plugins v0.1.0
github.com/jbenet/go-is-domain v1.0.2
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
github.com/jbenet/go-random-files v0.0.0-20190219210431-31b3f20ebded
github.com/jbenet/go-temp-err-catcher v0.0.0-20150120210811-aac704a3f4f2
github.com/jbenet/goprocess v0.1.3
github.com/libp2p/go-eventbus v0.0.3 // indirect
github.com/libp2p/go-libp2p v0.2.0
github.com/libp2p/go-eventbus v0.1.0 // indirect
github.com/libp2p/go-libp2p v0.3.0
github.com/libp2p/go-libp2p-autonat-svc v0.1.0
github.com/libp2p/go-libp2p-circuit v0.1.0
github.com/libp2p/go-libp2p-circuit v0.1.1
github.com/libp2p/go-libp2p-connmgr v0.1.1
github.com/libp2p/go-libp2p-core v0.0.6
github.com/libp2p/go-libp2p-core v0.2.2
github.com/libp2p/go-libp2p-http v0.1.2
github.com/libp2p/go-libp2p-kad-dht v0.1.1
github.com/libp2p/go-libp2p-kad-dht v0.2.0
github.com/libp2p/go-libp2p-kbucket v0.2.0
github.com/libp2p/go-libp2p-loggables v0.1.0
github.com/libp2p/go-libp2p-mplex v0.2.1
github.com/libp2p/go-libp2p-peerstore v0.1.2-0.20190621130618-cfa9bb890c1a
github.com/libp2p/go-libp2p-peerstore v0.1.3
github.com/libp2p/go-libp2p-pnet v0.1.0
github.com/libp2p/go-libp2p-pubsub v0.1.0
github.com/libp2p/go-libp2p-pubsub-router v0.1.0
github.com/libp2p/go-libp2p-quic-transport v0.1.1
github.com/libp2p/go-libp2p-record v0.1.0
github.com/libp2p/go-libp2p-record v0.1.1
github.com/libp2p/go-libp2p-routing-helpers v0.1.0
github.com/libp2p/go-libp2p-secio v0.1.0
github.com/libp2p/go-libp2p-swarm v0.1.1
github.com/libp2p/go-libp2p-testing v0.0.4
github.com/libp2p/go-libp2p-secio v0.2.0
github.com/libp2p/go-libp2p-swarm v0.2.0
github.com/libp2p/go-libp2p-testing v0.1.0
github.com/libp2p/go-libp2p-tls v0.1.0
github.com/libp2p/go-libp2p-yamux v0.2.1
github.com/libp2p/go-maddr-filter v0.0.5
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/mr-tron/base58 v1.1.2
github.com/multiformats/go-multiaddr v0.0.4
github.com/multiformats/go-multiaddr-dns v0.0.3
github.com/multiformats/go-multiaddr-net v0.0.1
github.com/multiformats/go-multibase v0.0.1
github.com/multiformats/go-multihash v0.0.5
github.com/multiformats/go-multihash v0.0.7
github.com/opentracing/opentracing-go v1.1.0
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v0.9.3
Expand Down
131 changes: 42 additions & 89 deletions go.sum

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions namesys/ipns_resolver_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
dssync "github.com/ipfs/go-datastore/sync"
mockrouting "github.com/ipfs/go-ipfs-routing/mock"
offline "github.com/ipfs/go-ipfs-routing/offline"
u "github.com/ipfs/go-ipfs-util"
ipns "github.com/ipfs/go-ipns"
path "github.com/ipfs/go-path"
opts "github.com/ipfs/interface-go-ipfs-core/options/namesys"
ci "github.com/libp2p/go-libp2p-core/crypto"
peer "github.com/libp2p/go-libp2p-core/peer"
pstore "github.com/libp2p/go-libp2p-core/peerstore"
routing "github.com/libp2p/go-libp2p-core/routing"
"github.com/libp2p/go-libp2p-core/test"
pstoremem "github.com/libp2p/go-libp2p-peerstore/pstoremem"
record "github.com/libp2p/go-libp2p-record"
testutil "github.com/libp2p/go-libp2p-testing/net"
Expand Down Expand Up @@ -137,19 +137,15 @@ func TestResolverValidation(t *testing.T) {
}

func genKeys(t *testing.T) (ci.PrivKey, peer.ID, string, string) {
sr := u.NewTimeSeededRand()
priv, _, err := ci.GenerateKeyPairWithReader(ci.RSA, 1024, sr)
sk, pk, err := test.RandTestKeyPair(ci.RSA, 2048)
if err != nil {
t.Fatal(err)
}

// Create entry with expiry in one hour
pid, err := peer.IDFromPrivateKey(priv)
id, err := peer.IDFromPublicKey(pk)
if err != nil {
t.Fatal(err)
}

return priv, pid, PkKeyForID(pid), ipns.RecordKey(pid)
return sk, id, PkKeyForID(id), ipns.RecordKey(id)
}

type mockValueStore struct {
Expand Down
2 changes: 1 addition & 1 deletion namesys/namesys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestNamesysResolution(t *testing.T) {

func TestPublishWithCache0(t *testing.T) {
dst := dssync.MutexWrap(ds.NewMapDatastore())
priv, _, err := ci.GenerateKeyPair(ci.RSA, 1024)
priv, _, err := ci.GenerateKeyPair(ci.RSA, 2048)
if err != nil {
t.Fatal(err)
}
Expand Down
54 changes: 14 additions & 40 deletions namesys/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import (
mockrouting "github.com/ipfs/go-ipfs-routing/mock"
ipns "github.com/ipfs/go-ipns"
path "github.com/ipfs/go-path"
ci "github.com/libp2p/go-libp2p-core/crypto"
peer "github.com/libp2p/go-libp2p-core/peer"
test "github.com/libp2p/go-libp2p-core/test"
testutil "github.com/libp2p/go-libp2p-testing/net"
tnet "github.com/libp2p/go-libp2p-testing/net"
)

func TestRoutingResolve(t *testing.T) {
Expand All @@ -26,23 +24,15 @@ func TestRoutingResolve(t *testing.T) {
resolver := NewIpnsResolver(d)
publisher := NewIpnsPublisher(d, dstore)

privk, pubk, err := test.RandTestKeyPair(ci.RSA, 512)
if err != nil {
t.Fatal(err)
}
identity := tnet.RandIdentityOrFatal(t)

h := path.FromString("/ipfs/QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN")
err = publisher.Publish(context.Background(), privk, h)
err := publisher.Publish(context.Background(), identity.PrivateKey(), h)
if err != nil {
t.Fatal(err)
}

pid, err := peer.IDFromPublicKey(pubk)
if err != nil {
t.Fatal(err)
}

res, err := resolver.Resolve(context.Background(), pid.Pretty())
res, err := resolver.Resolve(context.Background(), identity.ID().Pretty())
if err != nil {
t.Fatal(err)
}
Expand All @@ -59,36 +49,28 @@ func TestPrexistingExpiredRecord(t *testing.T) {
resolver := NewIpnsResolver(d)
publisher := NewIpnsPublisher(d, dstore)

privk, pubk, err := test.RandTestKeyPair(ci.RSA, 512)
if err != nil {
t.Fatal(err)
}

id, err := peer.IDFromPublicKey(pubk)
if err != nil {
t.Fatal(err)
}
identity := tnet.RandIdentityOrFatal(t)

// Make an expired record and put it in the datastore
h := path.FromString("/ipfs/QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN")
eol := time.Now().Add(time.Hour * -1)

entry, err := ipns.Create(privk, []byte(h), 0, eol)
entry, err := ipns.Create(identity.PrivateKey(), []byte(h), 0, eol)
if err != nil {
t.Fatal(err)
}
err = PutRecordToRouting(context.Background(), d, pubk, entry)
err = PutRecordToRouting(context.Background(), d, identity.PublicKey(), entry)
if err != nil {
t.Fatal(err)
}

// Now, with an old record in the system already, try and publish a new one
err = publisher.Publish(context.Background(), privk, h)
err = publisher.Publish(context.Background(), identity.PrivateKey(), h)
if err != nil {
t.Fatal(err)
}

err = verifyCanResolve(resolver, id.Pretty(), h)
err = verifyCanResolve(resolver, identity.ID().Pretty(), h)
if err != nil {
t.Fatal(err)
}
Expand All @@ -101,35 +83,27 @@ func TestPrexistingRecord(t *testing.T) {
resolver := NewIpnsResolver(d)
publisher := NewIpnsPublisher(d, dstore)

privk, pubk, err := test.RandTestKeyPair(ci.RSA, 512)
if err != nil {
t.Fatal(err)
}

id, err := peer.IDFromPublicKey(pubk)
if err != nil {
t.Fatal(err)
}
identity := tnet.RandIdentityOrFatal(t)

// Make a good record and put it in the datastore
h := path.FromString("/ipfs/QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN")
eol := time.Now().Add(time.Hour)
entry, err := ipns.Create(privk, []byte(h), 0, eol)
entry, err := ipns.Create(identity.PrivateKey(), []byte(h), 0, eol)
if err != nil {
t.Fatal(err)
}
err = PutRecordToRouting(context.Background(), d, pubk, entry)
err = PutRecordToRouting(context.Background(), d, identity.PublicKey(), entry)
if err != nil {
t.Fatal(err)
}

// Now, with an old record in the system already, try and publish a new one
err = publisher.Publish(context.Background(), privk, h)
err = publisher.Publish(context.Background(), identity.PrivateKey(), h)
if err != nil {
t.Fatal(err)
}

err = verifyCanResolve(resolver, id.Pretty(), h)
err = verifyCanResolve(resolver, identity.ID().Pretty(), h)
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion test/3nodetest/bootstrap/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM zaqwsx_ipfs-test-img

RUN ipfs init -b=1024
RUN ipfs init -b=2048
ADD . /tmp/id
RUN mv -f /tmp/id/config /root/.ipfs/config
RUN ipfs id
Expand Down
2 changes: 1 addition & 1 deletion test/3nodetest/client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM zaqwsx_ipfs-test-img

RUN ipfs init -b=1024
RUN ipfs init -b=2048
ADD . /tmp/id
RUN mv -f /tmp/id/config /root/.ipfs/config
RUN ipfs id
Expand Down
2 changes: 1 addition & 1 deletion test/3nodetest/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM zaqwsx_ipfs-test-img

RUN ipfs init -b=1024
RUN ipfs init -b=2048
ADD . /tmp/test
RUN mv -f /tmp/test/config /root/.ipfs/config
RUN ipfs id
Expand Down
2 changes: 1 addition & 1 deletion test/bench/bench_cli_ipfs_add/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func benchmarkAdd(amount int64) (*testing.BenchmarkResult, error) {
}
}

initCmd := exec.Command("ipfs", "init", "-b=1024")
initCmd := exec.Command("ipfs", "init", "-b=2048")
setupCmd(initCmd)
if err := initCmd.Run(); err != nil {
benchmarkError = err
Expand Down
2 changes: 1 addition & 1 deletion test/bench/offline_add/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func benchmarkAdd(amount int64) (*testing.BenchmarkResult, error) {
cmd.Env = env
}

cmd := exec.Command("ipfs", "init", "-b=1024")
cmd := exec.Command("ipfs", "init", "-b=2048")
setupCmd(cmd)
if err := cmd.Run(); err != nil {
b.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion test/sharness/lib/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ test_init_ipfs() {

test_expect_success "ipfs init succeeds" '
export IPFS_PATH="$(pwd)/.ipfs" &&
ipfs init --profile=test -b=1024 > /dev/null
ipfs init --profile=test -b=2048 > /dev/null
'

test_expect_success "prepare config -- mounting" '
Expand Down
10 changes: 5 additions & 5 deletions test/sharness/t0020-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ test_expect_success "clean up ipfs dir" '
'

test_expect_success "'ipfs init --empty-repo' succeeds" '
BITS="1024" &&
BITS="2048" &&
ipfs init --bits="$BITS" --empty-repo >actual_init
'

Expand Down Expand Up @@ -128,14 +128,14 @@ test_expect_success "clean up ipfs dir" '

# test init profiles
test_expect_success "'ipfs init --profile' with invalid profile fails" '
BITS="1024" &&
BITS="2048" &&
test_must_fail ipfs init --bits="$BITS" --profile=nonexistent_profile 2> invalid_profile_out
EXPECT="Error: invalid configuration profile: nonexistent_profile" &&
grep "$EXPECT" invalid_profile_out
'

test_expect_success "'ipfs init --profile' succeeds" '
BITS="1024" &&
BITS="2048" &&
ipfs init --bits="$BITS" --profile=server
'

Expand All @@ -149,7 +149,7 @@ test_expect_success "clean up ipfs dir" '
'

test_expect_success "'ipfs init --profile=test' succeeds" '
BITS="1024" &&
BITS="2048" &&
ipfs init --bits="$BITS" --profile=test
'

Expand All @@ -168,7 +168,7 @@ test_expect_success "clean up ipfs dir" '
'

test_expect_success "'ipfs init --profile=lowpower' succeeds" '
BITS="1024" &&
BITS="2048" &&
ipfs init --bits="$BITS" --profile=lowpower
'

Expand Down
2 changes: 1 addition & 1 deletion test/sharness/t0025-datastores.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test_description="Test non-standard datastores"
. lib/test-lib.sh

test_expect_success "'ipfs init --profile=badgerds' succeeds" '
BITS="1024" &&
BITS="2048" &&
ipfs init --bits="$BITS" --profile=badgerds
'

Expand Down
Loading

0 comments on commit e7239fe

Please sign in to comment.