Changeset 1162 for trunk/CrypPlugins/DES


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

    r1157 r1162  
    545545        }
    546546
     547        public byte[] Decrypt(byte[] ciphertext, byte[] key)
     548        {
     549            return Decrypt(ciphertext, key, ciphertext.Length);
     550        }
     551
    547552        // TODO: add override with iv, mode, blocksize
    548         public byte[] Decrypt(byte[] ciphertext, byte[] key)
     553        public byte[] Decrypt(byte[] ciphertext, byte[] key, int bytesToUse)
    549554        {
    550555            CryptoStream crypto_stream = null;
    551             byte[] output = new byte[ciphertext.Length];
     556            int size = bytesToUse > ciphertext.Length ? ciphertext.Length : bytesToUse;
     557
     558            byte[] output = new byte[size];
    552559           
    553560            // always recreating this instance is thread-safe, but may cost us some performance
     
    595602            }
    596603
    597             crypto_stream = new CryptoStream(new MemoryStream(ciphertext), p_decryptor, CryptoStreamMode.Read);
     604            crypto_stream = new CryptoStream(new MemoryStream(ciphertext,0,size), p_decryptor, CryptoStreamMode.Read);
    598605
    599606            int read, readOverall = 0;
Note: See TracChangeset for help on using the changeset viewer.