Let's say I change the password for the root & pi user to something impossible to brute force, say 20 characters.

Then in one of my files on my raspberry pi, I hardcode a password.

Is this password secure? The user has unlimited physical access to the raspberry pi. (I am selling a device with a pi connected to it).

What if I use full disk encryption?

In case anyone is asking why I am doing this, I have a server endpoint that registers serial numbers of pi's I sell. Only registered serial numbers can access my server's platform. I don't want to have to plug in every raspberry pi I sell into a computer and copy the serial number into the database on my server. Instead, the sd card for the raspberry pi includes a script that encrypts the serial number and sends it to my server.

On my server, if decryption is successful, then it implies the serial number is valid and came from a raspberry pi. (Note I use aes-256-gcm).

In this way, I am hoping that all I have to do is flash a new sd card in order to sell my device. (As opposed to flash sd card + insert to raspberry pi + cat /proc/cpuinfo to get the serial number + POST that to my server).

If the file with a password is not secure, what can I do to secure it?

  • 3
    This isn't really possible without secure hardware, all you can do is try to make it more difficult. Your current solution is trivially breakable by reading the sd card directly with another computer. Jul 18, 2018 at 17:04
  • @AndrolGenhald what if I use full disk encryption? Jul 18, 2018 at 17:08
  • 2
    @TerenceChow: And who has the key to the full disk encryption? Given that the user should be able to run the system the user will probably have the key or the key is on the device - same problem again in that the user can simply mount the sdcard with the known key on a different system and access the file. Jul 18, 2018 at 17:25
  • 1
    Will the user ever have to restart it? If so, they'll need to enter the password, so it'll be useless. The only way I really see that working is if you enter the password in person every time it's booted. Even then, depending on how much effort they're willing to put into it, it's still breakable (the key necessarily exists in RAM or the CPU while it's running). Jul 18, 2018 at 17:25
  • What will you do to prevent an attacker from submitting a previously registered serial number from a different device? Since this scheme is only a mild deterrent in the first place, you could provide a mild deterrent to key theft. One idea might be to use a code obfuscation to simply make the key more difficult to extract from the binary. Jul 18, 2018 at 22:26


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.