Changeset 1100


Ignore:
Timestamp:
Jan 20, 2010, 5:46:29 PM (12 years ago)
Author:
arnold
Message:

First testable version of network-comprehensive DES-Bruteforcing with P2PMAnager and P2PWorker.

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/KeySearcher_IControl/KeySearcher_IControl.cs

    r1098 r1100  
    114114        private KeySearcher_IControl keySearcher;
    115115
    116         #region for bruteforcing necessary data
    117         private KeyPattern actualKeyPattern;
    118         private byte[] encryptedData;
    119         private byte[] initVector;
    120         #endregion
    121 
    122         /// <summary>
    123         /// workaround: Flag which will be set, when the OnAllMasterControlsInitialized
    124         /// Event is thrown. So we can assure the correct flow of the KeySearcher
    125         /// </summary>
    126         private bool allMasterControlsInitialized = false;
    127         /// <summary>
    128         /// workaround: Flag which will be set, when a worker wants to
    129         /// bruteforce a pattern, but the MasterControls of the base
    130         /// KeySearcher aren't initialized yet. In this case the pattern
    131         /// will be stored in the variable actualKeyPattern and will be
    132         /// processed when the OnMasterControlsInitialized-Event is thrown
    133         /// </summary>
    134         private bool tryBruteforcingBeforeMastersInitialized = false;
    135 
    136116        public KeySearcherMaster(KeySearcher_IControl keysearcher)
    137117        {
    138118            this.keySearcher = keysearcher;
    139             // this.keySearcher.OnBruteforcingEnded +=new KeySearcher.KeySearcher.BruteforcingEnded(keySearcher_OnBruteforcingEnded);
    140             // subscribe to event before any bruteforcing has started, so we make sure that this event will thrown in every case
    141119            this.keySearcher.OnBruteforcingEnded += new KeySearcher.KeySearcher.BruteforcingEnded(keySearcher_OnBruteforcingEnded);
    142             //this.keySearcher.OnAllMasterControlsInitialized += new KeySearcher_IControl.IsReadyForExecution(keySearcher_OnAllMasterControlsInitialized);
    143120        }
    144121
     
    157134        public void StartBruteforcing(KeyPattern pattern, byte[] encryptedData, byte[] initVector)
    158135        {
    159             // if not all MasterControls are initialized, store the actual
    160             // pattern and wait for throwing the OnMasterControlsInitialized-Event
    161             //if (!allMasterControlsInitialized)
    162             //{
    163             //    tryBruteforcingBeforeMastersInitialized = true;
    164             //    this.actualKeyPattern = pattern;
    165             //    this.encryptedData = encryptedData;
    166             //    this.initVector = initVector;
    167             //    return;
    168             //}
    169             Bruteforcing(pattern, encryptedData, initVector);
    170         }
    171 
    172         /* dirty workaround, because it could happen, that a Worker
    173          * wants to start Bruteforcing before all Master Controls of the base
    174          * KeySearcber (IEncryptionControl und ICostControl) are finally
    175          * initialized, in this case the pattern will be stored and processed
    176          * after this event was thrown. */
    177         //private void keySearcher_OnAllMasterControlsInitialized()
    178         //{
    179         //    this.allMasterControlsInitialized = true;
    180         //    if (this.tryBruteforcingBeforeMastersInitialized)
    181         //    {
    182         //        Bruteforcing(this.actualKeyPattern, this.encryptedData, this.initVector);
    183         //        this.actualKeyPattern = null;
    184         //        this.encryptedData = null;
    185         //        this.initVector = null;
    186 
    187         //        this.tryBruteforcingBeforeMastersInitialized = false;
    188         //    }
    189         //}
    190 
    191         private void Bruteforcing(KeyPattern actualKeyPattern, byte[] encryptedData, byte[] initVector)
    192         {
    193136            //because the KeySearcher object uses this property instead of the parameters in some internal methods... Dirty implementation...
    194             this.keySearcher.Pattern = actualKeyPattern;
     137            this.keySearcher.Pattern = pattern;
    195138            //necessary, because the Pattern property seems to work incorrect
    196             this.keySearcher.Pattern.WildcardKey = actualKeyPattern.WildcardKey;
     139            this.keySearcher.Pattern.WildcardKey = pattern.WildcardKey;
    197140
    198141            //New stuff because of changing the IControl data flow - Arnie 2010.01.18
    199142
    200             this.keySearcher.BruteforcePattern(actualKeyPattern, encryptedData, initVector, this.keySearcher.ControlMaster, this.keySearcher.CostMaster);
     143            this.keySearcher.BruteforcePattern(pattern, encryptedData, initVector, this.keySearcher.ControlMaster, this.keySearcher.CostMaster);
    201144        }
    202145
  • trunk/CrypPlugins/PeerToPeerSubscriber/P2PSubscriberBase.cs

    r1098 r1100  
    119119            // if bolStopped = true, the Timer for Checking Publishers liveliness doesn't start
    120120            this.bolStopped = false;
    121             PeerId pubId = CheckPublisherAvailability();
    122             // if DHT Entry for Task is empty, there exist no Publisher at present.
    123             // The method PublisherIsAlive starts a Timer for this case to continous proof Publisher-DHT-Entry
    124             if (pubId != null)
    125             {
    126                 SendMessage(pubId, PubSubMessageType.Register);
    127                 if (this.timeoutForPublishersRegAccept == null)
    128                     this.timeoutForPublishersRegAccept = new Timer(OnTimeoutRegisteringAccepted, null, this.publisherReplyTimespan, this.publisherReplyTimespan);
    129                 this.started = true;
    130             }
    131             else
     121            PeerId pubId = CheckPublishersAvailability();
     122            // if DHT Entry for the task is empty, no Publisher exists at present.
     123            // The method CheckPublishersAvailability starts a Timer for this case to continous proof Publisher-DHT-Entry
     124            if (pubId == null)
    132125            {
    133126                this.Started = false;
    134127                // if PubId is null, the Publisher isn't started!
    135128                this.bolStopped = true;
    136             }
     129                GuiLogging("No publisher for registering found.", NotificationLevel.Info);
     130                return;
     131            }
     132
     133            // when the actual publisher differs from the new detected publisher, change it
     134            if (pubId != null && (actualPublisher != null && actualPublisher != pubId))
     135            {
     136                GuiLogging("Publisher has been changed from ID '" + actualPublisher + "' to '" + pubId + "'", NotificationLevel.Debug);
     137                actualPublisher = pubId;
     138            }
     139            SendMessage(pubId, PubSubMessageType.Register);
     140            if (this.timeoutForPublishersRegAccept == null)
     141                this.timeoutForPublishersRegAccept = new Timer(OnTimeoutRegisteringAccepted, null, this.publisherReplyTimespan, this.publisherReplyTimespan);
     142            this.started = true;
    137143        }
    138144
     
    254260        private void OnRegisteringNotPossible(object state)
    255261        {
    256             PeerId pubId = CheckPublisherAvailability();
    257             // if DHT Entry for Task is empty, there exist no Publisher at present.
    258             // The method PublisherIsAlive starts a Timer for this case to continous proof Publisher-DHT-Entry
    259             if (pubId != null)
    260                 SendMessage(pubId, PubSubMessageType.Register);
    261             else
    262                 GuiLogging("No publisher for registering found.", NotificationLevel.Info);
     262            Register();
    263263        }
    264264
     
    275275        /// </summary>
    276276        /// <returns>the actual Publishers ID or null, when a publisher wasn't found in the DHT</returns>
    277         private PeerId CheckPublisherAvailability()
     277        private PeerId CheckPublishersAvailability()
    278278        {
    279279            PeerId pid = DHT_CommonManagement.GetTopicsPublisherId(ref this.p2pControl, this.sTopic);
     
    287287                }
    288288                GuiLogging("Publisher wasn't found in DHT or settings didn't stored on the right way.", NotificationLevel.Debug);
    289                 //GuiLogging("Publisher wasn't found in DHT or settings didn't stored on the right way.", NotificationLevel.Warning);
    290289                return null;
    291290            }
     
    303302                actualPublisher = pid;
    304303                GuiLogging("First time received publishers ID.", NotificationLevel.Debug);
    305             }
    306             else if (actualPublisher != pid)
    307             {
    308                 GuiLogging("Publisher has been changed from ID '" +  actualPublisher + "' to '" + pid + "'", NotificationLevel.Debug);
    309                 actualPublisher = pid;
    310                 // because the publisher has changed, send a new register msg
    311                 SendMessage(actualPublisher, PubSubMessageType.Register);
    312304            }
    313305
     
    329321        private void OnCheckPubAvailability(object state)
    330322        {
    331             PeerId newPubId = CheckPublisherAvailability();
     323            PeerId newPubId = CheckPublishersAvailability();
    332324
    333325            if (newPubId == actualPublisher)
     
    367359            }
    368360            // try to get an active publisher and re-register
    369             CheckPublisherAvailability();
     361            CheckPublishersAvailability();
    370362        }
    371363
  • trunk/CrypPlugins/PeerToPeerWorker/P2PWorkerBase.cs

    r1098 r1100  
    175175        private void StartProcessing(KeyPattern receivedKeyPattern)
    176176        {
    177             GuiLogging("Start Bruteforcing the incoming WildCardKey: '" + receivedKeyPattern.WildcardKey + "'", NotificationLevel.Info);
     177            GuiLogging("Start Bruteforcing the incoming Key: '" + receivedKeyPattern.getKey() + "', WildCardKey: '" + receivedKeyPattern.WildcardKey + "'", NotificationLevel.Info);
    178178
    179179            if (OnKeyPatternReceived != null)
     
    186186
    187187            GuiLogging("BEGIN: Retrieving encryption information from the DHT.", NotificationLevel.Debug);
    188             //byte[] encryptedData = this.p2pControl.DHTload(sTopicName + "EncryptedText");
    189             //byte[] initVector = this.p2pControl.DHTload(sTopicName + "InitializationVector");
    190188            byte[] encryptedData = DHT_CommonManagement.GetEncryptedData(ref this.p2pControl, sTopicName);
    191189            byte[] initVector = DHT_CommonManagement.GetInitializationVector(ref this.p2pControl, sTopicName);
Note: See TracChangeset for help on using the changeset viewer.