Click here to Skip to main content
15,890,506 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: OutputDebugString in x64 Pin
Rajesh R Subramanian17-Jul-10 8:06
professionalRajesh R Subramanian17-Jul-10 8:06 
Questionhow to know the downloaded data from the net for a PC Pin
Sakhalean16-Jul-10 23:25
Sakhalean16-Jul-10 23:25 
AnswerRe: how to know the downloaded data from the net for a PC Pin
Spawn@Melmac17-Jul-10 4:32
Spawn@Melmac17-Jul-10 4:32 
AnswerRe: how to know the downloaded data from the net for a PC Pin
Niklas L17-Jul-10 9:16
Niklas L17-Jul-10 9:16 
QuestionCompiling 64bit Pin
Fareed Rizkalla16-Jul-10 10:32
Fareed Rizkalla16-Jul-10 10:32 
AnswerRe: Compiling 64bit Pin
Emilio Garavaglia16-Jul-10 22:50
Emilio Garavaglia16-Jul-10 22:50 
AnswerRe: Compiling 64bit Pin
Richard MacCutchan16-Jul-10 23:00
mveRichard MacCutchan16-Jul-10 23:00 
Questionproper conversion of unsigned char [16] -> unsigned long [4] [modified] Pin
saiyuk6=716-Jul-10 8:45
saiyuk6=716-Jul-10 8:45 
I am stuck actually, im trying to write a md5 / blowfish function
im not sure if i am correctly converting the MD5[16] buffer into a unsigned long[4]
this doesnt really make too much sense too me

typedef struct _tag2Long {
   unsigned long _1;
   unsigned long _2;
   unsigned long _3;
   unsigned long _4;
} _2LONG;

void SignBuffer(unsigned char *pbzKey, unsigned char *pbzBuffer,
                unsigned int iSize, unsigned long pSignature[4])
{
   MD5_CTX md5;
   BLOWFISH_CTX bf;

   MD5Init(&md5);
   MD5Update(&md5, pbzBuffer, iSize);
   MD5Final(&md5);

   _2LONG *tl = (_2LONG*) md5.digest;

   printf("BLE 1\t\t %x %x %x %x\n", tl->_1, tl->_2, tl->_3, tl->_4);

   Blowfish_Init(&bf, pbzKey, 16);
   Blowfish_Encrypt(&bf, &tl->_1, &tl->_2);
   Blowfish_Encrypt(&bf, &tl->_3, &tl->_4);

   pSignature[0] = tl->_1;
   pSignature[1] = tl->_2;
   pSignature[2] = tl->_3;
   pSignature[3] = tl->_4;

   printf("BLE 2\t\t %x %x %x %x\n", pSignature[0], pSignature[1],
          pSignature[2], pSignature[3]);
}


bool VerifyBuffer(unsigned char *pbzKey, unsigned char *pSignature,
                  unsigned int iSize, unsigned long pBuffer[4])
{
   BLOWFISH_CTX bf;
   MD5_CTX md5;
   bool bResult = false;

   printf("BLD 1\t\t %x %x %x %x\n", pBuffer[0], pBuffer[1],
          pBuffer[2], pBuffer[3]);

   Blowfish_Init(&bf, pbzKey, 16);
   Blowfish_Decrypt(&bf, &pBuffer[0], &pBuffer[1]);
   Blowfish_Decrypt(&bf, &pBuffer[2], &pBuffer[3]);

   printf("BLD 2\t\t %x %x %x %x\n", pBuffer[0], pBuffer[1],
          pBuffer[2], pBuffer[3]);

   MD5Init(&md5);
   MD5Update(&md5, pSignature, iSize);
   MD5Final(&md5);

   _2LONG *tl = (_2LONG*) md5.digest;
//   printf("BLD 3\t\t %x %x %x %x\n", tl->_1, tl->_2, tl->_3, tl->_4);

   if (tl->_1 == pBuffer[0] && tl->_2 == pBuffer[1] &&
       tl->_3 == pBuffer[2] && tl->_4 == pBuffer[4])
      bResult = true;

   return bResult;
}

