[client] improved 'SynchronisationKey' security
This commit is contained in:
parent
e178642fea
commit
99f7df9ad5
|
@ -148,13 +148,17 @@ func (c *T) Receive(r io.Reader) error {
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
func (c *T) SynchronisationKey() ([]byte, error) {
|
func (c *T) SynchronisationKey() ([]byte, error) {
|
||||||
|
|
||||||
/* (1) Get current hash */
|
/* (1) Reset keys so no value can be guessed*/
|
||||||
|
c.migrateKey(); // 1: copies 'sync' into 'key'
|
||||||
|
c.migrateKey(); // 2: copies random new 'sync' into 'key' (old 'sync)
|
||||||
|
|
||||||
|
/* (2) Get current hash */
|
||||||
hash, err := c.key.CurrentHash()
|
hash, err := c.key.CurrentHash()
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
|
|
||||||
/* (2) Decrement key so 'hash' is valid */
|
/* (3) Decrement key so 'hash' is valid */
|
||||||
c.key.Decrement()
|
c.key.Decrement()
|
||||||
|
|
||||||
/* (3) Return key */
|
/* (4) Return key */
|
||||||
return hash, nil;
|
return hash, nil;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue