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

Refactor tkey-verification: new ways of accessing compiled-in assets #19

Merged
merged 59 commits into from
Jul 3, 2024

Conversation

mchack-work
Copy link
Member

@mchack-work mchack-work commented Apr 18, 2024

Refactoring to:

  • Include the device binaries in the repo directly. Remove the build scripts for verisigner. Use the ordinary tkey-device-signer for new stuff. If a user wants to build verisigner, they have to use old tags and the instructions there.

  • Use ordinary tkeyclient package instead of internal version.

  • Use the ordinary tkeysign package to communicate with both signer, these days updated to be able to get a firmware hash, and the old verisigner.

  • Use new way of accessing internal assets like: vendor public keys, known firmwares, and the app binaries. We're now more idiomatic in the access and use something like foos := NewFoo() with methods on foo to do something with them.

  • Support multiple vendor keys at the same time for verification.

  • Make the external command show-pubkey into just another command in tkey-verification.

  • Error handling much changed. Still a little different in verify.go compared to the rest of the program. Not sure what we do about that. Perhaps just leave it.

A good way to start to understand the refactoring is to look in the new Implementation notes

Closes #18

@mchack-work mchack-work requested a review from dehanj April 18, 2024 10:09
@dehanj dehanj mentioned this pull request May 17, 2024
@dehanj dehanj force-pushed the signer branch 5 times, most recently from 9ec8987 to 5b577a9 Compare May 23, 2024 20:35
@mchack-work mchack-work force-pushed the signer branch 3 times, most recently from f1a1757 to 15b27d8 Compare June 17, 2024 18:33
@mchack-work mchack-work force-pushed the signer branch 6 times, most recently from d71b79a to 5118321 Compare June 25, 2024 16:21
@mchack-work mchack-work changed the title Include device app binaries and use tkey-device-signer Refactor tkey-verification: new ways of accessing compiled-in assets Jun 25, 2024
@mchack-work mchack-work force-pushed the signer branch 2 times, most recently from c1d20ad to 979ac2c Compare June 25, 2024 16:46
@mchack-work
Copy link
Member Author

mchack-work commented Jun 25, 2024

  • Updated the description of what this PR does.
  • Rebased on main.
  • Squashed and reworded many commits.

Please have a look @dehanj. Do you think we should squash the entire thing into something like the new PR description or do we leave the individual commits? Some of them are mostly small fixes.

Not sure what to do about the first commit... It's from the tkey-libs branch which has been abondened. Do we even try to remove it?

@mchack-work mchack-work marked this pull request as ready for review June 26, 2024 08:44
@mchack-work mchack-work force-pushed the signer branch 2 times, most recently from 5b130a4 to e9288e3 Compare June 26, 2024 09:24
- We include compiled device app binaries in the repo.

- We move internal packages used to get at assets like app bins,
  firmwares, and vendor pubkeys under the tkey-verification command.
We turn this into a command in tkey-verification itself instead.
- tkeyclient instead of old tk1
- tkeysign instead of tk1sign
- Update go packages
- Use digests as strings
- Rename some variables as a consequence of above
mchack-work and others added 23 commits July 2, 2024 22:17
- Include long-lived CA and certificates for testing purposes.
- Remove gotools and, with it, the certstrap tool. Instead let the
  user install it themselves, if wanted.
- Change README and Makefile accordingly.
Terminate in a nice way if the user types Control-C or something.
- Silence lint for 0644 mode
- Pre-alloc slices
- Remove unused variables
- Revise linting config

  - Enable er113
  - Disable unparam
Especially when doing verification we just want to output the UDI and
if the TKey is genuine or not.
We split the errors into different categories to make it more easy for
a user to reason about what went wrong.

- commFailed: I/O errors, communication with the TKey, with an HTTP
  server, or a local file.

- parseFailure: Parsing something from external sources failed.

- missing: Something is missing in the binary to complete a
  verification.

- notFound: Using external data we can't find something.

- verificationFailed: a problem with verification of firmware, the
  vendor signature or the signature of the challenge.
- Build actual man page depending on scdoc source
- Add convenience target for man page
Update because of the refactoring to include the binaries in the repo,
allow several vendor keys, and change the building.

Co-authored-by: dehanj <jobson@tillitis.se>
- Use constant errors.
- Use more specific details as log messages.
- Add check for correct app digest length.
- Move MessageLen to only place where it's used, in the API's error
  handling, and make it a constant.
- Use constant errors where possible
- Use error types when not possible.
- Verify against all known vendor pubkeys
- Remove the check for just 1 vendor key.
- Increase error reporting.
Exit cleanly on errors, closing the TKey connection.
Explain the assets and their functions:

- appbins
- firmwares
- vendor pubkeys
Used only by removed program show-pubkey
We index the device apps by hash. Also look after indexing that the
app name and tag is the expected one.
- Latest() -> Current()
- latestAppHash -> currentAppHash
Since we verify against all known vendor keys we might as well make
the digest of the app used for vendor signing configurable instead.
It's only used when we do the `serve-siger` command. Let the vendor
decide which of the built-in apps they want to use.

When we list the vendor keys in --built, list all of them, not just
the formerly built-in current vendor key.
- Instead of hard coded digest of the app to be used for device
  signing during provisioning, we add it to the configuration file as
  `signingapphash`.

- As a consequence of above, redo configuration loading and make it
  explictly for either server-signer or remote-sign commands.

- As a consequence of this, move TLS config and server setup to the
  remote sign command directly.

- Remove the undocumented sign-challenge command instead of updating
  it to work with the new version.
Copy link
Member

@dehanj dehanj left a comment

Choose a reason for hiding this comment

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

Managed to squash another 6 commits.

At this stage it looks good to me.
I have verified:

  • multiple vendor signing key support, and hence do signing and verifying
  • that it does not break verification files out in the field
  • Setting up the a test environment with QEMU
  • the new speed command
  • Added the correct year for the copyright notices
  • Revised part of readme (squashed)

Ready to merge.

mchack-work and others added 2 commits July 3, 2024 14:17
Allow setting of speed for communication with TKey in all commands.
@mchack-work mchack-work merged commit 0efa89a into main Jul 3, 2024
2 checks passed
@mchack-work mchack-work deleted the signer branch July 3, 2024 12:27
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.

Use tkey-device-signer, include binaries in repo
2 participants