void main(void)
{
   unsigned char bszBuffer[2] = {'A', 'B'};
   unsigned long ulSig[4];
   SignBuffer((unsigned char*)"key", bszBuffer, 2, ulSig);
   printf("\n");
   if (VerifyBuffer((unsigned char*)"key", bszBuffer, 2, ulSig))
      printf("\nok");
   else printf("\nerr");
}


and this is the output of them
BLE 1            b0c66fb8 733df651 4c2d26de a9a0e334
BLE 2            f12b0ed9 782fae18 a87960ac f37b342e

BLD 1            f12b0ed9 782fae18 a87960ac f37b342e
BLD 2            dc95818a 65685d43 8d7d54b9 8827b217

err


modified on Friday, July 16, 2010 3:32 PM

AnswerRe: proper conversion of unsigned char [16] -> unsigned long [4] Pin
Chris Losinger16-Jul-10 9:14
professionalChris Losinger16-Jul-10 9:14 
GeneralRe: proper conversion of unsigned char [16] -> unsigned long [4] Pin
saiyuk6=716-Jul-10 9:28
saiyuk6=716-Jul-10 9:28 
GeneralRe: proper conversion of unsigned char [16] -> unsigned long [4] Pin
Chris Losinger16-Jul-10 9:40
professionalChris Losinger16-Jul-10 9:40 
GeneralRe: proper conversion of unsigned char [16] -> unsigned long [4] Pin
saiyuk6=716-Jul-10 9:53
saiyuk6=716-Jul-10 9:53 
GeneralRe: proper conversion of unsigned char [16] -> unsigned long [4] Pin
Chris Losinger16-Jul-10 10:27
professionalChris Losinger16-Jul-10 10:27 
GeneralRe: proper conversion of unsigned char [16] -> unsigned long [4] Pin
saiyuk6=716-Jul-10 10:40
saiyuk6=716-Jul-10 10:40 
AnswerRe: proper conversion of unsigned char [16] -> unsigned long [4] Pin
Code-o-mat16-Jul-10 9:18
Code-o-mat16-Jul-10 9:18 
GeneralRe: proper conversion of unsigned char [16] -> unsigned long [4] Pin
saiyuk6=716-Jul-10 9:39
saiyuk6=716-Jul-10 9:39 
QuestionFIX protocol: Logon using QuickFix engine Pin
arupsarkar16-Jul-10 7:01
arupsarkar16-Jul-10 7:01 
AnswerRe: FIX protocol: Logon using QuickFix engine Pin
Garth J Lancaster18-Jul-10 1:07
professionalGarth J Lancaster18-Jul-10 1:07 
Questioncurl to return server response Pin
Eli Nurman16-Jul-10 4:40
Eli Nurman16-Jul-10 4:40 
AnswerRe: curl to return server response Pin
Aescleal16-Jul-10 20:18
Aescleal16-Jul-10 20:18 
QuestionMagic Packet Pin
Fareed Rizkalla16-Jul-10 4:04
Fareed Rizkalla16-Jul-10 4:04 
AnswerRe: Magic Packet Pin
Richard MacCutchan16-Jul-10 7:07
mveRichard MacCutchan16-Jul-10 7:07 
QuestionHow to send data to a C# App which has WPF control (text box) from VC++ application. Pin
Joseph8216-Jul-10 3:38
Joseph8216-Jul-10 3:38 
AnswerRe: How to send data to a C# App which has WPF control (text box) from VC++ application. Pin
Hristo-Bojilov16-Jul-10 7:24
Hristo-Bojilov16-Jul-10 7:24 
QuestionActive Directory/LDAP. Pin
Mike Doner16-Jul-10 2:47
Mike Doner16-Jul-10 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.