Ignore:
Timestamp:
Dec 7, 2009, 11:04:32 PM (12 years ago)
Author:
pretzsch
Message:

+ MD5Collider: Added random seed input for reproducible results

Location:
trunk/CrypPlugins/MD5Collider
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/MD5Collider/Algorithm/MD5TunnelCollider.cs

    r957 r965  
    1111        public byte[] FirstCollidingData { get; private set; }
    1212        public byte[] SecondCollidingData { get; private set; }
     13        public byte[] RandomSeed { get; set; }
    1314
    1415        public void FindCollision()
    1516        {
    16             X = (new Random(121).Next(int.MaxValue) << 16) | new Random(2).Next(int.MaxValue);
     17            byte[] seedBytedMd5 = MD5.Create().ComputeHash(RandomSeed);
     18            int seed = BitConverter.ToInt32(seedBytedMd5, 0) ^ BitConverter.ToInt32(seedBytedMd5, 4) ^ BitConverter.ToInt32(seedBytedMd5, 8) ^ BitConverter.ToInt32(seedBytedMd5, 12);
     19            Random rngInitializer = new Random(seed);
     20
     21            X = (rngInitializer.Next(int.MaxValue) << 16) | rngInitializer.Next(int.MaxValue);
    1722            Y = 0x00000001;
    1823
     
    2328        UInt32[] Hx = new UInt32[16];
    2429        UInt32[] P_IHV1 = new UInt32[4], P_HIHV1 = new UInt32[4];
    25         UInt32 pocet_kolizi;
     30        //UInt32 pocet_kolizi;
    2631        byte[] buffer = new byte[2048];
    2732        double cas1 = 0, cas2 = 0, cas3 = 0, cas4 = 0, cas5 = 0;
     
    867872
    868873
    869             pocet_kolizi = 0; cas1 = cas2 = cas3 = cas4 = cas5 = 0;
     874            //pocet_kolizi = 0;
     875            cas1 = cas2 = cas3 = cas4 = cas5 = 0;
    870876            for (; ; )
    871877            {
  • trunk/CrypPlugins/MD5Collider/MD5Collider.cs

    r957 r965  
    1313{
    1414    [Author("Holger Pretzsch", "mail@holger-pretzsch.de", "Uni Duisburg-Essen", "http://www.uni-due.de")]
    15     [PluginInfo(true, "MD5Collider", "MD5 hash collider", "MD5Collider/DetailedDescription/Description.xaml", "MD5Collider/MD5Collider.png")]
     15    [PluginInfo(false, "MD5Collider", "MD5 hash collider", "MD5Collider/DetailedDescription/Description.xaml", "MD5Collider/MD5Collider.png")]
    1616    [EncryptionType(EncryptionType.Classic)]
    1717    class MD5Collider : ICryptographicHash
     
    9595        }
    9696
     97        private byte[] randomSeed;
     98        [PropertyInfo(Direction.InputData, "Random seed", "Data used for initialization of RNG", "", true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
     99        public byte[] RandomSeed
     100        {
     101            get { return randomSeed; }
     102            set
     103            {
     104                this.randomSeed = value;
     105                OnPropertyChanged("RandomSeed");
     106            }
     107        }
     108
    97109        public void Execute()
    98110        {
     111            if (RandomSeed == null)
     112                return;
     113
    99114            ProgressChanged(0.5, 1.0);
     115
    100116            MD5TunnelCollider collider = new MD5TunnelCollider();
     117
     118            collider.RandomSeed = RandomSeed;
    101119            collider.FindCollision();
     120
    102121            OutputData1 = collider.FirstCollidingData;
    103122            OutputData2 = collider.SecondCollidingData;
     123
    104124            ProgressChanged(1.0, 1.0);
    105125        }
Note: See TracChangeset for help on using the changeset viewer.