Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 public ZkPasswordHash GetPasswordHashSet(string username)
 {
     if (_hash == null) _hash = _protocol.HashCredentials(username, password);
     return _hash;
 }