Exemple #1
0
// decodeSecureBlock handles the secure login block and the login response (via doLogin)
func (svc *GameService) decodeSecureBlock(client player.Player) error {
	rsaBlock := encoding.RSABlock{&game_protocol.InboundSecureLoginBlock{}}
	rsaArgs := encoding.RSADecodeArgs{
		Key:       svc.key,
		BlockSize: client.SecureBlockSize(),
	}
	if err := rsaBlock.Decode(client.Conn().ReadBuffer, rsaArgs); err != nil {
		return err
	}
	secureBlock := rsaBlock.Codable.(*game_protocol.InboundSecureLoginBlock)

	// Seed the RNGs
	inSeed := make([]uint32, 4)
	outSeed := make([]uint32, 4)
	for i := range inSeed {
		inSeed[i] = uint32(secureBlock.ISAACSeed[i])
		outSeed[i] = uint32(secureBlock.ISAACSeed[i]) + 50
	}
	client.InitISAAC(inSeed, outSeed)

	username := string(secureBlock.Username)
	password := string(secureBlock.Password)
	password = auth.HashPassword(password)

	return svc.doLogin(client, username, password)
}