Esempio n. 1
0
        private void HandleValidateFrame(ServerValidateFrame frame)
        {
            if (IsMutuallyAuthenticated)
            {
                List <byte[]> signatureParts = new List <byte[]>();
                signatureParts.Add(frame.PublicKey);
                signatureParts.Add(ServerNonce);
                signatureParts.Add(LocalTag.RawData);

                if (!VerifyData(_remoteTag.Holder.Key, frame.Signature, signatureParts.ToArray()))
                {
                    OnExceptionThrown(new InvalidDataException("Invalid signature."));
                    return;
                }
            }

            InitializeCrypto(frame.PublicKey, true);
            BufferFrame(new ServerEchoFrame(), FrameState.ServerEcho);
        }
Esempio n. 2
0
        private void SendValidateFrame(byte[] publicKey, Tag remoteTag)
        {
            byte[] signature = null;

            if (IsMutuallyAuthenticated)
            {
                List <byte[]> signatureParts = new List <byte[]>();
                signatureParts.Add(publicKey);
                signatureParts.Add(ServerNonce);
                signatureParts.Add(remoteTag.RawData);

                signature = SignData(LocalTag.Holder.Key, signatureParts.ToArray());
            }

            ServerValidateFrame frame = new ServerValidateFrame();

            frame.PublicKey = publicKey;
            frame.Signature = signature;

            SendFrame(frame);
        }