Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/json_web_token/algorithm/hmac.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule JsonWebToken.Algorithm.Hmac do
"""
def sign(sha_bits, shared_key, signing_input) do
validate_params(sha_bits, shared_key)
:crypto.hmac(sha_bits, shared_key, signing_input)
:crypto.mac(:hmac, sha_bits, shared_key, signing_input)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lanodan

what about to have the code like that:

  if Code.ensure_loaded?(:crypto) and function_exported?(:crypto, :mac, 4) do
    defp hmac(type, key, data), do: :crypto.mac(:hmac, type, key, data)
  else
    defp hmac(type, key, data), do: :crypto.hmac(type, key, data)
  end

and then just call:

hmac(sha_bits, shared_key, signing_input)

https://github.com/elixir-ecto/postgrex/blob/master/lib/postgrex/scram.ex#L69

and it's definitely would be great to merge it as soon as possible. but it looks like the library has no active support.

end

@doc """
Expand Down