public bool ProcessZkInitiation(BinaryReader binReader, BinaryWriter binWriter, Stopwatch sw) { _username = binReader.ReadString(); _aEphemeral = binReader.ReadBytes(32); _logger.Debug("ZkInitiation client username received: {0}", _username); _logger.Debug("ZkInitiation client Ephemeral received: {0}", Convert.ToBase64String(_aEphemeral)); _zkPasswordHash = _repository.GetPasswordHashSet(_username); if (null == _zkPasswordHash) { _logger.Debug("ZkInitiation client username not found. Authentication failed."); binWriter.Write(false); return(false); } _bRand = _zkProtocol.CryptRand(); _bEphemeral = _zkProtocol.GetServerEphemeralB(_zkPasswordHash.Salt, _zkPasswordHash.Verifier, _bRand); _scramble = _zkProtocol.CalculateRandomScramble(_aEphemeral, _bEphemeral); _serverSessionKey = _zkProtocol.ServerComputeSessionKey(_zkPasswordHash.Salt, _zkPasswordHash.Key, _aEphemeral, _bEphemeral, _scramble); binWriter.Write(true); binWriter.Write(_zkPasswordHash.Salt); _logger.Debug("ZkInitiation hash salt sent to client: {0}", Convert.ToBase64String(_zkPasswordHash.Salt)); binWriter.Write(_bEphemeral); _logger.Debug("ZkInitiation server Ephemeral sent to client: {0}", Convert.ToBase64String(_bEphemeral)); return(true); }
public bool ProcessZkInitiation(BinaryReader binReader, BinaryWriter binWriter, Stopwatch sw) { _username = binReader.ReadString(); _aEphemeral = binReader.ReadBytes(32); _zkPasswordHash = _repository.GetPasswordHashSet(_username); if (null == _zkPasswordHash) { binWriter.Write(false); return(false); } _bRand = _zkProtocol.CryptRand(); _bEphemeral = _zkProtocol.GetServerEphemeralB(_zkPasswordHash.Salt, _zkPasswordHash.Verifier, _bRand); _scramble = _zkProtocol.CalculateRandomScramble(_aEphemeral, _bEphemeral); _serverSessionKey = _zkProtocol.ServerComputeSessionKey(_zkPasswordHash.Salt, _zkPasswordHash.Key, _aEphemeral, _bEphemeral, _scramble); binWriter.Write(true); binWriter.Write(_zkPasswordHash.Salt); binWriter.Write(_bEphemeral); return(true); }