anchor.diff:      NewState = State#decoder_state{eap_msg = [Value | State#decoder_state.eap_msg]},
       append_attr({Attr, Value}, NewState);
   decode_attribute(<<EncValue/binary>>, Req, Attr = #attribute{id = ?RMessage_Authenticator, type = Type, enc = Encryption}, Pos, State) ->
  -    append_attr({Attr, decode_value(decrypt_value(Req, EncValue, Encryption), Type)}, State#decoder_state{hmac_pos = Pos});
  +    append_attr({Attr, decode_value(decrypt_value(Req, State, EncValue, Encryption), Type)}, State#decoder_state{hmac_pos = Pos});
   decode_attribute(<<EncValue/binary>>, Req, Attr = #attribute{type = Type, enc = Encryption}, _Pos, State) when is_atom(Type) ->
  -    append_attr({Attr, decode_value(decrypt_value(Req, EncValue, Encryption), Type)}, State);
  +    append_attr({Attr, decode_value(decrypt_value(Req, State, EncValue, Encryption), Type)}, State);
   decode_attribute(WholeBin = <<Tag:8, Bin/binary>>, Req, Attr = #attribute{type = {tagged, Type}}, _Pos, State) ->
       case {decode_tag_value(Tag), Attr#attribute.enc} of
           {0, no} ->
  
positive.code: 
  -spec salt_encrypt(salt(), secret(), authenticator(), binary()) -> binary().
  salt_encrypt(Salt, SharedSecret, RequestAuthenticator, PlainText) ->
      CipherText = do_salt_crypt(Salt, SharedSecret, RequestAuthenticator, (pad_to(16, << (byte_size(PlainText)):8, PlainText/binary >>))),
      <<Salt/binary, CipherText/binary>>.
  
  -spec salt_decrypt(secret(), authenticator(), binary()) -> binary().
  salt_decrypt(SharedSecret, RequestAuthenticator, <<Salt:2/binary, CipherText/binary>>) ->
      << Length:8/integer, PlainText/binary >> = do_salt_crypt(Salt, SharedSecret, RequestAuthenticator, CipherText),
      if
          Length < byte_size(PlainText) ->
              binary:part(PlainText, 0, Length);
  
negative.code:             PlainText
      end.
  
  do_salt_crypt(Op, Salt, SharedSecret, RequestAuthenticator, <<CipherText/binary>>) ->
      B = crypto:hash(md5, [SharedSecret, RequestAuthenticator, Salt]),
      salt_crypt(Op, SharedSecret, B, CipherText, << >>).
  
  salt_crypt(Op, SharedSecret, B, <<PlainText:16/binary, Remaining/binary>>, CipherText) ->
      NewCipherText = crypto:exor(PlainText, B),
      Bnext = case Op of
  		decrypt -> crypto:hash(md5, [SharedSecret, PlainText]);
  		encrypt -> crypto:hash(md5, [SharedSecret, NewCipherText])
  	    end,
      salt_crypt(Op, SharedSecret, Bnext, Remaining, <<CipherText/binary, NewCipherText/binary>>);
  
  salt_crypt(Op, _SharedSecret, _B, << >>, CipherText) ->
      CipherText.
  
  %% @doc pad binary to specific length
  