Ignore:
Timestamp:
Nov 7, 2010, 10:24:18 AM (11 years ago)
Author:
Sven Rech
Message:

Added code to generate openCL bruteforce code in KeySearcher.
Not used yet, so don't try it

File:
1 edited

Legend:

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

    r2042 r2061  
    371371                    keysLeft[threadid] = size;
    372372
    373                     KeyTranslator keyTranslator = ControlMaster.getKeyTranslator();
     373                    IKeyTranslator keyTranslator = ControlMaster.getKeyTranslator();
    374374                    keyTranslator.SetKeys(pattern);
    375375
     
    455455        #region bruteforce methods
    456456
    457         private bool decryptAndCalculate(IControlEncryption sender, int bytesToUse, byte[] keya, KeyTranslator keyTranslator)
     457        private bool decryptAndCalculate(IControlEncryption sender, int bytesToUse, byte[] keya, IKeyTranslator keyTranslator)
    458458        {
    459459            ValueKey valueKey;
     
    709709
    710710            return costList;
     711        }
     712
     713        private string CreateOpenCLBruteForceCode(KeyPattern.KeyPattern keyPattern)
     714        {
     715            try
     716            {
     717                string code = sender.GetOpenCLCode(CostMaster.getBytesToUse());
     718                if (code == null)
     719                    throw new Exception("OpenCL not supported in this configuration!");
     720
     721                //put cost function stuff into code:
     722                code = costMaster.ModifyOpenCLCode(code);
     723
     724                //put input to be bruteforced into code:
     725                string inputarray = string.Format("__constant unsigned char inn[{0}] = {{ \n", CostMaster.getBytesToUse());
     726                for (int i = 0; i < CostMaster.getBytesToUse(); i++)
     727                {
     728                    inputarray += String.Format("0x{0:X2}, ", this.encryptedData[i]);
     729                }
     730                inputarray = inputarray.Substring(0, inputarray.Length - 2);
     731                inputarray += "}; \n";
     732                code = code.Replace("$$INPUTARRAY$$", inputarray);
     733
     734                //put key movement of pattern into code:
     735                IKeyTranslator keyTranslator = ControlMaster.getKeyTranslator();
     736                keyTranslator.SetKeys(pattern);
     737                code = keyTranslator.ModifyOpenCLCode(code, 256*256);
     738
     739                return code;
     740            }
     741            catch (Exception ex)
     742            {
     743                GuiLogMessage("Error trying to generate OpenCL code: " + ex.Message, NotificationLevel.Error);
     744                return null;
     745            }
    711746        }
    712747
Note: See TracChangeset for help on using the changeset viewer.