# OpenSSL - What Data Is Used To Create A Certificate's Digital Signature?

I am coming up-to-speed on OpenSSL certificates. In all of my research I see where "data" is hashed to create a hash value that is used as the basis for a certificate's digital signature. This hash value is encrypted using the sender's private key, at which point it becomes the certificate's digital signature.

What "data" is hashed? Is it specific information from the certificate? Is it all certificate information? Does the the data include the certificate's public key? Or, is the data some random number or string that is generated by OpenSSL when the certificate is created? I'm assuming that the "data" is certificate data since one of the functions of PKI is to validate that the contents of a message (in this case a certificate) haven't changed since the message was created.

• This is not specific to OpenSSL, which implements certificates defined by X.509 and PKIX, standards also implemented by thousands of other programs. For a concrete, detailed example of the verification side, see security.stackexchange.com/questions/127095/… (disclosure: I provided a chunk of the answer) Jun 7 '20 at 23:24

## 1 Answer

This applies over the entire certificate data. Per RFC 5280, section 4.1.1.3:

   The signatureValue field contains a digital signature computed upon
the ASN.1 DER encoded tbsCertificate.  The ASN.1 DER encoded
tbsCertificate is used as the input to the signature function.  This
signature value is encoded as a BIT STRING and included in the
signature field.  The details of this process are specified for each
of the algorithms listed in [RFC3279], [RFC4055], and [RFC4491].

By generating this signature, a CA certifies the validity of the
information in the tbsCertificate field.  In particular, the CA
certifies the binding between the public key material and the subject
of the certificate.


So every single field of the certificate is part of the signature (except of course for the signature). This is to guarantee that no element of it was tampered with (there is pretty much no field in the certificate that is not important. Even if one were, it's easier to require everything to be signed regardless of the use).

About public keys:

• subject public key is definitely included. Note the last sentence I quoted. This is one of the critical parts of the certificate: who it was issued to.
• issuer public key is not included in the certificate and therefore is not part of the signature. Instead, the subject field of the issuer is included as well as the Certificate Authority Key ID which can be found in the issuer's certificate under Subject Key ID. This is used in path building.
• Thanks for the explanation, @Marc! This is EXACTLY what I was looking for. I confirmed in RFC 5280, Sections 4.1.1.1 and 4.1.2 that the public key IS included as a field in the data that is used to generate the hash value that is used to generate the certificate's digital signature. Jun 7 '20 at 19:08
• Note my edit: the subject public key has to be. The issuer public key is not part of the certificate or signature (but its ID is).
– Marc
Jun 7 '20 at 19:09