Skip to content

Conversation

@lanodan
Copy link

@lanodan lanodan commented May 22, 2021

This fixes tests on OTP24.

@lanodan lanodan changed the title JsonWebToken.Algorithm.Hmac: Use :crypto.mac JsonWebToken.Algorithm.Hmac: Use :crypto.mac (OTP24) May 22, 2021
@tatiesmars
Copy link

@garyf Would be nice to have this PR merge so the library is supported for OPT24

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants