diff --git a/lib/chronoscope/nts/key_establishment_response.ex b/lib/chronoscope/nts/key_establishment_response.ex index 5a4bff6..5130b07 100644 --- a/lib/chronoscope/nts/key_establishment_response.ex +++ b/lib/chronoscope/nts/key_establishment_response.ex @@ -1,7 +1,7 @@ defmodule Chronoscope.NTS.KeyEstablishmentResponse do import Bitwise - @aead_alogorithms %{ + @aead_algorithms %{ 15 => "AEAD_AES_SIV_CMAC_256", 30 => "AEAD_AES_128_GCM_SIV" } @@ -16,6 +16,12 @@ defmodule Chronoscope.NTS.KeyEstablishmentResponse do 2 => "Internal Server Error" } + def aead_algorithm_to_id(algorithm) do + @aead_algorithms + |> Map.new(fn {k, v} -> {v, k} end) + |> Map.get(algorithm) + end + def parse(response) do parse_response(response, %{}) end @@ -127,7 +133,7 @@ defmodule Chronoscope.NTS.KeyEstablishmentResponse do end defp do_parse_aead_algorithm_list([high, low | rest], acc) do - @aead_alogorithms + @aead_algorithms |> Map.get(combine_octets(high, low), "UNKNOWN") |> then(&do_parse_aead_algorithm_list(rest, [&1 | acc])) end diff --git a/lib/chronoscope_web/live/index_live.ex b/lib/chronoscope_web/live/index_live.ex index 995671d..0497db8 100644 --- a/lib/chronoscope_web/live/index_live.ex +++ b/lib/chronoscope_web/live/index_live.ex @@ -2,6 +2,7 @@ defmodule ChronoscopeWeb.IndexLive do use ChronoscopeWeb, :live_view alias Chronoscope.NTS + alias Chronoscope.NTS.KeyEstablishmentResponse @topic "nts-servers" diff --git a/lib/chronoscope_web/live/index_live.html.heex b/lib/chronoscope_web/live/index_live.html.heex index 144a507..319e135 100644 --- a/lib/chronoscope_web/live/index_live.html.heex +++ b/lib/chronoscope_web/live/index_live.html.heex @@ -37,7 +37,13 @@ <%= status %>