anchor.diff:  	[{userdata, [{doc, "Send an EAP-pwd-Commit/Response to peer"}]}].
   
   pwd_commit(Config) ->
  -	Id = 1,
  -	PeerId = ?config(peer_id, Config),
  -	{ok, AuthAddress} = application:get_env(ocs, radius_auth_addr),
  -	{ok, AuthPort} = application:get_env(ocs, radius_auth_port),
  +	PeerId = <<"34567890">>,
  +	MAC = "cc:dd:ee:ff:aa:bb",
  +	PeerAuth = ocs:generate_password(),
  +	ok = ocs:add_subscriber(PeerId, PeerAuth, []),
   	Socket = ?config(socket, Config), 
  -	UserName = ct:get_config(radius_username),
  -	SharedSecret = ct:get_config(radius_shared_secret),
  -	Authenticator = radius:authenticator(),
  -	IDReqAttributeList0 = radius_attributes:new(),
  -	IDReqAttributeList1 = radius_attributes:store(?UserName, UserName, IDReqAttributeList0),
  -	IDReqAttributeList2 = radius_attributes:store(?NasPort, 1, IDReqAttributeList1),
  -	IDReqAttributeList3 = radius_attributes:store(?NasIdentifier, "tomba1", IDReqAttributeList2),
  -	IDReqAttributeList4 = radius_attributes:store(?CallingStationId,"de:ad:be:ef:ca:fe",
  -		IDReqAttributeList3),
  -	IDReqAttributeList5 = radius_attributes:store(?MessageAuthenticator,
  -		list_to_binary(lists:duplicate(16,0)), IDReqAttributeList4),
  -	IDRequest1 = #radius{code = ?AccessRequest, id = Id, authenticator = Authenticator,
  -		attributes = IDReqAttributeList5},
  -	IDRequestPacket1 = radius:codec(IDRequest1),
  -	IDMsgAuth = crypto:hmac(md5, SharedSecret, IDRequestPacket1),
  -	IDReqAttributeList6 = radius_attributes:store(?MessageAuthenticator, IDMsgAuth, IDReqAttributeList5),
  -	IDRequest2 = #radius{code = ?AccessRequest, id = Id, authenticator = Authenticator,
  -		attributes = IDReqAttributeList6},
  -	IDRequestPacket2 = radius:codec(IDRequest2),
  -	ok = gen_udp:send(Socket, AuthAddress, AuthPort, IDRequestPacket2),
  -	{ok, {AuthAddress, AuthPort, IdReqPacket}} = gen_udp:recv(Socket, 0),
  -	#radius{code = ?AccessChallenge, id = Id, authenticator = _IDReqAuthenticator,
  -		attributes = BinIDReqAttributes} = radius:codec(IdReqPacket),
  -	IDReqAttributes = radius_attributes:codec(BinIDReqAttributes),
  -	{ok, IDEAPPacket} = radius_attributes:find(?EAPMessage, IDReqAttributes),
  -	#eap_packet{code = request, type = ?PWD, identifier = IDEAPId, data = IDData} =
  -		ocs_eap_codec:eap_packet(IDEAPPacket),
  -	#eap_pwd{length = false, more = false, pwd_exch = id,
  -		data = IDReqData} = ocs_eap_codec:eap_pwd(IDData),
  -	#eap_pwd_id{group_desc = 19, random_fun = 16#1, prf = 16#1, token = Token,
  -		pwd_prep = none, identity = ServerID} = ocs_eap_codec:eap_pwd_id(IDReqData),
  -	IDRespBody = #eap_pwd_id{token = Token, pwd_prep = none, identity = PeerId},
  -	IDRespBodyData = ocs_eap_codec:eap_pwd_id(IDRespBody),
  -	IDRespHeader = #eap_pwd{length = false, more = false, pwd_exch = id,
  -		data = IDRespBodyData},
  -	IDEAPData = ocs_eap_codec:eap_pwd(IDRespHeader),
  -	IDRespPacket = #eap_packet{code = response, type = ?PWD, identifier = IDEAPId, data = IDEAPData},
  -	IDEAPPacketData = ocs_eap_codec:eap_packet(IDRespPacket),
  -	IDRespAttributeList1 = radius_attributes:store(?EAPMessage, IDEAPPacketData, IDReqAttributeList5),
  -	Authenticator2 = radius:authenticator(),
  -	IDResponse1 = #radius{code = ?AccessRequest, id = 2,  authenticator = Authenticator2,
  -		attributes = IDRespAttributeList1},
  -	IDResPacket1 = radius:codec(IDResponse1),
  -	IDRespMsgAuth = crypto:hmac(md5, SharedSecret, IDResPacket1),
  -	IDRspAttributeList3 = radius_attributes:store(?MessageAuthenticator,
  -		IDRespMsgAuth, IDRespAttributeList1),
  -	IDResPacket1 = radius:codec(IDResponse1),
  -	IDRespMsgAuth = crypto:hmac(md5, SharedSecret, IDResPacket1),
  -	IDRspAttributeList3 = radius_attributes:store(?MessageAuthenticator,
  -		IDRespMsgAuth, IDRespAttributeList1),
  -	IDResponse2 = #radius{code = ?AccessRequest, id = 2, authenticator = Authenticator2,
  -		attributes = IDRspAttributeList3},
  -	IDResPacket2 = radius:codec(IDResponse2),
  -	ok = gen_udp:send(Socket, AuthAddress, AuthPort, IDResPacket2),
  -	{ok, {_Address, _Port, CommitPacket}} = gen_udp:recv(Socket, 0),
  -	#radius{code = ?AccessChallenge, id = 2, authenticator = _RAuthenticator,
  -		attributes = CommitReqAttributes} = radius:codec(CommitPacket),
  -	CommitReqAtt = radius_attributes:codec(CommitReqAttributes),
  -	{ok, CommitEAPPacket} = radius_attributes:find(?EAPMessage, CommitReqAtt),
  -	#eap_packet{code = request, type = ?PWD, identifier = EAPId2, data = CommitData} =
  -		ocs_eap_codec:eap_packet(CommitEAPPacket),
  +	{ok, Address} = application:get_env(ocs, radius_auth_addr),
  +	{ok, Port} = application:get_env(ocs, radius_auth_port),
  +	NasId = ?config(nas_id, Config),
  +	UserName = ct:get_config(radius_username),
  +	Secret = ct:get_config(radius_shared_secret),
  +	ReqAuth1 = radius:authenticator(),
  +	RadId = 4, EapId = 1,
  +	ok = send_identity(Socket, Address, Port, NasId, UserName,
  +			Secret, PeerId, MAC, ReqAuth1, EapId, RadId),
  +	NextEapId = EapId + 1,
  +	{NextEapId, _ServerID} = receive_id(Socket, Address,
  +			Port, Secret, ReqAuth1, RadId),
  +	ReqAuth2 = radius:authenticator(),
  +	Token = crypto:rand_bytes(4),
  +	send_id(Socket, Address, Port, Secret, ReqAuth2,
  +			UserName, NasId, PeerId, MAC, Token, NextEapId, RadId + 1),
  +	{ok, {_Address, _Port, RespPacket1}} = gen_udp:recv(Socket, 0),
  +	Response1 = radius:codec(RespPacket1),
  +	#radius{code = ?AccessChallenge, attributes = Attributes} = Response1,
  +	A1 = radius_attributes:codec(Attributes),
  +	MsgAuth2 = radius_attributes:fetch(?MessageAuthenticator, A1),
  +	A2 = radius_attributes:store(?MessageAuthenticator,
  +			list_to_binary(lists:duplicate(16,0)), A1),
  +	Response2 = Response1#radius{authenticator = ReqAuth2, attributes = A2},
  +	RespPacket2 = radius:codec(Response2),
  +	MsgAuth2 = crypto:hmac(md5, Secret, RespPacket2),
  +	EapMessage2 = radius_attributes:fetch(?EAPMessage, A1),
  +	EapIdCommit = NextEapId + 1,
  +	#eap_packet{code = request, type = ?PWD, identifier = EapIdCommit,
  +			data = EapData} = ocs_eap_codec:eap_packet(EapMessage2),
   	#eap_pwd{length = false, more = false, pwd_exch = commit,
  -		data = CommitReqData} = ocs_eap_codec:eap_pwd(CommitData),
  -	#eap_pwd_commit{element = _Element_S, scalar = _Scalar_S} = ocs_eap_codec:eap_pwd_commit(CommitReqData),
  -	P_Rand = crypto:rand_uniform(1, ?R),
  -	{ok, Password, _Attr, _Balance} = ocs:find_subscriber(PeerId),
  -	PWE = ocs_eap_pwd:compute_pwe(Token, PeerId, ServerID, Password),
  -	{Scalar_P, Element_P} = ocs_eap_pwd:compute_scalar(<<P_Rand:256>>, PWE),
  -	CommitRespBody = #eap_pwd_commit{scalar = Scalar_P, element = Element_P},
  -	CommitRespBodyData = ocs_eap_codec:eap_pwd_commit(CommitRespBody),
  -	CommitRespHeader = #eap_pwd{length = false, more = false, pwd_exch = commit,
  -		data = CommitRespBodyData},
  -	CommitEAPData = ocs_eap_codec:eap_pwd(CommitRespHeader),
  -	CommitRespPacket = #eap_packet{code = response, type = ?PWD, identifier = EAPId2, data = CommitEAPData},
  -	CommitRespPacketData = ocs_eap_codec:eap_packet(CommitRespPacket),
  -	CommitAttributeList1 = radius_attributes:store(?EAPMessage,
  -	   CommitRespPacketData, IDReqAttributeList5),
  -	Authenticator3 = radius:authenticator(),
  -	CommitResponse1 = #radius{code = ?AccessRequest, id = 3, authenticator = Authenticator3,
  -		attributes = CommitAttributeList1},
  -	CommitReqPacket1 = radius:codec(CommitResponse1),
  -	CommitRespMsgAuth = crypto:hmac(md5, SharedSecret, CommitReqPacket1),
  -	CommitAttributeList3 = radius_attributes:store(?MessageAuthenticator,
  -		CommitRespMsgAuth, CommitAttributeList1),
  -	CommitResponse2= #radius{code = ?AccessRequest, id = 3, authenticator = Authenticator3,
  -		attributes = CommitAttributeList3},
  -	CommitReqPacket2 = radius:codec(CommitResponse2),
  -	ok = gen_udp:send(Socket, AuthAddress, AuthPort, CommitReqPacket2),
  -	{ok, {_Address, _Port, _ConfirmPacket}} = gen_udp:recv(Socket, 0),
  -	ok =  gen_udp:close(Socket).
  +		data = EapPwdData} = ocs_eap_codec:eap_pwd(EapData),
  +	#eap_pwd_commit{element = _ElementS,
  +			scalar = _ScalarS} = ocs_eap_codec:eap_pwd_commit(EapPwdData).
   	
   pwd_confirm() ->
   	[{userdata, [{doc, "Send an EAP-pwd-Conform/Response to peer"}]}].
  
