defmodule Wampex.Crypto do
@moduledoc false
- def hash_challenge(secret, challenge) do
- :sha256
- |> :crypto.hmac(secret, challenge)
- |> :base64.encode()
+ def hash_challenge(key, data) do
+ :hmac
+ |> :crypto.mac(:sha256, key, data)
+ |> Base.encode64()
end
def pbkdf2(secret, salt, iterations, keylen) do
} = data
} = sl
) do
+ Logger.info("Hello #{inspect(dets)}")
+
{actions, challenge} =
case dets do
%{"authid" => ai, "authmethods" => am} ->
true ->
ch = auth.challenge(ai, id)
+ chal = %Challenge{
+ auth_method: auth.method(),
+ options: ch
+ }
+
send_to_peer(
- Peer.challenge(%Challenge{
- auth_method: auth.method,
- options: ch
- }),
+ Peer.challenge(chal),
tt,
t
)
authprovider = get_in(ch, ["authprovider"])
actions =
- case auth.authenticate(sig, get_in(ch, ["authid"]), challenge) do
+ case auth.authenticate(sig, authid, challenge) do
true ->
send_to_peer(
Peer.welcome(%Welcome{