[JDEV] Perl and c SHA problems

Thomas Muldowney temas at box5.net
Thu Nov 15 11:07:56 CST 2001


Hrm, I'll play around with this and see if I can get some more info for
you.

--temas


On Wed, Nov 14, 2001 at 08:52:48AM -0700, Tim Ferguson wrote:
> Hello,
> 
> I am running the 1.4.1 server on Tru64.  I suspect a problem with sha.c due
> to the 64 bit OS, but I do not know where to go from here.  I actually
> already have a modified version of sha.c from someone who claimed it fixed
> any 64 bit problems and I will include what is modified below.  The symptoms
> are:  All agents or transports can not connect due to an invalid handshake
> if they are written in perl, of course all agents written in c can connect
> because they all use the same routine, and no one can do anything but plain
> text authentication.  I tried moving the perl agents to linux and connecting
> back to the Tru64 server just to make sure that the perl was not the problem
> with the 64 bit architecture, but of course I still had an invalid handshake
> reported.  Does anyone have ideas, or have they already dealt with this?
> 
> Thanks,
> 
> Tim Ferguson
> Cable & Wireless
> 719-590-4100
> 
> 
> shahash and shahash_r are the only functions changed in my modified sha.c:
> 
> char *shahash(char *str)
> {
>     char read_buffer[65];
>     //int read_buffer[64];
>     int c=1, i;
>     long long length=0;
>     int strsz;
>     static char final[41];
>     int *hashval;
> 
>     if(str==NULL) return NULL;
> 
>     memset(read_buffer, 0, 65);
>      hashval = (int *)malloc(20);
> 
>     sha_init(hashval);
> 
>     strsz = strlen(str);
> 
>     while (strsz>0)
>     {
>         strncpy((char *)&read_buffer, str, 64);
>         c = strlen((char *)&read_buffer);
>         length+=c;
>         strsz-=c;
>         if (strsz<=0)
>         {
>             length<<=3;
>             read_buffer[c]=0x80;
>             for (i=c+1; i<64; i++)
>                 read_buffer[i]=0;
>             if (c>55)
>             {
>                 /* we need to do an entire new block */
>                 sha_hash((int *)&read_buffer, hashval);
>                 for (i=0; i<14; i++)
>                     ((int*)&read_buffer)[i]=0;
>             }
> 
> #ifdef WORDS_BIGENDIAN
>             memcpy(read_buffer+56, &length, 8);
> #else
>             for(i=0; i<8; i++)
>                 read_buffer[56+i]=(length>>(56-(i*8))) & 0xFF;
> #endif
> 
>         }
> 
>         sha_hash((int *)&read_buffer, hashval);
>         str+=64;
>     }
> 
>         final[40] = '\0';
>     strprintsha((char *)&final, hashval);
>     free(hashval);
>     return (char *)&final;
> }
> 
> void shahash_r(const char* str, char hashbuf[41])
> {
>     char read_buffer[65];
>     //int read_buffer[64];
>     int c=1, i;
>     long long length=0;
>     int strsz;
>     int *hashval;
> 
>     if(str==NULL)
>         {
>                 hashbuf[0] = '\0';
>                 return;
>         }
> 
>     memset(read_buffer, 0, 65);
>     hashval = (int *)malloc(20);
> 
>     sha_init(hashval);
> 
>     strsz = strlen(str);
> 
>     while (strsz>0)
>     {
>        strncpy((char *)&read_buffer, str, 64);
>         c = strlen((char *)&read_buffer);
>         length+=c;
>         strsz-=c;
>         if (strsz<=0)
>         {
>             length<<=3;
>             read_buffer[c]=0x80;
>             for (i=c+1; i<64; i++)
>                 read_buffer[i]=0;
>             if (c>55)
>             {
>                 /* we need to do an entire new block */
>                 sha_hash((int *)&read_buffer, hashval);
>                 for (i=0; i<14; i++)
>                     ((int*)&read_buffer)[i]=0;
>             }
> 
> #ifdef WORDS_BIGENDIAN
>             memcpy(read_buffer+56, &length, 8);
> #else
>             for(i=0; i<8; i++)
>               {
>                 read_buffer[56+i]=(length>>(56-(i*8))) & 0xFF;
>                 /* we need to do an entire new block */
>                 sha_hash((int *)&read_buffer, hashval);
>                 for (i=0; i<14; i++)
>                   ((int*)&read_buffer)[i]=0;
>               }
> #endif
> 
>         }
> 
>         sha_hash((int *)&read_buffer, hashval);
>         str+=64;
>     }
> 
>     hashbuf[40] = '\0';
>     strprintsha((char *)hashbuf, hashval);
>     free(hashval);
> }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <https://www.jabber.org/jdev/attachments/20011115/14b08859/attachment-0002.pgp>


More information about the JDev mailing list