From 0b24036360edc90e7db879cb3675d0b331763624 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 23 Apr 2018 18:09:31 +0200 Subject: [PATCH] [client:client] fixed migration validation --- src/git.xdrm.io/schastsp/client/client.go | 10 +++------- src/git.xdrm.io/schastsp/client/client.internal.go | 3 ++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/git.xdrm.io/schastsp/client/client.go b/src/git.xdrm.io/schastsp/client/client.go index c4f075f..0f66573 100644 --- a/src/git.xdrm.io/schastsp/client/client.go +++ b/src/git.xdrm.io/schastsp/client/client.go @@ -107,10 +107,8 @@ func (c *T) Receive(r io.Reader) error { /* (1) If pending migration -> migrate */ if c.key.MigrationCode() == 2 { - c.key.MigrationCode(3) - if DEBUG { - fmt.Printf("*** VALIDATED MIGRATION\n") - } + c.migrateKey() + if DEBUG { fmt.Printf("*** VALIDATED MIGRATION\n") } } /* (2) No error anyway */ @@ -136,9 +134,7 @@ func (c *T) Receive(r io.Reader) error { err = c.rescue(y1, y2) if err != nil { return err } - /* (4) Reset key to not consumed */ - c.key.MigrationCode(0) - c.updateConfig() + if DEBUG { fmt.Printf("*** MIGRATION PREPARED\n") } return nil diff --git a/src/git.xdrm.io/schastsp/client/client.internal.go b/src/git.xdrm.io/schastsp/client/client.internal.go index 8265e1e..778e76c 100644 --- a/src/git.xdrm.io/schastsp/client/client.internal.go +++ b/src/git.xdrm.io/schastsp/client/client.internal.go @@ -328,10 +328,11 @@ func (c *T) rescue(y1 []byte, y2 []byte) error { /* (4) Get the received hash */ receivedHash := xor.ByteArray(y1, hashedTimeId) - /* (4) Try to rescue the key */ + /* (5) Try to rescue the key */ err = c.key.Rescue(receivedHash) if err != nil { return err } + /* (6) Store updated key */ c.updateConfig() return nil