Ejemplo n.º 1
0
            public static Tuple <byte[], byte[]> GerarChaves()
            {
                var dna = new Dna();

                var serverKeys = dna.GenerateKeys();
                var clientKeys = dna.GenerateKeys();

                var ServerPrivateKey = serverKeys.Export(CngKeyBlobFormat.EccPrivateBlob);
                var ClientPrivateKey = clientKeys.Export(CngKeyBlobFormat.EccPrivateBlob);

                var ServerPublicKey = serverKeys.Export(CngKeyBlobFormat.EccPublicBlob);
                var ClientPublicKey = clientKeys.Export(CngKeyBlobFormat.EccPublicBlob);

                var derivedKeyServerClient = dna.DeriveKeyMaterial(ServerPrivateKey, ClientPublicKey);
                var derivedKeyClientServer = dna.DeriveKeyMaterial(ClientPrivateKey, ServerPublicKey);

                //ChaveClientServer = derivedKeyClientServer;
                ChaveServerClient = derivedKeyServerClient;

                return(new Tuple <byte[], byte[]>(derivedKeyServerClient, derivedKeyClientServer));
            }
Ejemplo n.º 2
0
            public static string ReceberMensagem(Tuple <byte[], byte[]> message)
            {
                var dna = new Dna();

                return(dna.DecryptMessage(ChaveClientServer, message.Item1, message.Item2));
            }
Ejemplo n.º 3
0
            public static Tuple <byte[], byte[]> EnviarMensagem(string message)
            {
                var dna = new Dna();

                return(dna.EncryptMessage(ChaveClientServer, message));
            }