Skip to content

Commit

Permalink
Merge pull request #212 from seriyps/otp-23
Browse files Browse the repository at this point in the history
Make it compatible with OTP-23; add OTP-23 to travis. Fixes #207
  • Loading branch information
mworrell authored May 23, 2020
2 parents c1fc246 + 66af11b commit debd38a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: erlang

matrix:
include:
- otp_release: 23.0
- otp_release: 22.3
- otp_release: 21.3
- otp_release: 20.3
Expand Down
Binary file modified rebar3
Binary file not shown.
16 changes: 15 additions & 1 deletion src/smtp_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,23 @@ guess_FQDN_1(Hostname, {error, nxdomain = Error}) ->
%% @doc Compute the CRAM digest of `Key' and `Data'
-spec compute_cram_digest(Key :: binary(), Data :: binary()) -> binary().
compute_cram_digest(Key, Data) ->
Bin = crypto:hmac(md5, Key, Data),
Bin = hmac_md5(Key, Data),
list_to_binary([io_lib:format("~2.16.0b", [X]) || <<X>> <= Bin]).

-ifdef(OTP_RELEASE).
-if(?OTP_RELEASE >= 23).
-define(CRYPTO_MAC, true).
-endif.
-endif.

-ifdef(CRYPTO_MAC).
hmac_md5(Key, Data) ->
crypto:mac(hmac, md5, Key, Data).
-else.
hmac_md5(Key, Data) ->
crypto:hmac(md5, Key, Data).
-endif.

%% @doc Generate a seed string for CRAM.
-spec get_cram_string(Hostname :: string()) -> string().
get_cram_string(Hostname) ->
Expand Down

0 comments on commit debd38a

Please sign in to comment.