Exemplo n.º 1
0
        private List <string> GetKeyCredentials()
        {
            RegistryKey keyCredential = GetCredentialRoute();

            string credential1 = (string)keyCredential.GetValue(GlobalResources.Key1);
            string credential2 = (string)keyCredential.GetValue(GlobalResources.Key2);
            string credential3 = (string)keyCredential.GetValue(GlobalResources.Key3);

            if (credential1 != null && credential2 != null && credential3 != null)
            {
                CryptographyManager objQueryTalkCryptography = new CryptographyManager();
                //string decryptedsimkey = objQueryTalkCryptography.DecryptAsim(CryptoContext.CryptedSimKey, CryptoContext.RSAPrivateKey);

                string user       = objQueryTalkCryptography.DecryptSim(credential1, CryptoContext.ComunicationKey);
                string password   = objQueryTalkCryptography.DecryptSim(credential2, CryptoContext.ComunicationKey);
                string rememberMe = objQueryTalkCryptography.DecryptSim(credential3, CryptoContext.ComunicationKey);

                List <string> Keys = new List <string>()
                {
                    user, password, rememberMe
                };

                return(Keys);
            }
            else
            {
                return(new List <string> {
                    "", "", ""
                });
            }
        }
Exemplo n.º 2
0
        internal static string SendMessageLicense(string xmlMessage, string decryptedsimkey)
        {
            string  responseStr = "";
            Message xmlResponseMessage;

            // get server response
            responseStr = CommunicationManager.SendXmlMessage(xmlMessage, GlobalResources.LicenseAnonymousUrl);

            if (string.IsNullOrEmpty(responseStr))
            {
                return(CommunicationManager.Deny(GlobalResources.ServerFailedMessage));
            }

            if (CommunicationManager.IsDenied(responseStr))
            {
                return(responseStr);
            }

            CryptographyManager objQueryTalkCryptography = new CryptographyManager();

            responseStr        = objQueryTalkCryptography.DecryptSim(responseStr, CryptoContext.ComunicationKey);
            xmlResponseMessage = CommunicationManager.ReadXML(responseStr, decryptedsimkey, true);
            if (!IsValidResponseNoUser(xmlResponseMessage as ResponseMessage))
            {
                return(CommunicationManager.Deny(GlobalResources.ServerFailedMessage));
            }

            return((xmlResponseMessage as ResponseMessage).Response);
        }
Exemplo n.º 3
0
        private static string RegisterAnonymousEmail(string xmlMessage, string decryptedsimkey)
        {
            var responseStr = SendXmlMessage(xmlMessage, GlobalResources.RegisterAnonymousEmailUrl);

            if (string.IsNullOrEmpty(responseStr))
            {
                return(Deny(GlobalResources.ServerFailedMessage));
            }

            if (IsDenied(responseStr))
            {
                return(responseStr);
            }

            CryptographyManager objQueryTalkCryptography = new CryptographyManager();

            responseStr = objQueryTalkCryptography.DecryptSim(responseStr, CryptoContext.ComunicationKey);

            var xmlResponseMessage = ReadXML(responseStr, decryptedsimkey, true);

            //Los mensajes de los servicios de licenciamiento se verifica que no se alterara ninguno de los datos originalmente enviados
            //y que hacen unica y universal la comunicación entre el usuario/machine/servidor
            if (!IsValidResponse(xmlResponseMessage as ResponseMessage))
            {
                return(Deny(GlobalResources.ServerFailedMessage));
            }

            return((xmlResponseMessage as ResponseMessage).Response);
        }
