PhraseSet.FillPhraseSet moved out to unmanaged code

master
Inga 🏳‍🌈 8 years ago
parent 9866d8ef7f
commit bb22805cbc
  1. 14
      dotnet/WhiteRabbit.UnmanagedBridge/WhiteRabbit.UnmanagedBridge.cpp
  2. 4
      dotnet/WhiteRabbit.UnmanagedBridge/WhiteRabbit.UnmanagedBridge.h
  3. 1
      dotnet/WhiteRabbit.UnmanagedBridge/WhiteRabbit.UnmanagedBridge.vcxproj
  4. 3
      dotnet/WhiteRabbit.UnmanagedBridge/constants.h

@ -28,10 +28,10 @@ void WhiteRabbitUnmanagedBridge::MD5Unmanaged::ComputeMD5(unsigned __int32 * inp
void WhiteRabbitUnmanagedBridge::MD5Unmanaged::FillPhraseSet(__int64* bufferPointer, __int64* allWordsPointer, __int32* wordIndexes, unsigned __int64* permutationsPointer, int permutationOffset, int numberOfCharacters, int numberOfWords)
{
long* longBuffer = (long*)bufferPointer;
__int64* longBuffer = (__int64*)bufferPointer;
auto currentPermutationPointer = permutationsPointer + permutationOffset;
for (auto i = 0; i < WhiteRabbitUnmanagedBridge::MD5Unmanaged::PhrasesPerSet; i++, currentPermutationPointer++)
for (auto i = 0; i < PHRASES_PER_SET; i++, currentPermutationPointer++)
{
auto permutation = *currentPermutationPointer;
if (permutation == 0)
@ -48,7 +48,7 @@ void WhiteRabbitUnmanagedBridge::MD5Unmanaged::FillPhraseSet(__int64* bufferPoin
longBuffer[1] |= currentWord[cumulativeWordOffsetX4 + 1];
longBuffer[2] ^= currentWord[cumulativeWordOffsetX4 + 2];
longBuffer[3] ^= currentWord[cumulativeWordOffsetX4 + 3];
cumulativeWordOffsetX4 += (int)currentWord[127];
cumulativeWordOffsetX4 += (__int32)currentWord[127];
}
longBuffer += 4;
@ -56,15 +56,15 @@ void WhiteRabbitUnmanagedBridge::MD5Unmanaged::FillPhraseSet(__int64* bufferPoin
auto length = numberOfCharacters + numberOfWords - 1;
unsigned char* byteBuffer = ((unsigned char*)bufferPointer) + length;
for (auto i = 0; i < WhiteRabbitUnmanagedBridge::MD5Unmanaged::PhrasesPerSet; i++)
for (auto i = 0; i < PHRASES_PER_SET; i++)
{
*byteBuffer = 128;
byteBuffer += 32;
}
auto lengthInBits = (unsigned int)(length << 3);
unsigned int* uintBuffer = ((unsigned int*)bufferPointer) + 7;
for (auto i = 0; i < WhiteRabbitUnmanagedBridge::MD5Unmanaged::PhrasesPerSet; i++)
auto lengthInBits = (unsigned __int32)(length << 3);
unsigned int* uintBuffer = ((unsigned __int32*)bufferPointer) + 7;
for (auto i = 0; i < PHRASES_PER_SET; i++)
{
*uintBuffer = lengthInBits;
uintBuffer += 8;

@ -2,6 +2,8 @@
#pragma once
#include "constants.h"
using namespace System;
namespace WhiteRabbitUnmanagedBridge {
@ -9,7 +11,7 @@ namespace WhiteRabbitUnmanagedBridge {
public ref class MD5Unmanaged
{
public:
literal int PhrasesPerSet = 16;
literal int PhrasesPerSet = PHRASES_PER_SET;
static void ComputeMD5(unsigned int* input, unsigned int* output);
static void FillPhraseSet(__int64* bufferPointer, __int64* allWordsPointer, __int32* wordIndexes, unsigned __int64* permutationsPointer, int permutationOffset, int numberOfCharacters, int numberOfWords);
};

@ -133,6 +133,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="constants.h" />
<ClInclude Include="md5.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="Stdafx.h" />

@ -0,0 +1,3 @@
#pragma once
#define PHRASES_PER_SET 16
Loading…
Cancel
Save