|
|
@ -1,7 +1,9 @@ |
|
|
|
namespace WhiteRabbit |
|
|
|
namespace WhiteRabbit |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
using System.Numerics; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using WhiteRabbitUnmanagedBridge; |
|
|
|
using WhiteRabbitUnmanagedBridge; |
|
|
|
|
|
|
|
|
|
|
@ -29,41 +31,40 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public unsafe void FillPhraseSet(PhraseSet initial, Word[] allWords, int[] wordIndexes, ulong[] permutations, int permutationOffset) |
|
|
|
public unsafe void ProcessPermutations(PhraseSet initialPhraseSet, Word[] allWords, int[] wordIndexes, ulong[] permutations, Vector<uint> expectedHashes, Action<byte[], uint> action) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fixed (uint* bufferPointer = this.Buffer, initialBufferPointer = initial.Buffer) |
|
|
|
fixed (uint* bufferPointer = this.Buffer, initialBufferPointer = initialPhraseSet.Buffer) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fixed (ulong* permutationsPointer = permutations) |
|
|
|
fixed (ulong* permutationsPointer = permutations) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fixed (int* wordIndexesPointer = wordIndexes) |
|
|
|
fixed (int* wordIndexesPointer = wordIndexes) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fixed (Word* allWordsPointer = allWords) |
|
|
|
fixed (Word* allWordsPointer = allWords) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (var i = 0; i < permutations.Length; i += Constants.PhrasesPerSet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MD5Unmanaged.FillPhraseSet( |
|
|
|
MD5Unmanaged.FillPhraseSet( |
|
|
|
(ulong*)initialBufferPointer, |
|
|
|
(ulong*)initialBufferPointer, |
|
|
|
(ulong*)bufferPointer, |
|
|
|
(ulong*)bufferPointer, |
|
|
|
(ulong*)allWordsPointer, |
|
|
|
(ulong*)allWordsPointer, |
|
|
|
wordIndexesPointer, |
|
|
|
wordIndexesPointer, |
|
|
|
permutationsPointer + permutationOffset, |
|
|
|
permutationsPointer + i, |
|
|
|
wordIndexes.Length); |
|
|
|
wordIndexes.Length); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MD5Unmanaged.ComputeMD5(bufferPointer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var j = 0; j < Constants.PhrasesPerSet; j++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (Vector.EqualsAny(expectedHashes, new Vector<uint>(bufferPointer[j * 8 + 7]))) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
action(this.GetBytes(j), bufferPointer[j * 8 + 7]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public unsafe void ComputeMD5() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fixed (uint* inputBuffer = this.Buffer) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
MD5Unmanaged.ComputeMD5(inputBuffer); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
|
|
|
|
|
public uint GetMD5(int number) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return this.Buffer[number * 8 + 7]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public unsafe byte[] GetBytes(int number) |
|
|
|
public unsafe byte[] GetBytes(int number) |
|
|
|