this is not the problem, because tryin with phone A to register with 5030 and password 5030 it works correctly:
<--- SIP read from UDP:192.168.1.130:1025 --->
REGISTER sip:192.168.1.230 SIP/2.0
From: sip:5030@192.168.1.230;tag=a17d13508ac692508adfc0_F5030192.168.1.130
To: sip:5030@192.168.1.230
Call-ID: 1_f1f7043451d508ad5c0_R@192.168.1.130
CSeq: 2 REGISTER
Via: SIP/2.0/UDP 192.168.1.130;branch=z9hG4bK2_181d465f9785508adfed_R5030
Content-Length: 0
Max-Forwards: 70
Contact: <sip:5030@192.168.1.130;avaya-sc-enabled;transport=udp>;q=1;expires=1000;reg-id=1;+sip.instance="<urn:uuid:00000000-0000-1000-8000-001b4f57167c>"
Allow: INVITE,CANCEL,BYE,ACK,SUBSCRIBE,NOTIFY,MESSAGE,INFO,PUBLISH,REFER,UPDATE
User-Agent: Avaya one-X Deskphone
Supported: eventlist
Authorization: Digest username="5030",realm="asterisk",nonce="4a0bea57",uri="sip:192.168.1.230",response="9b537a1d630d8f4bda78a178c56ac600"
<------------->
--- (13 headers 0 lines) ---
Sending to 192.168.1.130:5060 (no NAT)
<--- Transmitting (no NAT) to 192.168.1.130:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.130;branch=z9hG4bK2_181d465f9785508adfed_R5030;received=192.168.1.130
From: sip:5030@192.168.1.230;tag=a17d13508ac692508adfc0_F5030192.168.1.130
To: sip:5030@192.168.1.230;tag=as4bf3dde6
Call-ID: 1_f1f7043451d508ad5c0_R@192.168.1.130
CSeq: 2 REGISTER
Server: Asterisk PBX 1.8.15.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Expires: 1000
Contact: <sip:5030@192.168.1.130;avaya-sc-enabled;transport=udp>;expires=1000
Date: Fri, 26 Oct 2012 15:21:46 GMT
Content-Length: 0
i’ve experienced this type of problem (SIP/2.0 401 Unauthorized) when asterisk was started with nat=yes but no nat present on my network.