[client:client.internal] implemented 'rescue(y1, y2) error' for extracting response data + rescuing key
This commit is contained in:
parent
d759e85735
commit
8b6d5a12cd
|
@ -267,3 +267,38 @@ func (c *T) generateRequest(x1 []byte, x2 []byte) error {
|
|||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (5) Rescue management
|
||||
*
|
||||
* @Y1<[]byte> First rescue parameter
|
||||
* @Y2<[]byte> Second rescue parameter
|
||||
*
|
||||
* @return err<error> The error or NIL if not
|
||||
*
|
||||
---------------------------------------------------------*/
|
||||
func (c *T) rescue(y1 []byte, y2 []byte) error {
|
||||
|
||||
/* (1) Extract time mod */
|
||||
timeMod := uint32( xor.ByteArray(y1, y2)[0] % 2 )
|
||||
|
||||
/* (2) Try to guess time id from timeM */
|
||||
timeId := timeid.Guess(c.ctx.Window(), timeMod);
|
||||
var timeIdBytes []byte;
|
||||
binary.BigEndian.PutUint32(timeIdBytes, timeId)
|
||||
|
||||
/* (3) Hash timeId */
|
||||
hashedTimeId, err := scha.Hash(timeIdBytes, 1, nil, nil);
|
||||
if err != nil { return err }
|
||||
|
||||
/* (4) Get the received hash */
|
||||
receivedHash := xor.ByteArray(y1, hashedTimeId);
|
||||
|
||||
/* (4) Try to rescue the key */
|
||||
err = c.key.Rescue(receivedHash)
|
||||
|
||||
/* (5) Dispatch error */
|
||||
return err
|
||||
|
||||
}
|
Loading…
Reference in New Issue