diff --git a/.travis.yml b/.travis.yml index 86467dd..3184bb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,3 +9,5 @@ otp_release: - 17.5 - 18.3 - 19.2 + - 23.3 + - 24.3 diff --git a/src/radius_codec.erl b/src/radius_codec.erl index 94ba149..f137606 100644 --- a/src/radius_codec.erl +++ b/src/radius_codec.erl @@ -4,7 +4,7 @@ -export([encode_response/3, encode_attributes/1]). -export([encode_request/2]). --compile(export_all). +%%-compile(export_all). -include("radius.hrl"). @@ -30,7 +30,7 @@ decode_packet(Bin, Secret) -> A1 = lists:keyreplace("Message-Authenticator", 1, A, {"Message-Authenticator", <<0:128>>}), {ok, A2} = encode_attributes(A1), Packet1 = [Code, Ident, <>, Auth, A2], - case crypto:hmac(md5, Secret, Packet1) =:= Value of + case hmac(Secret, Packet1) =:= Value of true -> {ok, Packet}; false -> @@ -118,7 +118,7 @@ encode_response(Request, Response, Secret) -> Length = <<(20 + byte_size(A2)):16>>, Packet = list_to_binary([Code, Ident, Length, ReqAuth, A2]), - MA = crypto:hmac(md5, Secret, Packet), + MA = hmac(Secret, Packet), A3 = A ++ [{"Message-Authenticator", MA}], {ok, A4} = encode_attributes(A3), @@ -292,3 +292,16 @@ lookup_value(Code, Name, Attrs) -> false -> undefined end end. + +-ifdef(OTP_RELEASE). +-if(?OTP_RELEASE >= 23). +hmac(Key, Str) -> + crypto:mac(hmac, md5, Key, Str). +-else. +hmac(Key, Str) -> + crypto:hmac(md5, Key, Str). +-endif. +-else. +hmac(Key, Str) -> + crypto:hmac(md5, Key, Str). +-endif. \ No newline at end of file