[client:client] fixed migration validation

This commit is contained in:
xdrm-brackets 2018-04-23 18:09:31 +02:00
parent 50d17723f8
commit 0b24036360
2 changed files with 5 additions and 8 deletions

View File

@ -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

View File

@ -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