What happens when code is signed

Code signing is performed using a code signing application. In order to sign code, the code signing application needs, at a minimum, these three pieces of information:

  • The code to be signed
  • The certificate to use to sign the code
  • The hashing algorithm to use

At a basic level, the signing application performs the following steps:

  1. Verifies that the code signing certificate is available.
  2. Checks which hashing algorithm to use.
  3. Runs the specified hashing algorithm over the code binary to produce a hash of the code.
  4. Signs (or encrypts) the hash using the private key associated with the certificate.
  5. Adds the signed hash and the certificate, known as a digital signature, to the code being signed. How this occurs varies between signing applications.

NOTE  The code itself is not signed. What is signed is the hash.

With the digital signature now created, the code is ready to be distributed. Using the information that is included in the digital signature, the recipients of the code will be able to verify the integrity and authenticity of the code.