Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions lib/ex_ice/priv/ice_agent.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2675,8 +2675,8 @@ defmodule ExICE.Priv.ICEAgent do
end

defp generate_credentials() do
ufrag = :crypto.strong_rand_bytes(3) |> Base.encode64()
pwd = :crypto.strong_rand_bytes(16) |> Base.encode64()
ufrag = :crypto.strong_rand_bytes(3) |> Base.encode64(padding: false)
pwd = :crypto.strong_rand_bytes(16) |> Base.encode64(padding: false)
{ufrag, pwd}
end

Expand Down
17 changes: 17 additions & 0 deletions test/priv/ice_agent_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2908,6 +2908,23 @@ defmodule ExICE.Priv.ICEAgentTest do
assert <<_channel_number::16, _len::16, "somedata">> = packet
end

describe "generate_credentials/0" do
test "generates credentials without padding" do
ice_agent =
ICEAgent.new(
controlling_process: self(),
role: :controlling,
if_discovery_module: IfDiscovery.MockSingle,
transport_module: Transport.Mock
)

refute String.contains?(ice_agent.local_ufrag, "=")
refute String.contains?(ice_agent.local_pwd, "=")
assert byte_size(ice_agent.local_ufrag) == 4
assert byte_size(ice_agent.local_pwd) == 22
end
end

defp connect(ice_agent) do
[socket] = ice_agent.sockets
[remote_cand] = Map.values(ice_agent.remote_cands)
Expand Down