Changeset 2087


Ignore:
Timestamp:
Nov 14, 2010, 6:03:32 PM (11 years ago)
Author:
Sven Rech
Message:

keysearcher opencl fix

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPluginBase/Control/KeyTranslator.cs

    r2086 r2087  
    8282        /// <returns></returns>
    8383        bool NextOpenCLBatch();
     84
     85        /// <summary>
     86        /// Gets the opencl batch size.
     87        /// </summary>
     88        /// <returns></returns>
     89        int GetOpenCLBatchSize();
    8490    }
    8591}
  • trunk/CrypPlugins/KeySearcher/KeySearcher.cs

    r2086 r2087  
    429429        private unsafe bool BruteforceOpenCL(KeySearcherOpenCLCode keySearcherOpenCLCode, IKeyTranslator keyTranslator, IControlEncryption sender, int bytesToUse)
    430430        {
    431             float[] costArray = new float[keySearcherOpenCLCode.GetBruteforceBlock()];
     431            float[] costArray = null;
    432432            try
    433433            {
    434434                Kernel bruteforceKernel = keySearcherOpenCLCode.GetBruteforceKernel(oclManager, keyTranslator);
     435                costArray = new float[keyTranslator.GetOpenCLBatchSize()];
    435436                int deviceIndex = settings.OpenCLDevice;
    436437               
    437438                Mem costs = oclManager.Context.CreateBuffer(MemFlags.READ_ONLY, costArray.Length * 4);
    438                 IntPtr[] globalWorkSize = { (IntPtr)keySearcherOpenCLCode.GetBruteforceBlock() };
     439                IntPtr[] globalWorkSize = { (IntPtr)keyTranslator.GetOpenCLBatchSize() };
    439440
    440441                Mem userKey;
  • trunk/CrypPlugins/KeySearcher/KeyTranslators/ByteArrayKeyTranslator.cs

    r2086 r2087  
    314314        }
    315315
     316        public int GetOpenCLBatchSize()
     317        {
     318            return openCLSize;
     319        }
     320
    316321        #endregion
    317322
  • trunk/CrypPlugins/KeySearcher/OpenCL/KeySearcherOpenCLCode.cs

    r2086 r2087  
    1414        private IControlCost controlCost;
    1515        private IControlEncryption encryptionController;
    16         private int bruteforceBlock;
     16        private int maxKeys;
    1717
    1818        private IKeyTranslator keyTranslatorOfCode = null;
     
    2020        private Kernel openCLKernel = null;
    2121
    22         public KeySearcherOpenCLCode(byte[] encryptedData, IControlEncryption encryptionController, IControlCost controlCost, int bruteforceBlock)
     22        public KeySearcherOpenCLCode(byte[] encryptedData, IControlEncryption encryptionController, IControlCost controlCost, int maxKeys)
    2323        {
    2424            this.encryptedData = encryptedData;
    2525            this.encryptionController = encryptionController;
    2626            this.controlCost = controlCost;
    27             this.bruteforceBlock = bruteforceBlock;
     27            this.maxKeys = maxKeys;
    2828        }
    2929
     
    5757
    5858            //put key movement of pattern into code:
    59             code = keyTranslator.ModifyOpenCLCode(code, bruteforceBlock);
     59            code = keyTranslator.ModifyOpenCLCode(code, maxKeys);
    6060
    6161            keyTranslatorOfCode = keyTranslator;
    6262            this.openCLCode = code;
    6363
    64             ////Test:
    65             //System.IO.TextWriter tw = new System.IO.StreamWriter(@"C:\Users\sven\Test\test.txt");
    66             //tw.Write(code);
    67             //tw.Close();
     64            //Test:
     65            System.IO.TextWriter tw = new System.IO.StreamWriter(@"C:\Users\sven\Test\test.txt");
     66            tw.Write(code);
     67            tw.Close();
    6868
    6969            return code;
     
    8989            }
    9090        }
    91 
    92         public int GetBruteforceBlock()
    93         {
    94             return bruteforceBlock;
    95         }
    9691    }
    9792}
  • trunk/CrypPlugins/SDES/SDES.cs

    r2086 r2087  
    799799        }
    800800
     801        public int GetOpenCLBatchSize()
     802        {
     803            throw new NotImplementedException();
     804        }
     805
    801806        #endregion
    802807    }
Note: See TracChangeset for help on using the changeset viewer.