-
Notifications
You must be signed in to change notification settings - Fork 0
Secure channel / install mode #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,7 @@ defmodule Jeff.Message do | |
end | ||
|
||
@spec scs(Jeff.osdp_address(), byte(), boolean()) :: | ||
0x11 | 0x12 | 0x13 | 0x14 | 0x17 | 0x18 | nil | ||
0x11 | 0x12 | 0x13 | 0x14 | 0x15 | 0x17 | 0x18 | nil | ||
def scs(address, code, sc_established?) do | ||
do_scs(type(address), code, sc_established?) | ||
end | ||
|
@@ -99,6 +99,7 @@ defmodule Jeff.Message do | |
defp do_scs(:reply, 0x76, _), do: 0x12 | ||
defp do_scs(:command, 0x77, _), do: 0x13 | ||
defp do_scs(:reply, 0x78, _), do: 0x14 | ||
defp do_scs(:command, id, true) when id in [0x60, 0x64, 0x65, 0x66, 0x67], do: 0x15 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was the most critical change to get things to work -- commands with no data payload need to use SCS 0x15. It would have been nice to calculate this based on the actual payload length, but that was a bigger refactor than I wanted to do, and there are a fixed number of commands with no payload. |
||
defp do_scs(:command, _, true), do: 0x17 | ||
defp do_scs(:reply, _, true), do: 0x18 | ||
defp do_scs(:command, _, false), do: nil | ||
|
@@ -144,7 +145,7 @@ defmodule Jeff.Message do | |
|
||
defp maybe_add_mac(%{bytes: bytes, device: device} = message) do | ||
{secure_channel, mac} = | ||
if add_mac?(message) do | ||
if device.secure_channel.established? && add_mac?(message) do | ||
secure_channel = SecureChannel.calculate_mac(device.secure_channel, bytes, true) | ||
{secure_channel, secure_channel.cmac |> :binary.part(0, 4)} | ||
else | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where I got hung up on this PR was trying to decide how much install mode Jeff should be responsible for. This is the basic logic implemented in this PR in pseudocode: