Ignore:
Timestamp:
Feb 21, 2010, 8:25:11 PM (12 years ago)
Author:
Arno Wacker
Message:

KeySearcher:

  • Removed creation of CryptoolStream for each trial key -> performance boost
  • Re-integrated the usage of only the partial encrypted message for trial decryption (byteToUse). Now the value set in the costFunction will determine how many bytes will be used. This value shall be moved in the future to the KeySearcher settings.

IControlEncryption

  • Added an extended method for Decrypt to IControlEncryption for usage with bytesToUse

AES/DES/SDES

  • Updated for compatibility with IControlEncryption-changes (the new parameter is also used by all three)

Samples

  • Updated KeySearcher-Sample-DES to use only 128 bytes for bruteforcing instead of 256 (increase performance a little)

Note: providing a value for bytesToUse smaller than the blocksize of the algorithm used is an error case - not sure if every case is already covered.

File:
1 edited

Legend:

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

    r1161 r1162  
    105105                {
    106106                    this.csEncryptedData = value;
    107                     cryptoolStreamChanged = true;
     107                    this.encryptedData = GetByteFromCryptoolStream(value);
    108108                    OnPropertyChanged("CSEncryptedData");
    109109                }
     
    121121                {
    122122                    this.encryptedData = value;
    123                     cryptoolStreamChanged = true;
    124123                    OnPropertyChanged("EncryptedData");
    125124                }
     
    130129        /// When the Input-Slot changed, set this variable to true, so the new Stream will be transformed to byte[]
    131130        /// </summary>
    132         private bool cryptoolStreamChanged = false;
    133         private byte[] encryptedByteData;
    134131        private byte[] GetByteFromCryptoolStream(CryptoolStream cryptoolStream)
    135132        {
    136             // only transform CryptoolStream to Byte[], if there is a new CryptoolStream
    137             // or decryptedByteData is Null
    138             if (cryptoolStreamChanged || encryptedByteData == null)
     133            byte[] encryptedByteData = null;
     134
     135            if (cryptoolStream != null)
    139136            {
    140137                CryptoolStream cs = new CryptoolStream();
     
    228225        {
    229226            //either byte[] CStream input or CryptoolStream Object input
    230             if (this.EncryptedData != null || this.CSEncryptedData != null) //to prevent execution on initialization
     227            if (this.encryptedData != null || this.csEncryptedData != null) //to prevent execution on initialization
    231228            {
    232229                if (this.ControlMaster != null)
     
    446443            try
    447444            {
    448                 CryptoolStream cs = new CryptoolStream();
    449                 if (this.CSEncryptedData == null)
    450                 {
    451                     cs.OpenRead(this.EncryptedData);
    452                     valueKey.decryption = sender.Decrypt(this.EncryptedData, keya);
     445                if (this.encryptedData != null && this.encryptedData.Length > 0)
     446                {
     447                    valueKey.decryption = sender.Decrypt(this.encryptedData, keya, bytesToUse);
    453448                }
    454449                else
    455450                {
    456                     cs.OpenRead(this.CSEncryptedData.FileName);
    457                     byte[] byteCS = new byte[cs.Length];
    458                     cs.Read(byteCS, 0, byteCS.Length);
    459                     //this.CSEncryptedData.Read(byteCS, 0, byteCS.Length);
    460                     valueKey.decryption = sender.Decrypt(byteCS, keya);
    461                 }
     451                    GuiLogMessage("Can't bruteforce empty input!", NotificationLevel.Error);
     452                    return false;
     453                }
     454                //CryptoolStream cs = new CryptoolStream();
     455                //if (this.CSEncryptedData == null)
     456                //{
     457                //    cs.OpenRead(this.EncryptedData);
     458                //    valueKey.decryption = sender.Decrypt(this.EncryptedData, keya);
     459                //}
     460                //else
     461                //{
     462                //    cs.OpenRead(this.CSEncryptedData.FileName);
     463                //    byte[] byteCS = new byte[cs.Length];
     464                //    cs.Read(byteCS, 0, byteCS.Length);
     465                //    //this.CSEncryptedData.Read(byteCS, 0, byteCS.Length);
     466                //    valueKey.decryption = sender.Decrypt(byteCS, keya);
     467                //}
    462468
    463469                //valueKey.decryption = sender.Decrypt(keya, bytesToUse);
     
    860866        {
    861867            /* Begin: New stuff because of changing the IControl data flow - Arnie 2010.01.18 */
    862             this.EncryptedData = encryptedData;
    863             this.InitVector = initVector;
     868            this.encryptedData = encryptedData;
     869            this.initVector = initVector;
    864870            /* End: New stuff because of changing the IControl data flow - Arnie 2010.01.18 */
    865871           
Note: See TracChangeset for help on using the changeset viewer.