2

We are using Beaglebone Black (AM335x) based custom board, so for firmware upgrades of the board we will be using an encrypted firmware image.

As you would have already guessed, we will be using symmetric encryption to encrypt a large firmware file (fimware tar) and then encrypt the symmetric key with an asymmetric key. So we have two files which is to be given to the user for upgrading his board. Now we don't want to do that, we want to give only one file to user.

So we have to somehow combine the encrypted firmware image and the encrypted symmetric key.

I thought of two strategies, I will encrypting firmware using bash script,

  • Tar encrypted firmware and encrypted symmetric key. But its very slow.
  • Append encrypted symmetric key to the encrypted tar file. Don't feel this is a clean approach, isn't it?

Any suggestion on how to handle this in a fast and better way?

Note
I have posted this question on Stack Overflow but thought this question could possibly also belongs to Information Security. Let me know if you don't feel its right.

  • (a) Please do not cross-post, its very, very, very poor netiquette !! (b) How about just appending the additional data you need to do the base file, and then have your functions split it out again ? – Little Code Jun 8 '16 at 11:23
  • @LittleCode Sure, I will take care. I feel there should be way to link post to multiple SO website, sometimes its a confusion as in where you would expect help. :( I didn't get your suggestion, I feel what you suggested is the second strategy what I have added in the original post, isn't it ? – AnkurTank Jun 8 '16 at 11:30
2

I think you just need to use PGP/GPG encryption and encrypt the archive using your private key (under the hood PGP/GPG will do the same as you described: it will generate a random symmetric key, encrypt the body of the payload with it, then will encrypt the symmetric key with your private asymmetric key).

This will give you a single encrypted file. All that is left is to incorporate your public key into the base system of your board (you can also publish you public key on your website, so users will be able to decrypt the archive if they want to.

Most manufacturers are implementing this approach and they are using the embedded public key to ensure that the update/upgrade process works with firmwares produced by the manufacturer (the one who has the corresponding private key). This approach works until there is a flow in your board's system that would allow an attacker to tamper with the embedded public key.

  • Especially if OP publishes their public key in some easy-to-locate place, this has the added benefit of giving users a relatively easy way to verify the validity of the file they downloaded. – a CVn Oct 12 '16 at 11:06
1

You should just use the simple archive(default) feature of tar to pack some data together:

tar cvf output.tar data.tar.gz key

You can also make the file(readonly) available on private (or maybe on public) network, and send the sym key and url to the users encrypted by their public keys.

  • Thank you for reply, tar is indeed a solution but its slow considering my firmware image can be of 200MB to 300MB. While encryption is still not an issue as it is done on the server PC, decryption time is an issue as that is carried out on the AM335x board. Untaring firmware image file and encrypted symmetric key adds to the decryption time. – AnkurTank Jun 8 '16 at 13:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.