source: trunk/CrypPlugins/KeySearcher/P2P/DistributedBruteForceManager.cs

Last change on this file was 8983, checked in by kopal, 9 months ago

Complete CrypTool 2 project

  • renamed "Cryptool" namespace to "CrypTool" namespace
File size: 3.5 KB
RevLine 
[1634]1using System;
[2024]2using System.Collections.Generic;
[1682]3using System.Diagnostics;
[1643]4using System.Numerics;
[2115]5using System.Threading;
[6301]6using System.Windows.Threading; 
[8983]7using CrypTool.PluginBase;
[1634]8using KeySearcher.Helper;
[1674]9using KeySearcher.KeyPattern;
[1647]10using KeySearcher.P2P.Exceptions;
[1707]11using KeySearcher.P2P.Helper;
[1682]12using KeySearcher.P2P.Presentation;
[1674]13using KeySearcher.P2P.Storage;
14using KeySearcher.P2P.Tree;
[2866]15using KeySearcher.Presentation;
16using KeySearcher.Presentation.Controls;
[1682]17using KeySearcherPresentation.Controls;
[2295]18using KeySearcher.Properties;
[2024]19using System.Timers;
[2115]20using Timer = System.Timers.Timer;
[1634]21
22namespace KeySearcher.P2P
23{
[1674]24    internal class DistributedBruteForceManager
[1634]25    {
[1674]26        private readonly StorageKeyGenerator keyGenerator;
27        private readonly KeySearcher keySearcher;
[1682]28        private readonly KeySearcherSettings settings;
[1707]29        private readonly KeyQualityHelper keyQualityHelper;
[1682]30        private readonly P2PQuickWatchPresentation quickWatch;
[2866]31        private readonly KeyPoolTreePresentation _keyPoolTreePresentation;
[1674]32        private readonly KeyPatternPool patternPool;
[1682]33        private readonly StatusContainer status;
34        internal readonly StatisticsGenerator StatisticsGenerator;
35        internal readonly Stopwatch StopWatch;
[1634]36
[1707]37        private KeyPoolTree keyPoolTree;
[2115]38        private AutoResetEvent systemJoinEvent = new AutoResetEvent(false);
[1707]39
[1674]40        public DistributedBruteForceManager(KeySearcher keySearcher, KeyPattern.KeyPattern keyPattern, KeySearcherSettings settings,
[2866]41                                            KeyQualityHelper keyQualityHelper, P2PQuickWatchPresentation quickWatch, KeyPoolTreePresentation keyPoolTreePresentation)
[1634]42        {
[1674]43            this.keySearcher = keySearcher;
[1682]44            this.settings = settings;
[1707]45            this.keyQualityHelper = keyQualityHelper;
[1682]46            this.quickWatch = quickWatch;
[2866]47            _keyPoolTreePresentation = keyPoolTreePresentation;
[1634]48
[1647]49            // TODO when setting is still default (21), it is only displayed as 21 - but the settings-instance contains 0 for that key!
[6509]50            if (settings.NumberOfBlocks == 0)
[1634]51            {
[6509]52                settings.NumberOfBlocks = 3;
[1634]53            }
54
[1698]55            StopWatch = new Stopwatch();
[2078]56            status = new StatusContainer(keySearcher);
[1698]57            status.IsCurrentProgressIndeterminate = true;
58
[1674]59            keyGenerator = new StorageKeyGenerator(keySearcher, settings);
[6509]60            patternPool = new KeyPatternPool(keyPattern, new BigInteger(Math.Pow(2, settings.NumberOfBlocks)));
[1682]61            StatisticsGenerator = new StatisticsGenerator(status, quickWatch, keySearcher, settings, this);
62            quickWatch.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(UpdateStatusContainerInQuickWatch));
[2866]63
64            _keyPoolTreePresentation.PatternPool = patternPool;
65            _keyPoolTreePresentation.KeyQualityHelper = keyQualityHelper;
66            _keyPoolTreePresentation.KeyGenerator = keyGenerator;
67            _keyPoolTreePresentation.StatusContainer = status;
[1707]68        }
[1682]69
[1707]70        public void Execute()
71        {
[2295]72            status.CurrentOperation = Resources.Initializing_connection_to_the_peer_to_peer_system;
[1707]73            new ConnectionHelper(keySearcher, settings).ValidateConnectionToPeerToPeerSystem();
[1634]74        }
[1682]75
[2884]76
[1682]77        private void UpdateStatusContainerInQuickWatch()
78        {
79            quickWatch.DataContext = status;
80            quickWatch.UpdateSettings(keySearcher, settings);
81        }
[1634]82    }
[1674]83}
Note: See TracBrowser for help on using the repository browser.