positive.code: 			identity = ServerID} = ocs_eap_codec:eap_pwd_id(EapPwdData),
  	{EapId, ServerID}.
  
  send_id(Socket, Address, Port, Secret, ReqAuth, UserName, NasId, PeerId) ->
  	A0 = radius_attributes:new(),
  	A1 = radius_attributes:add(?UserName, UserName, A0),
  	A2 = radius_attributes:add(?NasPort, 0, A1),
  	A3 = radius_attributes:add(?NasIdentifier, NasId, A2),
  	A4 = radius_attributes:add(?CallingStationId, "de:ad:be:ef:ca:fe", A3),
  	Token = crypto:rand_bytes(4),
  	EapPwdId = #eap_pwd_id{group_desc = 19, random_fun = 16#1, prf = 16#1,
  			token = Token, pwd_prep = none, identity = PeerId},
  	EapPwd = #eap_pwd{pwd_exch = id, data = ocs_eap_codec:eap_pwd_id(EapPwdId)},
  	EapPacket  = #eap_packet{code = response, type = ?PWD, identifier = 1,
  			data = ocs_eap_codec:eap_pwd(EapPwd)},
  	EapMsg = ocs_eap_codec:eap_packet(EapPacket),
  	A5 = radius_attributes:add(?EAPMessage, EapMsg, A4),
  	A6 = radius_attributes:add(?MessageAuthenticator,
  			list_to_binary(lists:duplicate(16,0)), A5),
  	Request1 = #radius{code = ?AccessRequest, id = 1,
  			authenticator = ReqAuth, attributes = A6},
  	RequestPacket1 = radius:codec(Request1),
  	MsgAuth1 = crypto:hmac(md5, Secret, RequestPacket1),
  	A7 = radius_attributes:store(?MessageAuthenticator, MsgAuth1, A6),
  	Request2 = Request1#radius{attributes = A7},
  	RequestPacket2 = radius:codec(Request2),
  	gen_udp:send(Socket, Address, Port, RequestPacket2).
  
  
negative.code: 	SharedSecret = ct:get_config(radius_shared_secret),
  	ok = ocs:add_client(AuthAddress, SharedSecret),
  	NasId = atom_to_list(node()),
  	[{nas_id, NasId}] ++ Config.
  
  -spec end_per_suite(Config :: [tuple()]) -> any().
  %% Cleanup after the whole suite.
  