Ignore:
Timestamp:
Feb 19, 2010, 2:13:46 AM (12 years ago)
Author:
Arno Wacker
Message:

P2P Bruteforce key searching

  • Fixed serialization bug (JobId > 255)
  • Removed special case for JobId == 0 due to BigInt-bug; BigInt bug fixed, see bellow
  • Cleanup and renaming of the P2P-samples for Worker and Manager

BigInt:

  • getBytes() now returns also a single zeroed byte if value of BigInt is zero
  • added a warning to BigInt.dataLength - in some cases the values returned are wrong ==> yet another bug

AnotherEditor:

  • Invoke -> BeginInvoke for Plugin-Icon-changes and Quickwatch-updates
  • New binaries (CrypWin/AnotherEditor)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/PeerToPeerJobs/JobMessages.cs

    r1137 r1155  
    279279            if (jobId != null)
    280280            {
    281                 // there's an error in BigInteger.getBytes() --> return null bytes, when BigInt is 0!
    282                 // => workaround: use jobId.dataLength, returns the right value!
    283                 byte[] jobIdByteLen = BitConverter.GetBytes(jobId.dataLength);
    284                 byte[] jobIdByte;
    285                 if (jobId.getBytes().Length == 0)
    286                 {
    287                     jobIdByte = new byte[1] { 0 };
    288                     resultByte = new byte[jobIdByteLen.Length + 1];
    289                 }
    290                 else
    291                 {
    292                     jobIdByte = jobId.getBytes();
    293                     resultByte = new byte[jobIdByte.Length + jobIdByteLen.Length];
    294                 }
    295                 Buffer.BlockCopy(jobIdByteLen, 0, resultByte, 0, jobIdByteLen.Length);
    296                 Buffer.BlockCopy(jobIdByte, 0, resultByte, jobIdByteLen.Length, jobIdByte.Length);
     281                // Note, there is a Bug in BigInt: BigInt b = 256; => b.dataLength = 1 -- it should be 2!
     282                // As a workarround rely on getBytes().Length (the null bytes for the BigInt 0 should be fixed now)
     283                byte[] jobIdBytes = jobId.getBytes();
     284                byte[] jobIdBytesLen = BitConverter.GetBytes(jobIdBytes.Length);
     285             
     286                resultByte = new byte[jobIdBytes.Length + jobIdBytesLen.Length];
     287               
     288                Buffer.BlockCopy(jobIdBytesLen, 0, resultByte, 0, jobIdBytesLen.Length);
     289                Buffer.BlockCopy(jobIdBytes, 0, resultByte, jobIdBytesLen.Length, jobIdBytes.Length);
    297290            }
    298291            return resultByte;
     
    301294        /// <summary>
    302295        /// Deserialized a jobId from any byte[] array. Requirement: The byte[] has
    303         /// to start with a one byte JobId-Length-Information and have than enough
     296        /// to start with a four byte (int32) JobId-Length-Information and have than enough
    304297        /// bytes left to deserialize the BigInteger Value. If any bytes left after
    305298        /// deserializing the JobId, the out value will specify this amount.
    306299        /// </summary>
    307         /// <param name="serializedJobId">The byte[] has to start with a one byte
     300        /// <param name="serializedJobId">The byte[] has to start with a four bytes (int32)
    308301        /// JobId-Length-Information and have than enough bytes left to deserialize
    309302        /// the BigInteger Value</param>
Note: See TracChangeset for help on using the changeset viewer.