Exemplo n.º 1
0
        private bool IsResponseLookupNameMessageValid(SignedLookupResponse signedResponse)
        {
            bool result = false;

            UserEntry responder = ServerApp._pkiCommunicator.GetVerifiedUserPublicKey(signedResponse.Username);
            if (responder != null)
            {

                RSACryptoServiceProvider responderProvider = new RSACryptoServiceProvider();
                responderProvider.FromXmlString(responder.PubKey);
                string data = signedResponse.Username + signedResponse.Uri;
                foreach (RedirectionFile f in signedResponse.FileList)
                    data += f.ToString();
                byte[] bytedata = Encoding.Default.GetBytes(data);
                if (responderProvider.VerifyData(bytedata, "SHA1", signedResponse.Signature))
                    result = true;
                else
                    result = false;
            }

            return result;
        }
Exemplo n.º 2
0
        private void sendResponseToLookupQuery(QueryByName q)
        {
            ServerToServerServices origin;
            RemoteAsyncLookupNameResponseDelegate remoteResDel;

            System.Windows.Forms.MessageBox.Show(ServerApp._user.Username + "@" + ServerApp._primaryURI + " : Its my node name!");
            String i = q.Uris.ElementAt(0);
            origin = ((ServerToServerServices)Activator.GetObject(typeof(ServerToServerServices),
                    i + "/" + ServicesNames.ServerToServerServicesName));
            remoteResDel = new RemoteAsyncLookupNameResponseDelegate(origin.lookupNameResponse);

            /* sign response */
            string data = getResponseDataForHash();
            byte[] bytestreamData = Encoding.Default.GetBytes(data);
            byte[] responseSignature = ServerApp._rsaProvider.SignData(bytestreamData, "SHA1");
            SignedLookupResponse signedLookupResponse =
                new SignedLookupResponse(ServerApp._user.Username, ServerApp._myUri,
                    ServerApp._user.RedirectionList, responseSignature);
            remoteResDel.BeginInvoke(signedLookupResponse, null, null);
        }
Exemplo n.º 3
0
        public void lookupNameResponse(SignedLookupResponse signedResponse)
        {
            if (IsResponseLookupNameMessageValid(signedResponse))
            {
                string name = signedResponse.Username;
                string uri = signedResponse.Uri;
                List<RedirectionFile> redList = signedResponse.FileList;

                ClientServices cliente = (ClientServices)Activator.GetObject(
                    typeof(ClientServices),
                    ServerApp._clientUri + "/" + ServicesNames.ClientServicesName);
                cliente.lookupNameResponse(name, uri, redList);
            }
        }