Exemplo n.º 4
0
        private static string SendMessageLicense(string xmlMessage, string decryptedsimkey, string user, string password)
        {
            string  responseStr = "";
            Message xmlResponseMessage;

            responseStr = SendXmlMessage(xmlMessage, GlobalResources.LicenseUrl);

            if (string.IsNullOrEmpty(responseStr))
            {
                return(Deny(GlobalResources.ServerFailedMessage));
            }

            if (IsDenied(responseStr))
            {
                return(responseStr);
            }

            //Los mensajes de los servicios de licenciamiento se encriptan doblemente en el servidor con el ComunicationKey
            CryptographyManager objQueryTalkCryptography = new CryptographyManager();

            responseStr = objQueryTalkCryptography.DecryptSim(responseStr, CryptoContext.ComunicationKey);

            xmlResponseMessage = ReadXML(responseStr, decryptedsimkey, true);

            //Los mensajes de los servicios de licenciamiento se verifica que no se alterara ninguno de los datos originalmente enviados
            //y que hacen unica y universal la comunicación entre el usuario/machine/servidor
            if (!IsValidResponse(xmlResponseMessage as ResponseMessage, user, password))
            {
                return(Deny(GlobalResources.ServerFailedMessage));
            }

            return((xmlResponseMessage as ResponseMessage).Response);
        }
Exemplo n.º 5
0
        internal static Message ReadXML(string xmlString, Func <string, string> simKeyProvider, bool response)
        {
            Message             message   = response ? new ResponseMessage() : new Message();
            CryptographyManager objCrypto = new CryptographyManager();

            XmlNode     node;
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xmlString);

            node = doc.DocumentElement.SelectSingleNode("/message/block0/block0value1");
            message.CommunicationID = node.InnerText;

            // get symetric key
            var simKey = simKeyProvider(message.CommunicationID);

            node            = doc.DocumentElement.SelectSingleNode("/message/block1/block1value1");
            message.Command = objCrypto.DecryptSim(node.InnerText, simKey);

            if (message.Command != Commands.VIEWLICENSE)
            {
                node       = doc.DocumentElement.SelectSingleNode("/message/block2/block2value1");
                message.CK = objCrypto.DecryptSim(node.InnerText, simKey);
            }

            node             = doc.DocumentElement.SelectSingleNode("/message/block3/block3value1");
            message.User     = objCrypto.DecryptSim(node.InnerText, simKey);
            node             = doc.DocumentElement.SelectSingleNode("/message/block3/block3value2");
            message.Password = objCrypto.DecryptSim(node.InnerText, simKey);

            //Información necesaria solo para los servicios de licenciamiento
            if (message.Command == Commands.AUTHENTICATE ||
                message.Command == Commands.AUTHENTICATE_ANONYMOUS ||
                message.Command == Commands.REMOVE ||
                message.Command == Commands.REGISTEREMAIL)
            {
                node                 = doc.DocumentElement.SelectSingleNode("/message/block4/block4value1");
                message.MK           = objCrypto.DecryptSim(node.InnerText, simKey);
                node                 = doc.DocumentElement.SelectSingleNode("/message/block4/block4value2");
                message.ComputerName = objCrypto.DecryptSim(node.InnerText, simKey);
                node                 = doc.DocumentElement.SelectSingleNode("/message/block4/block4value3");
                message.Manufacturer = objCrypto.DecryptSim(node.InnerText, simKey);
                node                 = doc.DocumentElement.SelectSingleNode("/message/block4/block4value4");
                message.Model        = objCrypto.DecryptSim(node.InnerText, simKey);
                node                 = doc.DocumentElement.SelectSingleNode("/message/block4/block4value5");
                message.Processor    = objCrypto.DecryptSim(node.InnerText, simKey);
            }

            //Información usada para los responses desde el servidor
            if (response)
            {
                node = doc.DocumentElement.SelectSingleNode("/message/block5/block5value1");
                (message as ResponseMessage).Response = objCrypto.DecryptSim(node.InnerText, simKey);
            }

            if (message.Command == Commands.REGISTEREMAIL)
            {
                node          = doc.DocumentElement.SelectSingleNode("/message/block6/block6value1");
                message.Email = objCrypto.DecryptSim(node.InnerText, simKey);
            }

            return(message);
        }