Skip to content
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

Secure channel / install mode #35

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bjyoungblood
Copy link
Member

No description provided.

@@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Comment on lines +126 to +136
def next_command(
%{
security?: true,
install_mode?: true,
secure_channel: %{established?: true, scbkd?: true},
address: address
} = device
) do
command = Command.new(address, KEYSET, key: device.scbk)
{device, command}
end
Copy link
Member Author

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:

if Jeff.add_device was called with a non-nil SCBK:
  Try to establish a secure channel with the given SCBK
  If secure channel is successful:
    Done
# Else if install mode is not allowed:
#   I was planning to implement this case, but I removed it
#   because of the same issue in the on failure case below
#   (not having a way to signal that a device is not working
#   properly)
  Else:
    Try to connect with the install mode SCBK
    On success:
       Issue a KEYSET command to set the SCBK on the device
       Restart the secure channel with the new SCBK
    On failure:
       TODO -- what _should_ happen here? We don't currently
       have a way to indicate that a device isn't working
       as expected

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.

1 participant