Skip to content

Conversation

@calvinpark
Copy link
Contributor

@calvinpark calvinpark commented Jan 17, 2025

Description

Owners of Toyota Security Key (TSK) vehicles need to extract the security key and then and write it to SecOCKey param. The biggest hurdle for this is the SSH requirement, as many people have not used SSH or GitHub before.

Extracting the security key is now possible to do without SSH through a community-developed GUI application TSK Manager. By pushing a GUI button, users are able to extract the security key and then write to 1. /data/params/d/SecOCKey to install the param and also to 2. /cache/params/SecOCKey to archive it.

While this works well for the initial extraction and putting the param before the initial openpilot installation, reinstalling openpilot remains to be cumbersome. Uninstalling openpilot deletes the param, so the users must SSH in and write the key again on each uninstall/reinstall.

This PR takes the archived user key and puts it in SecOCKey param. This allows the users who already extracted and archived the key using TSK Manager to restore the key upon a reinstall without using SSH.

A shortcoming of this button is that /cache/params/SecOCKey archive file must already contain the key. The existing users who had used SSH in the past to extract the key (as opposed to using TSK Manager) don't have this file, but such people already have SSH configured so it's not difficult to guide them to create the archive file.

Verification
Tested on my device

@github-actions github-actions bot added the ui label Jan 17, 2025
@calvinpark
Copy link
Contributor Author

Made it a bit shorter. I'm not sure how to make it simpler without removing validation or user interactions.

@github-actions
Copy link
Contributor

UI Preview

settings_device : $${\color{red}\text{DIFFERENT}}$$
master proposed
diff composite diff
driver_camera : $${\color{red}\text{DIFFERENT}}$$
master proposed
diff composite diff
All Screenshots

@jyoung8607
Copy link
Collaborator

You can do this in two lines of shell script. Just make launch_openpilot.sh copy the /cache key to params if it exists. You don't even need to add backup functionality, just start instructing users to put the key in /cache.

@calvinpark
Copy link
Contributor Author

calvinpark commented Jan 17, 2025

I can totally do that if they're okay with me changing launch_openpilot.sh.

cp /cache/params/SecOCKey /data/params/d/SecOCKey || true

But at the same time, a GUI button can also show the current key which is nice.

I guess why not both? Have the settings just show the current key without a button

@jyoung8607
Copy link
Collaborator

I could say a lot of things, but if I may skip to the point: there's a window here to ship the one-liner (nice!) but the UI change is much harder to justify, so let's take yes for an answer on the things we are all agreeing on and ship it.

@calvinpark
Copy link
Contributor Author

One liner done

@calvinpark calvinpark changed the title SecOCKey Restore button Install user SecOCKey to params Jan 17, 2025
Copy link
Collaborator

@jyoung8607 jyoung8607 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot most of the code was still in launch_chffrplus, move it there and put it inside the agnos_init function, so it only runs on AGNOS. Eventually comma wants launch_openpilot.sh to work on PC. Other than that, LGTM.

Copy link
Collaborator

@jyoung8607 jyoung8607 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction, you'll need to handle the first time startup case when /data/params hasn't been created yet.

@calvinpark
Copy link
Contributor Author

calvinpark commented Jan 17, 2025

Should it go into launch function instead? A user may have their key changed and re-extracted, so the file should be copied on every time OP runs. That solves the /data/params dir problem too

@calvinpark
Copy link
Contributor Author

Never mind, I see what you mean. Moving it into agnos_init

Copy link
Contributor

@adeebshihadeh adeebshihadeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move it here for better locality:

if self.CP.secOcRequired and not self.params.get_bool("IsReleaseBranch"):

@github-actions github-actions bot added the car vehicle-specific label Jan 17, 2025
@calvinpark
Copy link
Contributor Author

Ready for a review

@calvinpark
Copy link
Contributor Author

All checks passing

@adeebshihadeh adeebshihadeh merged commit 5509850 into commaai:master Jan 18, 2025
16 checks passed
@calvinpark calvinpark deleted the secoc-restore branch January 18, 2025 19:40
ssysm pushed a commit to MOTIF-lab/openpilot that referenced this pull request Feb 13, 2025
* Install user SecOCKey to params

* Move it to launch_chffrplus.sh/launch

* Move it to card.py

* Basic error check

* Catch Exception to suppress the linter

* Make it local to secOC section
qzwf pushed a commit to qzwf/openpilot that referenced this pull request Feb 25, 2025
* Install user SecOCKey to params

* Move it to launch_chffrplus.sh/launch

* Move it to card.py

* Basic error check

* Catch Exception to suppress the linter

* Make it local to secOC section
calvinpark added a commit to calvinpark/openpilot that referenced this pull request Apr 28, 2025
* Install user SecOCKey to params

* Move it to launch_chffrplus.sh/launch

* Move it to card.py

* Basic error check

* Catch Exception to suppress the linter

* Make it local to secOC section
chrispypatt added a commit to chrispypatt/openpilot that referenced this pull request Apr 28, 2025
Install user SecOCKey to params (commaai#34401)
calvinpark added a commit to calvinpark/openpilot that referenced this pull request Apr 28, 2025
* Install user SecOCKey to params

* Move it to launch_chffrplus.sh/launch

* Move it to card.py

* Basic error check

* Catch Exception to suppress the linter

* Make it local to secOC section
chrispypatt added a commit to chrispypatt/openpilot that referenced this pull request Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

car vehicle-specific ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants