Beispiel #1
0
        public static TherapeuteDB Connexion(string login, string pass)
        {
            //permet au TU de donner la fausse BD
            if (conn == null)
            {
                bdd = new ReaPlanDBEntities();
                UiServices.SetBusyState();
            }
            else
            {
                bdd = new ReaPlanDBEntities(conn);
            }

            //Cryptage du mot de passe entré pour le comparer avec le mdp crypté de la bd
            if (pass != null && login != null)
            {
                string       password      = login.ToLower() + pass;
                UTF8Encoding textConverter = new UTF8Encoding();
                byte[]       passBytes     = textConverter.GetBytes(password);
                pass = Convert.ToBase64String(new SHA384Managed().ComputeHash(passBytes));
            }

            using (bdd)
            {
                var requete = from c in bdd.TherapeuteDBs
                              where c.Login == login &&
                              c.MotDePasse == pass
                              select c;
                TherapeuteDB therapeute = requete.FirstOrDefault();
                return(therapeute);
            }
        }
Beispiel #2
0
        public void Cryptanalysis()
        {
            try
            {
                UiServices.SetBusyState();
                Paragraph paragraph = new Paragraph();
                paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonCryptanalysis + " **\r\n"))));
                paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext)));
                paragraph.Inlines.Add(" " + Cipher + "\r\n");

                Message = MerkleHellman.Cryptanalysis(cipher, paragraph);

                if (History.Document.Blocks.FirstBlock != null)
                {
                    History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph);
                }
                else
                {
                    History.Document.Blocks.Add(paragraph);
                }

                NotifyPropertyChanged("Message");
            }
            catch (Exception)
            {
                MessageBox.Show(Languages.errorNoSolutionFound, Languages.error, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            NotifyPropertyChanged("Message");
        }
Beispiel #3
0
        public void GenerateNewGGH(int dim, int l)
        {
            UiServices.SetBusyState();
            GGH = GGH != null && GGH.dim == dim ? new GGHModel(dim, l, GGH.errorVector) : new GGHModel(dim, l);

            Paragraph paragraph = new Paragraph();

            paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonGenerateNewCryptosystem + " **\r\n"))));
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrivateKeyR + ":")));
            paragraph.Inlines.Add(" " + GGH.privateKeyR + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrivateKeyR1 + ":")));
            paragraph.Inlines.Add(" " + GGH.privateKeyR1.ToStringLog() + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPublicKeyB + ":")));
            paragraph.Inlines.Add(" " + GGH.publicKeyB + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPublicKeyB1 + ":")));
            paragraph.Inlines.Add(" " + GGH.publicKeyB1.ToStringLog() + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelUnimodularTransformationMatrix + ":")));
            paragraph.Inlines.Add(" " + Lattice.LatticeTransformationToString() + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelParameterL)));
            paragraph.Inlines.Add(" " + GGH.l + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelErrorVector)));
            paragraph.Inlines.Add(" " + GGH.errorVector + "\r\n");

            if (History.Document.Blocks.FirstBlock != null)
            {
                History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph);
            }
            else
            {
                History.Document.Blocks.Add(paragraph);
            }

            NotifyPropertyChanged("ErrorVector");
        }
Beispiel #4
0
        public void GenerateNewLattice(int n, int m, BigInteger codomainStart, BigInteger codomainEnd)
        {
            UiServices.SetBusyState();

            LatticeND newLattice = new LatticeND(n, m, false);

            //Zur Generierung von kritischen Gittern
            //while (Math.Round(newLattice.AngleReducedVectors, 0) != 60)
            //{
            newLattice.GenerateRandomVectors(ReductionMethod == ReductionMethods.reduceGauss, codomainStart, codomainEnd);

            switch (ReductionMethod)
            {
            case ReductionMethods.reduceGauss:
                newLattice.GaussianReduce();
                break;

            default:
                newLattice.LLLReduce();
                break;
            }
            //}
            Lattice = newLattice;

            WriteHistoryForNewLattice(Languages.buttonGenerateNewLattice);

            NotifyPropertyChanged("Lattice");
        }
        protected override void LoadChildren()
        {
            UiServices.SetBusyState();

            var bookLookup = Directory
                             .GetFiles(ArtFilesSourcePath, "*.*", SearchOption.AllDirectories)
                             .Where(n => ValidRegex.IsMatch(Path.GetFileName(n) ?? ""))
                             .Select(n => new ArtFile(n))
                             .ToLookup(k => new { k.Id, k.BookType, k.Name });

            var books = bookLookup
                        .Select(v => new BookTreeViewItemViewModel(this)
            {
                BookType       = v.Key.BookType,
                Name           = v.Key.Name,
                ItemId         = v.Key.Id,
                PageSourcePath = ArtFilesSourcePath,
                ArtFiles       = bookLookup[v.Key].ToList()
            })
                        .OrderBy(v => v.BookType);

            foreach (var bookViewModel in books)
            {
                var firstPdf = bookViewModel.ArtFiles.FirstOrDefault(b => b.ArtFileType == ArtFileType.Pdf);
                if (firstPdf != null)
                {
                    bookViewModel.PageSourcePath = firstPdf.ParentPath;
                }

                Children.Add(bookViewModel);
            }
        }
 private void _reloadFiles(MediaDirectoryViewmodel directory)
 {
     if (directory?.IsInitialized == true && (!directory.IsIngestDirectory || directory.IsImport))
     {
         UiServices.SetBusyState();
         if (_mediaItems != null)
         {
             foreach (var m in _mediaItems)
             {
                 m.Dispose();
             }
         }
         MediaItems = new ObservableCollection <MediaViewViewmodel>(directory.Directory.GetFiles().Select(f => new MediaViewViewmodel(f)));
         _mediaView = CollectionViewSource.GetDefaultView(_mediaItems);
         if (!directory.IsXdcam)
         {
             _mediaView.SortDescriptions.Add(new SortDescription(nameof(MediaViewViewmodel.MediaName), ListSortDirection.Ascending));
         }
         if (!directory.IsArchiveDirectory)
         {
             _mediaView.Filter = _filter;
         }
         if (directory.IsXdcam && !directory.IsWan)
         {
             ThreadPool.QueueUserWorkItem(o => _refreshMediaDirectory(directory.Directory));
         }
     }
     else
     {
         MediaItems = null;
     }
 }
Beispiel #7
0
        public void GenerateNewRSA(int bitSize)
        {
            UiServices.SetBusyState();
            RSAModel = new RSAModel(bitSize);

            Paragraph paragraph = new Paragraph();

            paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonGenerateNewCryptosystem + " **\r\n"))));
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrimeP)));
            paragraph.Inlines.Add(" " + PrimP + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrimeQ)));
            paragraph.Inlines.Add(" " + PrimQ + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelModulus)));
            paragraph.Inlines.Add(" " + ModulusN + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrivateExponentD)));
            paragraph.Inlines.Add(" " + ExpD + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPublicExponentE)));
            paragraph.Inlines.Add(" " + ExpE + "\r\n");

            if (History.Document.Blocks.FirstBlock != null)
            {
                History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph);
            }
            else
            {
                History.Document.Blocks.Add(paragraph);
            }

            NotifyPropertyChanged("PrimP");
            NotifyPropertyChanged("PrimQ");
            NotifyPropertyChanged("ModulusN");
            NotifyPropertyChanged("ExpD");
            NotifyPropertyChanged("ExpE");
            NotifyPropertyChanged("ValidationInfo");
        }
Beispiel #8
0
        public void Encrypt()
        {
            UiServices.SetBusyState();
            MatrixND mesMat = new MatrixND(1, 1);

            mesMat[0, 0] = int.Parse(Message);
            Cipher       = LWE.Encrypt(mesMat)[0, 0].ToString();

            Paragraph paragraph = new Paragraph();

            paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonEncrypt + " **\r\n"))));
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPlainText)));
            paragraph.Inlines.Add(" " + Message + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext)));
            paragraph.Inlines.Add(" " + Cipher + "\r\n");

            if (History.Document.Blocks.FirstBlock != null)
            {
                History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph);
            }
            else
            {
                History.Document.Blocks.Add(paragraph);
            }

            NotifyPropertyChanged("Cipher");
        }
Beispiel #9
0
        public void Decrypt()
        {
            UiServices.SetBusyState();
            Paragraph paragraph = new Paragraph();

            try
            {
                Message = LWE.Decrypt(cipher)[0, 0].ToString();
                paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonDecrypt + " **\r\n"))));
                paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext)));
                paragraph.Inlines.Add(" " + Cipher + "\r\n");
                paragraph.Inlines.Add(new Bold(new Run(Languages.labelPlainText)));
                paragraph.Inlines.Add(" " + Message + "\r\n");
                NotifyPropertyChanged("Message");
            }
            catch (Exception ex)
            {
                paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonDecrypt + " **\r\n"))));
                paragraph.Inlines.Add(new Bold(new Underline(new Run(Languages.labelAbort))));
                paragraph.Inlines.Add(" " + ex.Message + "\r\n");

                MessageBox.Show(string.Format(Languages.errorDecryptionError, ex.Message), Languages.error, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                if (History.Document.Blocks.FirstBlock != null)
                {
                    History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph);
                }
                else
                {
                    History.Document.Blocks.Add(paragraph);
                }
            }
        }
        //Méthode appellé quand on clique sur le boutton Previous
        private void btPrev_Click(object sender, RoutedEventArgs e)
        {
            int posi = int.Parse((string)NumPage.Content);

            posi--;
            NumPage.Content  = posi.ToString();
            btNext.IsEnabled = true;
            UiServices.SetBusyState();
            verifCheck();
        }
Beispiel #11
0
 protected void LoadChildrens()
 {
     UiServices.SetBusyState();
     foreach (IEvent se in Event.SubEvents)
     {
         Childrens.Add(CreateChildEventPanelViewmodelForEvent(se));
         IEvent ne = se.Next;
         while (ne != null)
         {
             Childrens.Add(CreateChildEventPanelViewmodelForEvent(ne));
             ne = ne.Next;
         }
     }
 }
Beispiel #12
0
        public void GenerateNewMerkleHellman(int dim)
        {
            UiServices.SetBusyState();
            MerkleHellman = new MerkleHellmanModel(dim);

            WriteHistoryForNewCryptosystem(Languages.buttonGenerateNewLattice);

            NotifyPropertyChanged("MerkleHellman");
            NotifyPropertyChanged("PrivateKey");
            NotifyPropertyChanged("PublicKey");
            NotifyPropertyChanged("Mod");
            NotifyPropertyChanged("R");
            NotifyPropertyChanged("RI");
        }
Beispiel #13
0
		protected override void LoadChildren()
		{
			UiServices.SetBusyState();

			var projectDirs = JobFolderRepo.JobFolders
					.Where(d => _catRegex.IsMatch(Path.GetFileName(d) ?? ""))
					.OrderBy(Path.GetFileName)
					.ToList();

			foreach (var projectDir in projectDirs)
			{
				Children.Add(new ProjectViewModel(projectDir, this));
			}
		}
Beispiel #14
0
        public void Handle(BookSelectedEvent message)
        {
            UiServices.SetBusyState();

            var bvm = new BookViewModel(_progressViewModel, _windowManager, message.BookTreeViewItemViewModel);

            if (!message.IsSelected)
            {
                DeactivateItem(bvm, true);
                ActiveItem = null;
                return;
            }

            ActivateItem(bvm);
        }
Beispiel #15
0
 protected void ClearChildrens()
 {
     if (!Childrens.Any())
     {
         return;
     }
     if (!HasDummyChild)
     {
         UiServices.SetBusyState();
         foreach (var c in Childrens.ToList())
         {
             c.Dispose();
         }
         if (Event.SubEventsCount > 0)
         {
             Childrens.Add(DummyChild);
         }
     }
 }
Beispiel #16
0
        private void btn_buildHSS_Click(object sender, RoutedEventArgs e)
        {
            UiServices.SetBusyState();
            hssp hss = new hssp();

            hss.source = grid.file_def;

            if (path.Length > 1)
            {
                using (new WaitCursor())
                {
                    hss.build_package_references(tb_templatedir.Text);
                    hss.buildHSS(delim, grid.startYear, grid.endYear, path);
                }
            }
            else
            {
                MessageBox.Show("Invalid output folder", "Error");
            }
        }
Beispiel #17
0
        public void Cryptanalysis()
        {
            UiServices.SetBusyState();
            Paragraph paragraph = new Paragraph();

            try
            {
                paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonCryptanalysis + " **\r\n"))));
                paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext)));
                paragraph.Inlines.Add(" " + Cipher + "\r\n");
                paragraph.Inlines.Add(new Bold(new Run(Languages.labelKnownPlainText)));
                paragraph.Inlines.Add(" " + KnownMessage + "\r\n");

                string left  = message.Substring(0, unknownStart);
                string right = message.Substring(unknownStart + unknownLength);
                UnknownMessageResult = RSAModel.StereotypedAttack(left, right, unknownLength, cipher, "4");

                paragraph.Inlines.Add(new Bold(new Run(Languages.labelResultUnknownPlainText)));
                paragraph.Inlines.Add(" " + UnknownMessageResult + "\r\n");
            }
            catch (Exception ex)
            {
                UnknownMessageResult = "";

                paragraph.Inlines.Add(new Bold(new Run(Languages.labelAbort)));
                paragraph.Inlines.Add(" " + ex.Message + "\r\n");

                MessageBox.Show(ex.Message, Languages.error, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                if (History.Document.Blocks.FirstBlock != null)
                {
                    History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph);
                }
                else
                {
                    History.Document.Blocks.Add(paragraph);
                }
            }
        }
Beispiel #18
0
        public void SetLatticeManually(LatticeND newLattice)
        {
            UiServices.SetBusyState();

            Lattice = new LatticeND(newLattice.Vectors, newLattice.UseRowVectors);

            switch (ReductionMethod)
            {
            case ReductionMethods.reduceGauss:
                Lattice.GaussianReduce();
                break;

            default:
                Lattice.LLLReduce();
                break;
            }

            WriteHistoryForNewLattice(Languages.buttonDefineNewLattice);

            NotifyPropertyChanged("Lattice");
        }
Beispiel #19
0
        public void Encrypt()
        {
            if (!ValidateCryptosystem())
            {
                return;
            }

            UiServices.SetBusyState();
            Message = Message.TrimEnd('\0');
            Cipher  = GGH.Encrypt(Message).ToString();

            Paragraph paragraph = new Paragraph();

            paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonEncrypt + " **\r\n"))));
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPlainText)));
            paragraph.Inlines.Add(" " + Message + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext)));
            paragraph.Inlines.Add(" " + Cipher + "\r\n");

            History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph);

            NotifyPropertyChanged("Cipher");
        }
Beispiel #20
0
        public void GenerateNewLWE(int dim, int q)
        {
            UiServices.SetBusyState();

            LWE = new LWEModel(dim, 1, q, true);
            LWE.GenerateNewRandomVector();

            Paragraph paragraph = new Paragraph();

            paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonGenerateNewCryptosystem + " **\r\n"))));
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPrivateKeyS + ":")));
            paragraph.Inlines.Add(" " + LWE.S + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPublicKeyA + ":")));
            paragraph.Inlines.Add(" " + LWE.A + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelAlpha)));
            paragraph.Inlines.Add(" " + Util.FormatDoubleLog(LWE.alpha) + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPublicKeyB2 + ":")));
            paragraph.Inlines.Add(" " + LWE.B + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelModuloQ)));
            paragraph.Inlines.Add(" " + LWE.q + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelRandomVectorR)));
            paragraph.Inlines.Add(" " + MatrixND.Transpose(LWE.r) + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelSubsetU)));
            paragraph.Inlines.Add(" " + MatrixND.Transpose(LWE.u) + "\r\n");

            if (History.Document.Blocks.FirstBlock != null)
            {
                History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph);
            }
            else
            {
                History.Document.Blocks.Add(paragraph);
            }

            NotifyPropertyChanged("RandomVectorR");
            NotifyPropertyChanged("SubsetU");
        }
Beispiel #21
0
        public void Decrypt()
        {
            UiServices.SetBusyState();
            Message = RSAModel.Decrypt(cipher);

            Paragraph paragraph = new Paragraph();

            paragraph.Inlines.Add(new Bold(new Underline(new Run("** " + Languages.buttonDecrypt + " **\r\n"))));
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelCiphertext)));
            paragraph.Inlines.Add(" " + Cipher + "\r\n");
            paragraph.Inlines.Add(new Bold(new Run(Languages.labelPlainText)));
            paragraph.Inlines.Add(" " + Message + "\r\n");

            if (History.Document.Blocks.FirstBlock != null)
            {
                History.Document.Blocks.InsertBefore(History.Document.Blocks.FirstBlock, paragraph);
            }
            else
            {
                History.Document.Blocks.Add(paragraph);
            }

            NotifyPropertyChanged("Message");
        }
 private void ch_Checked(object sender, RoutedEventArgs e)
 {
     UiServices.SetBusyState();
     verifCheck();
 }