Score:2

Software signing with openSSL

sg flag

The company I work for wants me to implement some C functions to automatically sign their software. After doing some research I've found that openSSL is great for doing so.

Before starting the implementation in C, I wanted to get a feeling of the workflow by executing it in the CLI first. But that left me a bit confused, because I'm not sure where certificats should be used here.

These are the steps that I've taken:

  1. Generate a private key
$ openssl genrsa -out privat.pem 2048
  1. Extract public key from private key
$ openssl rsa -in privat.pem -outform PEM -pubout -out public.pem
  1. Sign the example file with the private key
$ openssl dgst -sha256 -sign privat.pem -out sign.sha256 file.txt
  1. Verify the signature with the public key
$ openssl dgst -sha256 -verify public.pem -signature sign.sha256 file.txt

Verified OK

Where would I now use a certificate to proof that the software is from the company?

Also the software is shipping as an application container for debian, where we create our own application header with meta data like checksum for example. I would have to include the signature also in this header, would it be a good idea to store the output of sign.sha256 there? Maybe in Base64?

DannyNiu avatar
vu flag
The `dgst` subcommand is for calculating hash digest of input message data. You should use the `cms` subcommand to operate in CMS data format which allows for signing, encrypting, in addition to digesting.
DannyNiu avatar
vu flag
Pure usage of software are probably off-topic on this site, but your question require non-trivial practical cryptography knowledge to answer, so I'd argue for this question to stay here, but others might have different opinion on topicallity in this case.
fgrieu avatar
ng flag
If the objective is "sign their software" in the sense that has for Windows, then I don't know that OpenSSL can do it. AFAIK it's role in the procedure is restricted to generation of a public/private key pair and matching Certificate Signing Request to a Certification Authority. The signing is done with other tools, typically signtool.exe
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.