anchor.diff:  %%  internal functions
   %%----------------------------------------------------------------------
   
  -%% @doc Sends an RADIUS-Access/Reject packet to peer
  -%% @hidden
  -send_radius_reject(RadiusID, RequestAuthenticator, Secret, RadiusFsm) ->
  -	AttributeList0 = radius_attributes:new(),
  -	AttributeList1 = radius_attributes:store(?MessageAuthenticator,
  -			<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>, AttributeList0),
  -	AttrListbin = radius_attributes:codec(AttributeList1),
  -	Response1 = #radius{code = ?AccessReject, id = RadiusID,
  -			authenticator = RequestAuthenticator, attributes = AttrListbin},
  -	ResponsePacket1 = radius:codec(Response1),
  -	MessageAuthenticator = crypto:hmac(md5, Secret, ResponsePacket1),
  -	AttributeList3 = radius_attributes:store(?MessageAuthenticator,
  -			MessageAuthenticator, AttributeList1),
  -	AttributeData = radius_attributes:codec(AttributeList3),
  -	Length = size(AttrListbin) + 20,
  -	ResponseAuthenticator = crypto:hash(md5,[<<?AccessReject, RadiusID,
  -			Length:16>>, RequestAuthenticator, AttributeData, Secret]),
  -	Response = #radius{code = ?AccessReject, id = RadiusID,
  -		authenticator = ResponseAuthenticator, attributes = AttributeData},
  -			ResponsePacket = radius:codec(Response),
  -	radius:response(RadiusFsm, {response, ResponsePacket}).
  -
  --spec send_radius_challenge(NewEAPID :: integer(), EAPData :: binary(),
  -		RadiusID :: byte(), RequestAuthenticator :: binary(), Secret :: binary(),
  -		RadiusFsm :: pid()) -> ok. 
   %% @doc Sends an RADIUS-Access/Challenge packet to peer
   %% @hidden
  -send_radius_challenge(NewEAPID, EAPData, RadiusID, RequestAuthenticator, Secret, RadiusFsm) ->
  -	Packet = #eap_packet{code = ?Request, identifier = NewEAPID, data = EAPData},
  +send_radius_response(EAPCode, NewEAPID, EAPData, RadiusCode, RadiusID, RequestAuthenticator, Secret, RadiusFsm) ->
  +	Packet = #eap_packet{code = EAPCode, identifier = NewEAPID, data = EAPData},
   	EAPPacketData = ocs_eap_codec:eap_packet(Packet),
   	AttributeList0 = radius_attributes:new(),
   	AttributeList1 = radius_attributes:store(?EAPMessage,
  
positive.code: 					case MK_S of
  						MK_P ->
  							NewEapID = EapID + 1,
  							send_radius_success(NewEapID, <<>>, RadiusID, RequestAuthenticator, Secret, RadiusFsm),
  							{next_state, wait_for_confirm, StateData, ?TIMEOUT};
  						_ ->
  							NewEapID = EapID + 1,
  
negative.code: 	end.
  %% @hidden
  wait_for_commit1(BodyData, #statedata{scalar_s = ScalarS, element_s = ElementS,
  		radius_fsm = RadiusFsm, radius_id = RadiusID, eap_id = NewEAPID,
  		secret = Secret, authenticator = RequestAuthenticator} = StateData) ->
  		ExpectedSize = size(<<ElementS/binary, ScalarS/binary>>),
  		case size(BodyData) of 
  			ExpectedSize ->
  				wait_for_commit2(BodyData, StateData);
  			_ ->
  				send_radius_response(?Failure, NewEAPID, BodyData, ?AccessReject, RadiusID, RequestAuthenticator, Secret, RadiusFsm),
  				{error, exit}
  		end.
  %% @hidden
  wait_for_commit2(BodyData, #statedata{element_p = ElementP, scalar_p = ScalarP, scalar_s = ScalarS,
  		element_s = ElementS,  radius_fsm = RadiusFsm, radius_id = RadiusID,
  		secret = Secret, authenticator = RequestAuthenticator, eap_id = NewEAPID} = StateData) ->
  	case {ElementP, ScalarP} of
  		{ElementS, ScalarS} ->
  			send_radius_response(?Failure, NewEAPID, BodyData, ?AccessReject, RadiusID, RequestAuthenticator, Secret, RadiusFsm),
  			{error, exit};
  		_ ->
  			wait_for_commit3(BodyData, StateData)
  	end.
  %% @hidden
  wait_for_commit3(BodyData, #statedata{scalar_p = ScalarP, radius_fsm = RadiusFsm, radius_id = RadiusID,
  		secret = Secret, authenticator = RequestAuthenticator, eap_id = NewEAPID} = _StateData)->
  	case ScalarP of
  		_ScalarP_Valid when  1 =< ScalarP, ScalarP >= $R ->
  			ok;
  		_ScalarP_Out_of_Range ->
  			send_radius_response(?Failure, NewEAPID, BodyData, ?AccessReject, RadiusID, RequestAuthenticator, Secret, RadiusFsm),
  			{error, exit}
  	end.
  
  