Beispiel #1
0
        public static void Test_BlockchainWithGlobalSignature()
        {
            // Blockchain whose block closure is guaranteed by digital signature
            System.Security.Cryptography.RSACryptoServiceProvider RSA = new System.Security.Cryptography.RSACryptoServiceProvider();

            var PublicKeyBase64  = Convert.ToBase64String(RSA.ExportCspBlob(false));
            var PrivateKeyBase64 = Convert.ToBase64String(RSA.ExportCspBlob(true));

            Blockchain Blocks = new Blockchain(PublicKeyBase64, "Webmaster", "Phrases", Blockchain.BlockchainType.Binary, false);

            byte[] Signature;
            bool   IsValid;

            Blockchain.Block Block1 = new Blockchain.Block(Blocks, "Hi my friends, I have a message for you");
            Signature = RSA.SignHash(Block1.CalculateChecksumBytes(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            IsValid   = Block1.AddBlockSignature(Signature); // Close the block with the digital signature

            Blockchain.Block Block2 = new Blockchain.Block(Blocks, "This is a message number 2, signed");
            Signature = RSA.SignHash(Block2.CalculateChecksumBytes(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            IsValid   = Block2.AddBlockSignature(Signature); // Close the block with the digital signature

            Blockchain.Block Block3 = new Blockchain.Block(Blocks, "In the last block I added the last message");
            Signature = RSA.SignHash(Block3.CalculateChecksumBytes(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            IsValid   = Block3.AddBlockSignature(Signature); // Close the block with the digital signature

            int BlockError = Blocks.Validate();              // 0 = no error
            var LastBlock  = Blocks.GetLastBlock();
        }
Beispiel #2
0
        public Keys RsaNewKeys(int keySize)
        {
            Keys keys = new Keys();

            // Generate a public/private key pair.
            System.Security.Cryptography.RSACryptoServiceProvider rsa;
            rsa = new System.Security.Cryptography.RSACryptoServiceProvider(keySize);
            //-----------------------------------------------------
            //Save the public key information to an RSAParameters structure.
            System.Security.Cryptography.RSAParameters publicKeyInfo;
            publicKeyInfo = rsa.ExportParameters(false);
            string publicXml = rsa.ToXmlString(false);

            keys.Public = System.Convert.ToBase64String(rsa.ExportCspBlob(false));
            //-----------------------------------------------------
            //Save the public and private key information to an RSAParameters structure.
            System.Security.Cryptography.RSAParameters privateKeyInfo;
            privateKeyInfo = rsa.ExportParameters(true);
            string privateXml = rsa.ToXmlString(true);

            keys.Private = System.Convert.ToBase64String(rsa.ExportCspBlob(true));
            //-----------------------------------------------------
            //System.Security.Cryptography.X509Certificates.PublicKey pubKey;
            //System.Security.Cryptography.X509Certificates.PublicKey pvtKey;
            return(keys);
        }
Beispiel #3
0
        public static void Test_BlockchainWithGlobalSignature()
        {
            // Blockchain whose block closure is guaranteed by digital signature
            var rsa = new System.Security.Cryptography.RSACryptoServiceProvider();

            var publicKeyBase64  = Convert.ToBase64String(rsa.ExportCspBlob(false));
            var privateKeyBase64 = Convert.ToBase64String(rsa.ExportCspBlob(true));

            var  blocks = new Blockchain(new string[] { publicKeyBase64 }, "Webmaster", "Phrases", Blockchain.BlockchainType.Binary, Blockchain.BlockSynchronization.AddInLocalAndSync, false);
            bool isValid;

            var block1    = new Blockchain.Block(blocks, "Hi my friends, I have a message for you");
            var signature = rsa.SignHash(block1.CalculateChecksumBytes(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));

            isValid = block1.AddBlockSignature(signature); // Close the block with the digital signature

            var block2 = new Blockchain.Block(blocks, "This is a message number 2, signed");

            signature = rsa.SignHash(block2.CalculateChecksumBytes(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            isValid   = block2.AddBlockSignature(signature); // Close the block with the digital signature

            var block3 = new Blockchain.Block(blocks, "In the last block I added the last message");

            signature = rsa.SignHash(block3.CalculateChecksumBytes(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            isValid   = block3.AddBlockSignature(signature); // Close the block with the digital signature

            var blockError = blocks.Validate();              // 0 = no error
            var lastBlock  = blocks.GetLastBlock();
        }
Beispiel #4
0
        public static Tuple <string, string> CreateKeyPair()
        {
            System.Security.Cryptography.CspParameters cspParams = new System.Security.Cryptography.CspParameters {
                ProviderType = 1
            };

            System.Security.Cryptography.RSACryptoServiceProvider rsaProvider = new System.Security.Cryptography.RSACryptoServiceProvider(1024, cspParams);

            string publicKey  = Convert.ToBase64String(rsaProvider.ExportCspBlob(false));
            string privateKey = Convert.ToBase64String(rsaProvider.ExportCspBlob(true));

            return(new Tuple <string, string>(privateKey, publicKey));
        }
        public SettingsRepository()
        {
            db = new LiteDatabase("config.db");

            serversettings = db.GetCollection <ServerSettings>("settings");

            // Get a collection (or create, if doesn't exist)
            var usercol = db.GetCollection <User>("users");

            // Index users using username property
            usercol.EnsureIndex(x => x.Username, true);

            ServerSettings = serversettings.FindOne(s => s.ServerRsaKey != null);


            if (ServerSettings == null)
            {
                // Insert new settings document (Id will be auto-incremented)
                ServerSettings = new ServerSettings();

                var csp = new System.Security.Cryptography.RSACryptoServiceProvider(4096);

                var rsakeydata = csp.ExportCspBlob(true);
                ServerSettings.ServerRsaKey = Convert.ToBase64String(rsakeydata);
                ServerSettings.ListenToPort = 22; // default port

                serversettings.Insert(ServerSettings);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Used only to create MyNode. Generate an RSA for the current node.
        /// </summary>
        /// <param name="myNode">Parameters for this node</param>
        internal Node(NodeInitializer myNode)
        {
            Address     = myNode.Address;
            MachineName = myNode.VirtualDevice?.MachineName ?? Environment.MachineName;
            //Create RSA
            var rsa = new System.Security.Cryptography.RSACryptoServiceProvider();

            rsa.ImportCspBlob(Convert.FromBase64String(myNode.PrivateKey));
            PublicKey = Convert.ToBase64String(rsa.ExportCspBlob(false));
            _rsa      = rsa;
        }
Beispiel #7
0
        public List <string> GerarChaves()
        {
            System.Security.Cryptography.CspParameters cspParams = new System.Security.Cryptography.CspParameters {
                ProviderType = 1
            };
            System.Security.Cryptography.RSACryptoServiceProvider rsaProvider = new System.Security.Cryptography.RSACryptoServiceProvider(cspParams);

            byte[] privateBytes = rsaProvider.ExportCspBlob(true);
            byte[] publicBytes  = rsaProvider.ExportCspBlob(false);

            string privateKey = Convert.ToBase64String(privateBytes);
            string publicKey  = Convert.ToBase64String(publicBytes);

            List <string> chaves = new List <string>();

            chaves.Add(privateKey);
            chaves.Add(publicKey);

            return(chaves);
        }
Beispiel #8
0
 static void Main(string[] args)
 {
     // your data you want to securely send from B to A without revealing the content
     byte[] data = new byte[] { 1, 2, 3, 4, 5, 6 };
     // machine A
     System.Security.Cryptography.RSACryptoServiceProvider full_rsa = new System.Security.Cryptography.RSACryptoServiceProvider(1024);
     byte[] publickey = full_rsa.ExportCspBlob(false);            //send the public key to machine B
     // machine B
     byte[] encrypteddata = EncryptData(publickey, data);         //send encrypted data back to machine A
     // machine A
     byte[] decrypteddata = DecryptData(full_rsa, encrypteddata); //decrypt the data encryped by machine B
     // decrypteddata = 1,2,3,4,5,6
 }
Beispiel #9
0
 /// <summary>
 /// 读取密钥文件
 /// </summary>
 /// <param name="path">密钥路径</param>
 public void LoadKey(string path)
 {
     if (string.IsNullOrEmpty(path))
     {
         throw new ArgumentNullException("path");
     }
     if (!File.Exists(path))
     {
         throw new InvalidDataException("File not exists");
     }
     if (path.EndsWith(".pem"))
     {
         //rsa pem file
         var file_data = File.ReadAllText(path);
         try
         {
             var rsa_data = Crypto.RSA_ImportPEMPrivateKey(file_data);
             _rsaPrivate = rsa_data;
             var rsa = new System.Security.Cryptography.RSACryptoServiceProvider();
             rsa.ImportCspBlob(rsa_data);
             _rsaPublic = rsa.ExportCspBlob(false);
             _hasRsaKey = true;
         }
         catch (Exception)
         {
         }
     }
     else
     {
         //aes file data
         var file_data = File.ReadAllText(path);
         if (file_data.Length == 96)
         {
             try
             {
                 var array = util.Hex(file_data);
                 _aesKey = new byte[32];
                 _aesIv  = new byte[16];
                 Array.Copy(array, 0, _aesKey, 0, 32);
                 Array.Copy(array, 32, _aesIv, 0, 16);
                 _hasAesKey = true;
             }
             catch (Exception)
             {
             }
         }
     }
 }
Beispiel #10
0
        public MockDataStore()
        {
            items = new List <Item>();
            List <Item> mockItems;

            mockItems = (List <Item>)Core.Storage.LoadObject(typeof(List <Item>), "Contacts");

#if DEBUG
            if (mockItems == null)
            {
                System.Security.Cryptography.RSACryptoServiceProvider RSA = new System.Security.Cryptography.RSACryptoServiceProvider();
                string PK = Convert.ToBase64String(RSA.ExportCspBlob(false));
                System.Diagnostics.Debug.Print(PK);
                mockItems = new List <Item>
                {
                    new Item {
                        Id = Guid.NewGuid().ToString(), ContactName = "Mario", PublicKey = PK
                    },
                    new Item {
                        Id = Guid.NewGuid().ToString(), ContactName = "Luigi", PublicKey = PK
                    },
                    new Item {
                        Id = Guid.NewGuid().ToString(), ContactName = "Gennaro", PublicKey = PK
                    },
                    new Item {
                        Id = Guid.NewGuid().ToString(), ContactName = "Peppone", PublicKey = PK
                    },
                    new Item {
                        Id = Guid.NewGuid().ToString(), ContactName = "Andrea", PublicKey = "BgIAAACkAABSU0ExAAQAAAEAAQCFZy1gQ+ks9C+jKZ8n5ypEgYWXLZWFfyXpbsmOURNuvSGenCqOUB7DAtzWQlooKDSyq8K+KUW0SS9ks4IJwpAzfEWkX4aJ6pgMzUgb4LJiaoGUNONWTDDM+UYpgCA2C5jLcV/PDhVgDZexIfMAZsg9AuRIEwK6zQW9d/yCIH50uw=="
                    },
                    new Item {
                        Id = Guid.NewGuid().ToString(), ContactName = "Bruno", PublicKey = "BgIAAACkAABSU0ExAAQAAAEAAQCBVjsSHlUACoyB57m7jFiCGoxE9vY4Lg+CM4s156B/8M4ldPaUt27/7yRn4llcvq3nOlDPpde6dkCx4t7fVPkkHNSlVY6LDBG2YCoe03fP2275Y7T9u3TM4NleD8uthdSk/sW4YrpMVPoGXTnCXCKSgxK0i/AuSO+4vrqwqUb73A=="
                    },
                };
            }
#endif
            if (mockItems == null)
            {
                mockItems = new List <Item>();
            }

            items = mockItems.OrderBy(o => o.ContactName).ToList();
        }
Beispiel #11
0
        public static void Test_BlockchainWithDocumentsSigned()
        {
            // Blockchain with the content having double signature

            var rsa1             = new System.Security.Cryptography.RSACryptoServiceProvider();
            var publicKey1Base64 = Convert.ToBase64String(rsa1.ExportCspBlob(false));

            var rsa2             = new System.Security.Cryptography.RSACryptoServiceProvider();
            var publicKey2Base64 = Convert.ToBase64String(rsa2.ExportCspBlob(false));

            var  blocks = new Blockchain("Webmaster", "Phrases", Blockchain.BlockchainType.Binary, Blockchain.BlockSynchronization.AddInLocalAndSync, true);
            var  test   = blocks.Validate();
            bool isValid;

            var block1    = new Blockchain.Block(blocks, "Hi my friends, I have a message for you");
            var signature = rsa1.SignHash(block1.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));

            isValid   = block1.AddBodySignature(publicKey1Base64, signature, false); // Add first signature
            signature = rsa2.SignHash(block1.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            isValid   = block1.AddBodySignature(publicKey2Base64, signature, true);  // Add second signature and closing the block

            var block2 = new Blockchain.Block(blocks, "This is a message number 2, signed");

            signature = rsa1.SignHash(block2.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            isValid   = block2.AddBodySignature(publicKey1Base64, signature, false); // Add first signature
            signature = rsa2.SignHash(block2.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            isValid   = block2.AddBodySignature(publicKey2Base64, signature, true);

            var block3 = new Blockchain.Block(blocks, "In the last block I added the last message");

            signature = rsa1.SignHash(block3.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            isValid   = block3.AddBodySignature(publicKey1Base64, signature, false); // Add first signature
            signature = rsa2.SignHash(block3.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            isValid   = block3.AddBodySignature(publicKey2Base64, signature, true);  // Add second signature and closing the block

            var blockError = blocks.Validate();                                      // 0 = no error
            var lastBlock  = blocks.GetLastBlock();
        }
Beispiel #12
0
        public static void Test_BlockchainWithDocumentsSigned()
        {
            // Blockchain with the content having double signature

            System.Security.Cryptography.RSACryptoServiceProvider RSA1 = new System.Security.Cryptography.RSACryptoServiceProvider();
            var PublicKey1Base64 = Convert.ToBase64String(RSA1.ExportCspBlob(false));

            System.Security.Cryptography.RSACryptoServiceProvider RSA2 = new System.Security.Cryptography.RSACryptoServiceProvider();
            var PublicKey2Base64 = Convert.ToBase64String(RSA2.ExportCspBlob(false));

            Blockchain Blocks = new Blockchain("Webmaster", "Phrases", Blockchain.BlockchainType.Binary, true);
            var        Test   = Blocks.Validate();

            byte[] Signature;
            bool   IsValid;

            Blockchain.Block Block1 = new Blockchain.Block(Blocks, "Hi my friends, I have a message for you");
            Signature = RSA1.SignHash(Block1.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            IsValid   = Block1.AddBodySignature(PublicKey1Base64, Signature, false); // Add first signature
            Signature = RSA2.SignHash(Block1.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            IsValid   = Block1.AddBodySignature(PublicKey2Base64, Signature, true);  // Add second signature and closing the block

            Blockchain.Block Block2 = new Blockchain.Block(Blocks, "This is a message number 2, signed");
            Signature = RSA1.SignHash(Block2.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            IsValid   = Block2.AddBodySignature(PublicKey1Base64, Signature, false); // Add first signature
            Signature = RSA2.SignHash(Block2.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            IsValid   = Block2.AddBodySignature(PublicKey2Base64, Signature, true);

            Blockchain.Block Block3 = new Blockchain.Block(Blocks, "In the last block I added the last message");
            Signature = RSA1.SignHash(Block3.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            IsValid   = Block3.AddBodySignature(PublicKey1Base64, Signature, false); // Add first signature
            Signature = RSA2.SignHash(Block3.HashBody(), System.Security.Cryptography.CryptoConfig.MapNameToOID("SHA256"));
            IsValid   = Block3.AddBodySignature(PublicKey2Base64, Signature, true);  // Add second signature and closing the block

            int BlockError = Blocks.Validate();                                      // 0 = no error
            var LastBlock  = Blocks.GetLastBlock();
        }
Beispiel #13
0
        /// <summary>
        /// Realizar el inicio de sesión para un usuario en la BD.
        /// </summary>
        /// <param name="NombreUsuario"></param>
        /// <param name="Pwd"></param>
        /// <returns>Objeto "RetornoInicioSesion" que indica el Resultado(true o false), Datos Globales del Sistema, el objeto Usuario CIPOL y un posible Mensaje de error.</returns>
        /// <history>
        /// [MartinV]          [jueves, 25 de septiembre de 2014]       Modificado  GCP-Cambios 15585
        /// </history>
        private mFormLogin IniciarSesion(string NombreUsuario, string Pwd, System.Net.CookieContainer cokie, string ip)
        {
            ///'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
            //                    DESCRIPCION DE VARIABLES LOCALES
            //strUsuario : Nombre del usuario
            //objProxy   : objeto proxy de conexion al servicio web
            //strCipol   : objeto serializado de sipol,
            //strErro    : string con mensaje de error si lo hubiera.
            //objEncSer  : Objeto de encriptación RSA que contiene la clave pública
            //             del servidor
            //strClave   : Clave de encriptación
            //objEncCli  : Objeto de encriptación RSA que contiene la clave pública
            //             y privada del cliente
            ///'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
            string strUsuario = null;

            COA.WebCipol.Fachada.FInicioSesion facInicioSesion = new COA.WebCipol.Fachada.FInicioSesion();
            string     strCipol    = null;
            string     strError    = "";
            string     strClave    = null;
            string     strTerminal = null;
            mFormLogin objRetIS    = new mFormLogin();

            //Define variables locales.
            //System.Runtime.Serialization.Formatters.Binary.BinaryFormatter objDeserializador;
            //System.IO.MemoryStream objFlujo;

            byte[] bytPub;
            System.Security.Cryptography.RSACryptoServiceProvider objEncServ = new System.Security.Cryptography.RSACryptoServiceProvider();
            System.Security.Cryptography.RSACryptoServiceProvider objEncCli  = new System.Security.Cryptography.RSACryptoServiceProvider();

            EntidadesEmpresariales.PadreCipolCliente objUsuarioCipol;

            TresDES objEncriptarNET;
            General objGeneral;

            try
            {
                strUsuario = NombreUsuario.Trim();
                if (string.IsNullOrEmpty(strUsuario))
                {
                    objRetIS.Mensaje = "El nombre del usuario es un dato obligatorio.";
                    objRetIS.ResultadoProcesoInicioSesion = false;
                    return(objRetIS);
                }
                if (Pwd.Trim() == string.Empty)
                {
                    objRetIS.Mensaje = "La contraseña es un dato obligatorio.";
                    objRetIS.ResultadoProcesoInicioSesion = false;
                    return(objRetIS);
                }

                strClave = Pwd;
                ManejoSesion.CookieMaster = cokie;
                System.Net.CookieContainer objCookieMASTER = ManejoSesion.CookieMaster;

                bytPub = facInicioSesion.GetClavePublica(objEncCli.ExportCspBlob(false), objCookieMASTER);
                if ((bytPub == null))
                {
                    objRetIS.Mensaje = "No se ha podido recuperar la clave pública.";
                    objRetIS.ResultadoProcesoInicioSesion = false;
                    return(objRetIS);
                }
                // Prepara el algoritmo asimétrico del servidor
                objEncServ.ImportCspBlob(bytPub);
                // Encripta con la clave pública
                strClave = System.Convert.ToBase64String(objEncServ.Encrypt(System.Text.UTF8Encoding.UTF8.GetBytes(strClave), false));

                strTerminal = COA.WebCipol.Presentacion.Utiles.cPrincipal.ObtenerTerminal(ip);

                strCipol = facInicioSesion.IniciarSesion(strUsuario, strTerminal, ref strError, strClave, objCookieMASTER);
                if (strCipol == null || string.IsNullOrEmpty(strCipol))
                {
                    objRetIS.Mensaje = "No se ha podido iniciar sesión" + (String.IsNullOrEmpty(strError) ? "" : ": " + strError).ToString();
                    objRetIS.ResultadoProcesoInicioSesion = false;
                    return(objRetIS);
                }
                if (Validaciones.ValidarCadenaNulaOVacia(strError))
                {
                    objRetIS.Mensaje = strError;
                    objRetIS.ResultadoProcesoInicioSesion = false;
                    return(objRetIS);
                }

                //Dim objFlujo As System.IO.MemoryStream
                System.IO.MemoryStream objFlu;
                //Dim objDeserializador As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
                System.Runtime.Serialization.Formatters.Binary.BinaryFormatter objDeser = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                //Dim objSerializar As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
                System.Runtime.Serialization.Formatters.Binary.BinaryFormatter objSerializar = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                //objFlujo = New System.IO.MemoryStream(System.Convert.FromBase64CharArray(pStrCipol.ToCharArray, 0, pStrCipol.Length))
                objFlu = new System.IO.MemoryStream(System.Convert.FromBase64CharArray(strCipol.ToCharArray(), 0, strCipol.Length));

                //gobjUsuarioCipol = CType(objDeserializador.Deserialize(objFlujo), EntidadesEmpresariales.PadreCipolCliente)
                objUsuarioCipol = (EntidadesEmpresariales.PadreCipolCliente)objDeser.Deserialize(objFlu);


                //Desencripta los valores encriptados en el servidor con la clave pública del RSA cliente
                //gobjUsuarioCipol.OtrosDatos("clave.usuario", System.Text.UTF8Encoding.UTF8.GetString(objEncCli.Decrypt(System.Convert.FromBase64String(gobjUsuarioCipol.OtrosDatos("clave.usuario")), False)))
                objUsuarioCipol.OtrosDatos("clave.usuario", System.Text.UTF8Encoding.UTF8.GetString(objEncCli.Decrypt(System.Convert.FromBase64String(objUsuarioCipol.OtrosDatos("clave.usuario")), false)));

                //gobjUsuarioCipol.Key = System.Convert.ToBase64String(objEncCli.Decrypt(System.Convert.FromBase64String(gobjUsuarioCipol.Key), False))
                objUsuarioCipol.Key = System.Convert.ToBase64String(objEncCli.Decrypt(System.Convert.FromBase64String(objUsuarioCipol.Key), false));

                //gobjUsuarioCipol.IV = System.Convert.ToBase64String(objEncCli.Decrypt(System.Convert.FromBase64String(gobjUsuarioCipol.IV), False))
                objUsuarioCipol.IV = System.Convert.ToBase64String(objEncCli.Decrypt(System.Convert.FromBase64String(objUsuarioCipol.IV), false));

                //TODO: VER QUE PASA CON LAS COOKIES
                //gobjUsuarioCipol.objColeccionDeCookies = pCookies
                //objUsuarioCipol.objColeccionDeCookiesCipol =

                //gobjUsuarioCipol.gobjRSAServ = objEncServ.ExportCspBlob(False)
                objUsuarioCipol.gobjRSAServ = objEncServ.ExportCspBlob(false);

                //gobjUsuarioCipol.OtrosDatos("urlwsInicioSesion", UrlWsInicioSesion)

                //objFlujo = New System.IO.MemoryStream()
                //objFlu= new System.IO.MemoryStream();

                //objSerializar.Serialize(objFlujo, gobjUsuarioCipol)
                //objSerializar.Serialize(objFlu, objUsuarioCipol);

                //gstrUsuarioCipol = System.Convert.ToBase64String(objFlujo.ToArray())
                //gstrUsuarioCipol = System.Convert.ToBase64String(objFlujo.ToArray())

                //Crea el objeto para encriptar.
                objEncriptarNET     = new TresDES();
                objEncriptarNET.IV  = objUsuarioCipol.IV;
                objEncriptarNET.Key = objUsuarioCipol.Key;

                //Crea el objeto con datos generales del usuario/sistema.
                objGeneral = new General(System.Reflection.Assembly.GetExecutingAssembly());
                objGeneral.AcercaDe_Descripcion = "Componente de Seguridad. Desarrollado por COA S.A.";
                objGeneral.AcercaDe_Detalle     = "Configurador Interactivo de Políticas de seguridad de los sistemas. Resuelve las funciones operativas propias de la seguridad de sistemas (implementación de políticas, administración de usuarios,  roles, acceso a subsistemas).";
                //TODO: HAY QUE EVALUAR COMO SE TRABAJA CON ESTA INFORMACION SI ES NECESARIA
                //objGeneral.AcercaDe_Logo = objGeneral.RutaArchivos + "img_CIPOL_CIPOL.jpg";
                //objGeneral.AcercaDe_Logo = "Imagenes/prod_cipol.gif";//PRUEBA.. ver la imagen a poner!!
                //objGeneral.AcercaDe_Icono = objGeneral.RutaArchivos + "CIPOL32.ico";
                objGeneral.AcercaDe_Cliente = objUsuarioCipol.NombreOrganizacion;
                objGeneral.UsuarioCIPOL     = objUsuarioCipol.Login;

                objGeneral.Hoy = objUsuarioCipol.FechaServidor;

                //Pasa al objeto Datos Sistema, que se va a guardar en sesión.
                //objDatosS.NombreSistema = objGeneral.NombreSistema;
                //objDatosS.EncriptarNET = objEncriptarNET;
                DatosSistema objDatosS = new DatosSistema();
                objDatosS.DatosGenerales = objGeneral;

                //Pasa al objeto de Retorno.
                objRetIS.DatosSistema = objDatosS;
                DatosCIPOL objDatosC = new DatosCIPOL();
                objDatosC.DatosPadreCIPOLCliente = objUsuarioCipol;
                objDatosC.strCipol = strCipol;

                objDatosC.DatosPadreCIPOLCliente.objColeccionDeCookies      = objCookieMASTER;
                objDatosC.DatosPadreCIPOLCliente.objColeccionDeCookiesCipol = objCookieMASTER;

                objRetIS.DatosCipol = objDatosC;
                objRetIS.Mensaje    = "El proceso de inicio de sesión se realizó exitosamente";
                objRetIS.ResultadoProcesoInicioSesion = true;

                return(objRetIS);
            }
            catch (Exception ex)
            {
                COA.Logger.Logueador.Loggear(ex, System.Diagnostics.EventLogEntryType.Error);
                objRetIS.ResultadoProcesoInicioSesion = false;
                objRetIS.Mensaje = "Ocurrió un error en el proceso de inicio de sesión.";
                return(objRetIS);
            }
        }