(This is split out from @henrygab’s discussions in OTP whitelabel options for RP2350 boards, and is by no means a priority or important. It’s a thought experiment that I’d like to engage in with the community.)
The RP2350 boards have an OTP area that can be used to store things, uh, once. There have been discussions about what to put there; I’d like to put in a plug for a digital signature in the form of an x509 certificate.
But why is it important or necessary?
The Bus Pirate is open source, so where would be the benefit/value-add of a digital signature?
It would be good for Dangerous Prototypes to be able to authenticate that any individual BP is one that they produced, what the serial number is, and when it was produces from the standpoint of tracking, recall, warranty. @ian has been absolutely amazing when it comes to customer service, but at some point it will become important from a business standpoint to more easily and reliably be able to know these things.
Note that I am not saying that there should be some functionality limited only to “official” BPs; only that “official” BPs be easily identified.
Why an x509 certificate?
This is a pretty industry standard method. The cert is signed by a private key held by Dangerous Prototypes and can be authenticated by anyone using the public key. That public key would be hard-coded into the firmware.
What kind of stuff would be in the cert?
- Validity: the
Not Before
date would be the manufacturing date. Set theNot After
10 years later or so; we really only care about the mfg date. - Subject:
C
: probablyNL
?O
: probablyDangerous Prototypes
?OU
: maybeBusPirate
CN
: maybe a description including hardware ver, likeBP7rev1
- x509 Extensions:
- serial number
- I would say mfg location code if there is ever a plan to make them anywhere besides DirtyPCBs
- anything else?
How to create the cert?
This would be need to be done at manufacturing:
- A signing server is on the network, and available to the assembly station where loading takes place.
- The manufacturing computer gets the next serial number (many, many ways to handle this), and sends it to the signing server along with other needed information like hardware model and rev.
- The signing server creates a new cert with today’s date and the other stuff in the
Subject
field - The signing server encodes the serial number as an extension (either bit string or integer; whatever makes sense)
- The server sends the .der-formatted cert to the the mfg computer
How to add the cert?
This would be a manufacturing process. Just like the firmware is loaded at manufacturing, there would need to be an additional process. (Does manufacturing do something like the self test?
There are 2 ways I can think of:
- There is a special “manufacturing” version of firmware:
- This version is not functional
- This version has some test features used in mfg
- This version has a method to copy the cert (in .der format) into OTP, and verify it is there correctly.
- Caveat - Either mfg or the end user has to load the “standard” firmware. When I worked in the ICS supplier world, we would ship it many things with the mfg firmware, forcing the end user to load the latest (or desired) firmware before commissioning the product.
- The “standard” firmware has the OTP write functions:
- Mfg would use this to load the cert
- The function would just fail with an error like “OTP already programmed”
The cert is in OTP, now what?
The running firmware has the public key hard-coded, so whenever it needs to reference the cert, the firmware would first authenticate the cert with that key. If the cert is “OK”, the firmware could extract the important information (mfg date, serial number, hardware information) and populate a global data structure.
When to do this?
- On init? (this wouldn’t take a lot of time)
- When the
i
info command is issued? Then the info could be added to theinfo
output (or some values indicating it is not a “genuine” BP)
When else?
- When the
format
command is issued, the firmware could copy the cert from OTP to the filesystem. That would be kind of cool - a user could look at the cert themselves.
What could go wrong?
CAVEAT - I have not threat-modeled this, so these are just off the top of my head
- OTP Corruption - this is a valid BP, but somehow the OTP was corrupted (either at write or some other time)
- Loss of confidentiality of the private signing key. This can be a hard problem to solve when using a manufacturing facility you don’t control. I would guess it’s not a problem now, but something to think about.
- Errors in the manufacturing process; the cert generation/OTP process is missed due to human error or lack of training.
- Forgeries:
- A bad actor could make BPs and copy the contents of the OTP to their product. That data would pass validation and show as a “genuine” BP, but every one the bad actor made would have the same serial number and mfg date
- A bad actor could create their own private/public keypair and make their own certs and load them into OTP. They would also fork/clone the firmware and change it to use their public key. The BPs they make would have unique serial numbers and mfg dates that would validate until the user (or anyone else) loads firmware from Dangerous Prototypes.
The good thing is that an error or problem with the signature really doesn’t cause a lot of problems. To the user/consumer, their Bus Pirate will function correctly; but there may be an issue with warranty or a missed tracking/recall campaign. I don’t forsee forgeries becoming an issue.
Ok, that was a little long winded, but thoughts? I could argue it adds complexity with minimal value added, but it’s still worth talking about.
(Note - this sounds interesting, so I just ordered a few $5.00 2350 boards to experiment with. Just what I needed - another distraction! :D)