Click here to Skip to main content
15,909,741 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Radio Button's Satus?? Pin
Randor 20-Jul-10 6:00
professional Randor 20-Jul-10 6:00 
GeneralRe: Radio Button's Satus?? [modified] Pin
Richard MacCutchan20-Jul-10 7:13
mveRichard MacCutchan20-Jul-10 7:13 
GeneralRe: Radio Button's Satus?? Pin
Randor 20-Jul-10 7:53
professional Randor 20-Jul-10 7:53 
AnswerRe: Radio Button's Satus?? Pin
bolivar12319-Jul-10 8:50
bolivar12319-Jul-10 8:50 
Questionproblem in skipping line in csv format files Pin
naveed tahir17-Jul-10 11:41
naveed tahir17-Jul-10 11:41 
AnswerRe: problem in skipping line in csv format files Pin
«_Superman_»17-Jul-10 18:07
professional«_Superman_»17-Jul-10 18:07 
AnswerRe: problem in skipping line in csv format files Pin
Garth J Lancaster17-Jul-10 18:10
professionalGarth J Lancaster17-Jul-10 18:10 
Questionerror C2440 Pin
mdocvc17-Jul-10 8:22
mdocvc17-Jul-10 8:22 
AnswerRe: error C2440 Pin
Aescleal17-Jul-10 9:37
Aescleal17-Jul-10 9:37 
Questioncalculating bytes per second Pin
saiyuk6=717-Jul-10 7:46
saiyuk6=717-Jul-10 7:46 
AnswerRe: calculating bytes per second Pin
Chris Losinger17-Jul-10 8:37
professionalChris Losinger17-Jul-10 8:37 
GeneralRe: calculating bytes per second Pin
saiyuk6=717-Jul-10 8:45
saiyuk6=717-Jul-10 8:45 
QuestionRe: calculating bytes per second Pin
David Crow19-Jul-10 5:46
David Crow19-Jul-10 5:46 
AnswerRe: calculating bytes per second [modified] Pin
saiyuk6=719-Jul-10 14:15
saiyuk6=719-Jul-10 14:15 
GeneralRe: calculating bytes per second Pin
David Crow20-Jul-10 2:22
David Crow20-Jul-10 2:22 
GeneralRe: calculating bytes per second [modified] Pin
saiyuk6=720-Jul-10 5:36
saiyuk6=720-Jul-10 5:36 
QuestionOutputDebugString in x64 Pin
Pascal Ganaye17-Jul-10 0:51
Pascal Ganaye17-Jul-10 0:51 
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

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.