Hello,

[EMAIL PROTECTED] wrote on 04/11/2008 03:56:45 PM:

> Hi Marek,
> 
> I do the following:
> 
> static char *login="login";
> static char *password="password";
> static char *label="label";
> 
> const unsigned char *buf=NULL;
> strcat(&buf, login); strcat(&buf, password); strcat(&buf, label);
You should allocate space for buf before strcat().
 
> unsigned char *m1[20];
> unsigned char *m2[20];
> 
> SHA1(&buf, strlen(&buf), m1); // The output is:
> 3d79ad220830e96dabd6ae6f9973306df1800906
> 
> //the output of the above SHA1 will be used as an input for the SHA1
> below, after concatenating it with label
> 
> strcat(&m1, label);
m1 has binary data, not string.
This data may have embeded 0x00 (look at your output above) and strcat
can not copy data in good place (to bytes before end instead of end of 
md1).
Use memcpy, does not relay of strlen() on such data too.

> SHA1(&m1, str len(&m1), m2);
> 
> I don't know why the output of the second SHA1 is not the same when I
> run the program several times. But I think the problem is in the m1
> storing, but I don't know how to resolve that.

Best regards,
--
Marek Marcola <[EMAIL PROTECTED]>

Reply via email to