Summary:ASTERISK-01168: auth=md5 doesnt work on amd64
Reporter:zoa (zoa)Labels:
Date Opened:2004-03-06 08:44:30.000-0600Date Closed:2008-01-15 14:46:14.000-0600
Versions:Frequency of
Description:although everything compiles fine, and asterisk gives no errors, its impossible to auth using md5.
(Tried with the same config as on another box, just doesnt work.)


julius*CLI> iax2 debug
IAX2 Debugging Enabled
Rx-Frame Retry[No] -- OSeqno: 000 ISeqno: 000 Type: IAX     Subclass: NEW
  Timestamp: 00001ms  SCall: 00001  DCall: 00000 [xxx.xxx.xxx.xxx:4569]
  VERSION         : 2
  CALLED NUMBER   : 003226101645
  CALLING NAME    : +32486103235
  LANGUAGE        : en
  CALLED CONTEXT  : iax-scx
  USERNAME        : blabla
  FORMAT          : 4
  CAPABILITY      : 65535
  ADSICPE         : 2
  DATE TIME       : 140932022

Tx-Frame Retry[000] -- OSeqno: 000 ISeqno: 001 Type: IAX     Subclass: AUTHREQ
  Timestamp: 00001ms  SCall: 00003  DCall: 00001 [xxx.xxx.xxx.xxx:4569]
  CHALLENGE       : 128528877
  USERNAME        : blabla

Rx-Frame Retry[No] -- OSeqno: 001 ISeqno: 001 Type: IAX     Subclass: AUTHREP
  Timestamp: 00087ms  SCall: 00001  DCall: 00003 [xxx.xxx.xxx.xxx:4569]
  MD5 RESULT      : e40ef308aeea33ffbfe744a3d26356a8

Apr  3 14:27:55 NOTICE[147466]: chan_iax2.c:4689 socket_read: Host xxx.xxx.xxx.xxx failed to authenticate as blabla

I  have no idea why this is not working...
Comments:By: zoa (zoa) 2004-03-06 12:16:11.000-0600

sip registrations also don't work on 64 bit asterisk.

I'm running SUSE 9 on AMD64 (opteron).

By: Mark Spencer (markster) 2004-03-06 15:10:33.000-0600

Would suggest an endianness issue.  Please try some debugging on md5.c to see what is going on.

By: zoa (zoa) 2004-03-06 18:13:15.000-0600

looks a bit like this bug...


By: zoa (zoa) 2004-03-06 18:16:22.000-0600

and this one...

By: zoa (zoa) 2004-03-06 18:23:10.000-0600

could someone help me out with debuggin this one ? i have no idea how to debug that as there are obviously no errors, the hash is just calculated in a wrong way.

By: James Golovich (jamesgolovich) 2004-03-06 19:08:34.000-0600

Can you try the fix they talk about in the first link on your system?  I don't have access to any 64bit systems right now to test it on

By: zoa (zoa) 2004-03-06 21:00:23.000-0600

md5_crypt in pam/pwdb is broken in big endian machines
due to endianess problems, this breaks programs that
use glibc's crypt (sulogin for example).

-->  i tried this first patch, but they say its for big endian machines, but the opteron cpu is 64 bit little endian. (just as an alpha CPU i think)

would the RSA md5.c be a possible solution ? or maybe someone knows where i could find a more recent version of the used md5.c ?

By: zoa (zoa) 2004-03-06 21:07:53.000-0600

i even tried the newer code on : http://www.jonh.net/~jonh/md5/md5/md5.c

still didnt work for me. (at least not the sip part, didnt get to test the iax2 part)

By: zoa (zoa) 2004-03-06 21:40:48.000-0600

tried with RSA's md5.c too, but get this error:

gcc -g  -o asterisk -Wl,-E  io.o sched.o logger.o frame.o loader.o config.o channel.o translate.o file.o say.o pbx.o cli.o md5.o term.o ulaw.o alaw.o callerid.o fskmodem.o image.o app.o cdr.o tdd.o acl.o rtp.o manager.o asterisk.o ast_expr.o dsp.o chanvars.o indications.o autoservice.o db.o privacy.o astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o -ldl -lpthread -lncurses -lm -lresolv   editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a
loader.o(.text+0x6c8): In function `ast_load_resource':
/usr/src/asterisk/loader.c:87: undefined reference to `MD5Init'
loader.o(.text+0x6e5):/usr/src/asterisk/loader.c:88: undefined reference to `MD5Update'
loader.o(.text+0x6f0):/usr/src/asterisk/loader.c:89: undefined reference to `MD5Final'
manager.o(.text+0x66a8): In function `authenticate':
/usr/src/asterisk/manager.c:293: undefined reference to `MD5Init'
manager.o(.text+0x6700):/usr/src/asterisk/manager.c:294: undefined reference to `MD5Update'
manager.o(.text+0x6715):/usr/src/asterisk/manager.c:295: undefined reference to `MD5Update'
manager.o(.text+0x672c):/usr/src/asterisk/manager.c:296: undefined reference to `MD5Final'
collect2: ld returned 1 exit status
make: *** [asterisk] Error 1

By: Mark Spencer (markster) 2004-03-06 23:45:35.000-0600

Judging by the first patch fixing the problem (i.e. #include <endian.h> i've included a similar patch which should hopefully resolve the problem.  Please re-open if it doesn't.

By: orlandi (orlandi) 2004-03-22 19:09:25.000-0600

Reminder sent to markster

The problem is in md5.h
The code defines:

#ifdef __alpha
typedef unsigned int uint32;
typedef unsigned long uint32;

unsigned long is 64-bits under x86-64 (an I presume any 64 bits arch) so, the code is broken for any 64-bits architecture except alpha.

Using unsigned int under AMD64 makes it work.

By: James Golovich (jamesgolovich) 2004-03-30 18:59:05.000-0600

Fixed in CVS -HEAD

By: Digium Subversion (svnbot) 2008-01-15 14:46:14.000-0600

Repository: asterisk
Revision: 2363

U   trunk/md5.c

r2363 | markster | 2008-01-15 14:46:14 -0600 (Tue, 15 Jan 2008) | 2 lines

Fix for endianness (bug ASTERISK-1168)



By: Digium Subversion (svnbot) 2008-01-15 14:46:14.000-0600

Repository: asterisk
Revision: 2362

U   branches/v1-0_stable/md5.c

r2362 | markster | 2008-01-15 14:46:13 -0600 (Tue, 15 Jan 2008) | 2 lines

Be sure to include endianness (bug ASTERISK-1168)