Otp.AbstractConnection.recvChallengeReply C# (CSharp) Method

recvChallengeReply() protected method

protected recvChallengeReply ( int our_challenge ) : int
our_challenge int
return int
        protected internal virtual int recvChallengeReply(int our_challenge)
        {
            
            int challenge;
            byte[] her_digest = new byte[16];
            
            try
            {
                byte[] buf = read2BytePackage();
                OtpInputStream ibuf = new OtpInputStream(buf);
                int tag = ibuf.read1();
                if (tag != ChallengeReply)
                {
                    throw new System.IO.IOException("Handshake protocol error");
                }
                challenge = ibuf.read4BE();
                ibuf.readN(her_digest);
                byte[] our_digest = genDigest(our_challenge, auth_cookie);
                if (!digests_equals(her_digest, our_digest))
                {
                    throw new OtpAuthException("Peer authentication error.");
                }
            }
            catch (Erlang.Exception)
            {
                throw new System.IO.IOException("Handshake failed - not enough data");
            }
            
            if (traceLevel >= OtpTrace.Type.handshakeThreshold)
            {
                OtpTrace.TraceEvent("<- " + "HANDSHAKE recvChallengeReply" + " from=" + peer._node + " challenge=" + challenge + " digest=" + hex(her_digest) + " local=" + self);
            }
            
            return challenge;
        }