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/AES/AES.cs

    r1157 r1162  
    496496        }
    497497
    498        
    499 
    500498        public byte[] Decrypt(byte[] ciphertext, byte[] key)
    501499        {
     500            return Decrypt(ciphertext, key, ciphertext.Length);
     501        }
     502
     503        public byte[] Decrypt(byte[] ciphertext, byte[] key, int bytesToUse)
     504        {
    502505            CryptoStream crypto_stream = null;
    503             byte[] output = new byte[ciphertext.Length];
     506            int size = bytesToUse > ciphertext.Length ? ciphertext.Length : bytesToUse;
     507
     508            byte[] output = new byte[size];
    504509
    505510
     
    532537                }
    533538
    534                 crypto_stream = new CryptoStream(new MemoryStream(ciphertext), p_decryptor, CryptoStreamMode.Read);
     539                crypto_stream = new CryptoStream(new MemoryStream(ciphertext, 0, size), p_decryptor, CryptoStreamMode.Read);
    535540
    536541                byte[] buffer = new byte[aes_algorithm.BlockSize / 8];
Note: See TracChangeset for help on using the changeset viewer.