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)); }
public static string ReceberMensagem(Tuple <byte[], byte[]> message) { var dna = new Dna(); return(dna.DecryptMessage(ChaveClientServer, message.Item1, message.Item2)); }
public static Tuple <byte[], byte[]> EnviarMensagem(string message) { var dna = new Dna(); return(dna.EncryptMessage(ChaveClientServer, message)); }