Tutorial 2.15: Digital Signatures and Public Key Infrastructure

Table of Contents

Learning Objectives

After completing this tutorial, you should be able to:

Overview

Digital signatures are the public-key equivalent of handwritten signatures. They provide a way to verify the authenticity and integrity of a message or document, and they ensure that the signer cannot later deny having signed it—a property known as non-repudiation. Digital signatures are fundamental to modern security systems, enabling secure software distribution, electronic commerce, legal documents, and authentication protocols such as TLS.

Unlike MACs, which use symmetric keys and do not provide non-repudiation, digital signatures use asymmetric cryptography. A signer uses their private key to create a signature, and anyone with the corresponding public key can verify it. This binding between a public key and an identity is achieved through Public Key Infrastructure (PKI), which issues digital certificates that attest to the ownership of a public key by a named entity.

In this tutorial, we explore digital signatures in depth. We begin by defining their properties and security requirements. We then examine the major signature schemes: RSA signatures, DSA, ECDSA, and EdDSA. We discuss the importance of padding schemes and hash functions. We then introduce PKI, covering X.509 certificates, Certificate Authorities (CAs), Registration Authorities (RAs), certificate validation, and revocation mechanisms (CRLs and OCSP). We also discuss trust models and the challenges of PKI deployment.

The tutorial concludes with real-world applications and case studies that illustrate the importance and vulnerabilities of digital signatures and PKI.

Relationship to the Tutorial Series

In Tutorials 2.11–2.14, we studied public-key cryptography, RSA, Diffie-Hellman, and ECC. This tutorial builds on those algorithms to provide digital signatures. It also introduces PKI, which is essential for using public keys in practice. Tutorial 2.16 will cover cryptographic protocols and applications that rely on digital signatures and PKI.

Introduction to Digital Signatures

Digital Signature
A cryptographic value generated from a message and a private key, such that anyone with the corresponding public key can verify the authenticity and integrity of the message. Digital signatures provide:

Digital signatures are typically created by hashing the message and then signing the hash. This is more efficient than signing the entire message and allows for signing large documents.

┌─────────────────────────────────────────────────────────────────┐ │ DIGITAL SIGNATURE PROCESS │ ├─────────────────────────────────────────────────────────────────┤ │ │ │ Signing: │ │ Message ──► Hash ──► Sign with Private Key ──► Signature │ │ │ │ Verification: │ │ Message ──► Hash ──► Verify Signature with Public Key │ │ │ │ • Signature is tied to the message and the signer's identity. │ │ • Verifying the signature confirms authenticity and integrity.│ └─────────────────────────────────────────────────────────────────┘

Figure 1: Digital signature creation and verification.

Security Properties of Digital Signatures

A secure digital signature scheme must satisfy the following properties:

1. Unforgeability

It must be computationally infeasible for an adversary to create a valid signature for a message without the private key.

2. Non-repudiation

Once a signature is verified, the signer cannot deny having signed the message.

3. Message Integrity

Any modification to the message will cause the signature verification to fail.

4. Existential Unforgeability

The adversary cannot generate a valid signature for any new message, even if they have seen signatures for other messages.

5. Resilience to Chosen-Message Attacks

The scheme remains secure even if the adversary can obtain signatures for messages of their choice.

Security Models

RSA Signatures

RSA can be used for both encryption and signatures. The RSA signature scheme is similar to encryption but with the roles of the keys reversed.

RSA Signature Generation

1. Compute hash h = Hash(M).
2. Encode h using a padding scheme (e.g., PSS or PKCS#1 v1.5).
3. Compute signature σ = hd mod n, where d is the private key.
4. Output σ.

RSA Signature Verification

1. Compute h = Hash(M).
2. Compute h' = σe mod n, where e is the public exponent.
3. Decode h' and compare to h (with padding check).
4. Accept if equal; reject otherwise.

Security of RSA Signatures

RSA Signature Example (Small Numbers)

Using RSA with n=391, e=7, d=151 from Tutorial 2.12, sign a message with hash h=88 (assume h is already padded).
σ = 88151 mod 391 = 130 (using modular exponentiation).
Verify: h' = 1307 mod 391 = 88. Signature is valid.

Digital Signature Algorithm (DSA)

DSA is a U.S. government standard for digital signatures (FIPS 186). It is based on the discrete logarithm problem in a finite field.

DSA Parameters

DSA Signing

1. Compute hash h = Hash(M).
2. Generate random ephemeral key k ∈ [1, q−1].
3. Compute r = (gk mod p) mod q. If r = 0, choose new k.
4. Compute s = k−1 (h + x·r) mod q. If s = 0, choose new k.
5. Output signature (r, s).

DSA Verification

1. Check 0 < r < q and 0 < s < q.
2. Compute h = Hash(M).
3. Compute w = s−1 mod q.
4. Compute u₁ = h·w mod q, u₂ = r·w mod q.
5. Compute v = (gu1 · yu2 mod p) mod q.
6. Accept if v = r; reject otherwise.

DSA Security

Elliptic Curve Digital Signature Algorithm (ECDSA)

ECDSA is the elliptic curve variant of DSA. It provides the same security as DSA with much smaller key sizes.

ECDSA Parameters

ECDSA Signing

1. Compute hash h = Hash(M).
2. Generate random ephemeral key k ∈ [1, n−1].
3. Compute R = [k]P = (x₁, y₁). If R = O, choose new k.
4. Compute r = x₁ mod n. If r = 0, choose new k.
5. Compute s = k−1 (h + d·r) mod n. If s = 0, choose new k.
6. Output signature (r, s).

ECDSA Verification

1. Check 0 < r < n and 0 < s < n.
2. Compute h = Hash(M).
3. Compute w = s−1 mod n.
4. Compute u₁ = h·w mod n, u₂ = r·w mod n.
5. Compute V = [u₁]P + [u₂]Q.
6. If V = O, reject.
7. Let x-coordinate of V be x₁. Accept if x₁ mod n == r; reject otherwise.

Security and Vulnerabilities

EdDSA (Ed25519)

EdDSA is a modern digital signature scheme designed by Daniel J. Bernstein, using the Edwards curve Ed25519. It provides high security, excellent performance, and resistance to side-channel attacks.

EdDSA Features

EdDSA Signing (Simplified)

1. Compute deterministic nonce k = H(d || M) mod n.
2. Compute R = [k]P.
3. Compute h = H(R || A || M) where A is the public key.
4. Compute s = k + h·d mod n.
5. Output signature (R, s).

EdDSA Verification

1. Check that R is a valid point and s is in range.
2. Compute h = H(R || A || M).
3. Check that [s]P = R + [h]A.
4. Accept if valid.

EdDSA is used in many modern protocols, including TLS 1.3, SSH, and OpenPGP.

Padding for Signatures (PSS, PKCS#1)

PKCS#1 v1.5 Signature Padding

The PKCS#1 v1.5 signature padding format is:

0x00 || 0x01 || PS || 0x00 || ASN.1(hash)

where PS is a string of 0xFF bytes (to make the block length equal to the modulus size).

Vulnerability: PKCS#1 v1.5 is not provably secure; it is vulnerable to some attacks (e.g., Bleichenbacher's attack on RSA encryption, though less severe for signatures). However, it is widely used in legacy systems.

Probabilistic Signature Scheme (PSS)

PSS is a modern padding scheme for RSA signatures, defined in PKCS#1 v2.1. It provides provable security against existential forgery attacks.

PSS uses:

Advantage: PSS is provably secure in the random oracle model.

Recommendation: Use RSA-PSS for RSA signatures in new systems. For ECDSA, no additional padding is needed (the signature includes randomness via k). For EdDSA, the deterministic nonce provides security.

Public Key Infrastructure (PKI)

A digital signature is only as trustworthy as the binding between the public key and the identity. PKI provides this binding through digital certificates issued by trusted entities.

Public Key Infrastructure (PKI)
A system of policies, procedures, and technologies that manages digital certificates and public-key encryption. It provides a trusted framework for binding public keys to identities.

PKI Components

┌─────────────────────────────────────────────────────────────────┐ │ PKI ARCHITECTURE │ ├─────────────────────────────────────────────────────────────────┤ │ │ │ End Entity (User) ──► RA ──► CA ──► Certificate Repository │ │ │ │ CA signs certificates and CRLs. │ │ RA verifies identity. │ │ Repository publishes certificates and revocation status. │ │ Relying parties verify certificates using CA's public key. │ └─────────────────────────────────────────────────────────────────┘

Figure 2: Public Key Infrastructure architecture.

Digital Certificates (X.509)

The most common certificate format is X.509, defined by ITU-T and used in TLS, S/MIME, and many other protocols.

X.509 Certificate Fields

FieldDescription
VersionX.509 version (1, 2, or 3)
Serial NumberUnique identifier assigned by the CA
Signature AlgorithmAlgorithm used by the CA to sign the certificate (e.g., SHA-256 with RSA)
IssuerDistinguished Name (DN) of the CA
ValidityNot Before and Not After dates
SubjectDN of the certificate holder
Subject Public Key InfoThe public key and its algorithm
Extensionsv3 extensions (e.g., Subject Alternative Name, Key Usage, Basic Constraints)
SignatureDigital signature of the CA over the certificate

Certificate Chain and Trust Anchors

A certificate chain starts from the end-entity certificate and goes up through intermediate CA certificates to a root CA certificate, which is trusted (the trust anchor).

Validation involves:

  1. Verifying the signature of each certificate in the chain.
  2. Checking that each certificate is within its validity period.
  3. Verifying that the certificate is not revoked.
  4. Checking that the certificate's purpose (Key Usage, Extended Key Usage) matches the intended use.

Certificate Lifecycle

1. Key Pair Generation

The end entity generates a public/private key pair. The private key is kept secret; the public key is submitted to the CA.

2. Certificate Signing Request (CSR)

The end entity sends a CSR containing the public key, identity information, and a signature (proving possession of the private key).

3. Identity Verification

The RA verifies the identity of the requester (e.g., domain validation, organization validation, extended validation).

4. Certificate Issuance

The CA signs the certificate and publishes it.

5. Certificate Deployment

The end entity installs the certificate on their server or device.

6. Certificate Renewal

Certificates have a validity period (e.g., 1-2 years). Before expiry, the entity obtains a new certificate.

7. Certificate Revocation

If the private key is compromised or the certificate is no longer valid, the CA revokes it.

Certificate Revocation (CRL, OCSP)

Certificate Revocation Lists (CRLs)

A CRL is a list of revoked certificates, signed by the CA and published periodically. It contains the serial numbers of revoked certificates and the revocation date.

Limitations: CRLs are large, may be out of date (periodic updates), and require downloading the entire list.

Online Certificate Status Protocol (OCSP)

OCSP allows a relying party to query the CA (or an OCSP responder) for the revocation status of a specific certificate in real time.

Advantage: Timely and lightweight (only one certificate per query).

Security: OCSP responses must be signed by the CA or a trusted responder.

OCSP Stapling

To reduce load on OCSP servers and improve privacy, the server includes an OCSP response in the TLS handshake (stapling). This allows the client to verify the certificate's status without contacting the CA directly.

CRLite

A newer approach that uses a compact Bloom filter to efficiently distribute revocation information.

Trust Models

1. Hierarchical Trust (Root CA Model)

Root CA → Intermediate CA → End Entity. This is the standard model used in web PKI. Trust is anchored in a root CA whose public key is pre-installed in browsers and operating systems.

2. Web of Trust

Used in PGP/GPG. Users sign each other's public keys, creating a distributed network of trust. There is no central authority; trust is transitive.

3. Direct Trust

Parties manually exchange and verify each other's public keys (e.g., SSH with known_hosts).

4. Bridge CA

A CA that cross-certifies with other CAs to enable inter-domain trust.

Standards and Formats

Certificate Standards

Encoding Formats

Applications of Digital Signatures and PKI

Transport Layer Security (TLS)

TLS uses digital certificates for server authentication (and optionally client authentication). The server presents a certificate signed by a CA; the client verifies the certificate chain.

Secure Email (S/MIME, PGP)

S/MIME uses X.509 certificates to sign and encrypt emails. PGP uses a web of trust for key verification.

Code Signing

Software developers sign their code with a digital signature. Users (or operating systems) verify the signature to ensure the software comes from the claimed publisher and has not been tampered with.

Document Signing

Digital signatures are used to sign legal documents, contracts, and PDFs. Standards include PDF signatures (based on X.509) and electronic signatures (e.g., eIDAS in Europe).

Authentication (SSH, VPN)

SSH uses public keys (often self-signed) for user authentication, sometimes with certificates for host authentication. VPNs (IPsec) use certificates for authentication.

Blockchain and Cryptocurrency

Bitcoin and other cryptocurrencies use ECDSA signatures to authorize transactions.

Case Studies

Case Study 1: The DigiNotar CA Compromise (2011)

DigiNotar, a Dutch CA, was compromised, leading to the issuance of fraudulent certificates for high-profile domains including google.com. Attackers used these certificates to perform man-in-the-middle attacks against Iranian users. The incident led to the removal of DigiNotar's root certificate from all major browsers and the eventual bankruptcy of the company.

Lesson: CA security is critical; a single compromised CA can undermine trust in the entire PKI.

Case Study 2: The Flame Malware and MD5 Collisions (2012)

Flame used an MD5 collision to forge a Microsoft certificate, allowing it to appear as legitimate Windows Update software. This demonstrated that weak hash functions in signature schemes can have severe consequences.

Case Study 3: The Heartbleed Bug and Certificate Revocation (2014)

Heartbleed exposed private keys on many servers. The affected certificates had to be revoked. The incident highlighted the importance of timely revocation (CRL/OCSP) and the challenges of large-scale revocation.

Case Study 4: The SHA-1 Deprecation (2017)

With the SHAttered collision attack, SHA-1 was broken. Major browsers and CAs stopped issuing SHA-1 certificates, migrating to SHA-256. This illustrates the need for agility in signature algorithms.

Key Takeaways

Quiz

  1. What is the primary purpose of a digital signature?
  2. AnswerTo provide authentication (ensuring the message came from the claimed signer), integrity (ensuring the message was not altered), and non-repudiation (preventing denial of signing).
  3. What is the difference between a MAC and a digital signature?
  4. AnswerA MAC uses a symmetric key and does not provide non-repudiation; a digital signature uses asymmetric keys and provides non-repudiation because only the private key holder could have signed.
  5. What is the role of hashing in digital signatures?
  6. AnswerHashing produces a fixed-size digest of the message, which is then signed. This is more efficient than signing the entire message and allows signing of large documents.
  7. What is the RSA signature operation (sign and verify)?
  8. AnswerSign: σ = hd mod n (where h is the hash and d is the private key). Verify: check that σe mod n = h (where e is the public exponent).
  9. What is the most critical vulnerability in ECDSA regarding randomness?
  10. AnswerThe ephemeral nonce k must be unique for each signature. If k is reused, the private key can be recovered.
  11. What is EdDSA and what makes it different from ECDSA?
  12. AnswerEdDSA is a deterministic signature scheme using Edwards curves (e.g., Ed25519). It avoids nonce generation by deriving k deterministically from the message and private key, providing side-channel resistance and simplicity.
  13. What is the purpose of padding in RSA signatures (e.g., PSS)?
  14. AnswerPadding (like PSS) provides semantic security and prevents attacks such as existential forgery. It adds randomness and structure to the signed hash, making it resistant to chosen-message attacks.
  15. What are the main components of a PKI?
  16. AnswerCA (Certificate Authority), RA (Registration Authority), certificate repository, end entities, and validation authority (OCSP responder).
  17. What is an X.509 certificate and what are its key fields?
  18. AnswerX.509 is the standard certificate format. Key fields include version, serial number, signature algorithm, issuer, validity, subject, subject public key info, and CA signature.
  19. What is the difference between CRL and OCSP?
  20. AnswerCRL (Certificate Revocation List) is a periodically published list of revoked certificate serial numbers. OCSP (Online Certificate Status Protocol) allows real-time queries for the status of a specific certificate.

Exercises

  1. RSA Signature (Small Numbers)

    Using RSA with n=391, e=7, d=151, sign a message with hash h=55 and verify the signature.

  2. Sample Solution

    Sign: σ = 55151 mod 391. Compute using modular exponentiation: 552=3025 mod391=278; 554=2782=77284 mod391=... We can shortcut: Since d is large, it's easier to compute with square-and-multiply. The result is σ = 55151 mod 391. (In practice, we'd use a calculator or code.)

    Verify: h' = σ7 mod 391. Since we used the private key, h' should equal 55, confirming the signature is valid.

  3. Certificate Chain Validation

    Explain the steps a browser takes to validate a server certificate chain. What happens if an intermediate certificate is missing?

  4. Sample Solution

    The browser: 1) Verifies the signature on the server certificate using the issuer's public key; 2) Checks the validity period; 3) Checks revocation status; 4) Builds the chain up to a trusted root CA; 5) Verifies each signature in the chain; 6) Checks the certificate's Key Usage extensions.

    If an intermediate certificate is missing, the browser may fail to build the chain. Some browsers will attempt to download the missing intermediate using the Authority Information Access (AIA) extension in the certificate.

  5. ECDSA Nonce Reuse

    Show that if the same ephemeral key k is used for two ECDSA signatures (r, s₁) and (r, s₂), the private key d can be recovered. Derive the formula.

  6. Sample Solution

    Given s₁ = k⁻¹(h₁ + d·r) mod n and s₂ = k⁻¹(h₂ + d·r) mod n.

    Subtract: s₁ − s₂ = k⁻¹(h₁ − h₂) mod n → k = (h₁ − h₂)/(s₁ − s₂) mod n.

    Then d = (s₁·k − h₁) / r mod n.

  7. PKI Trust Models

    Compare hierarchical trust (web PKI) and the web of trust (PGP). What are the advantages and disadvantages of each?

  8. Sample Solution

    Hierarchical: Centralized, easier for users (trust is anchored in pre-installed root CAs), but single point of failure (a compromised CA can break trust).

    Web of Trust: Decentralized, no single point of failure, but requires users to manually manage trust relationships and is more complex.

  9. OCSP Stapling

    Explain what OCSP stapling is and why it improves performance and privacy in TLS.

  10. Sample Solution

    OCSP stapling allows the server to obtain an OCSP response from the CA and include it in the TLS handshake (as a "staple") to the client. This avoids the client making a separate OCSP query, reducing latency and hiding the client's browsing history from the CA.

Homework

  1. Research: The DigiNotar Incident

    Research the DigiNotar CA compromise (2011). Write a 500-word report covering:

  2. Sample Answer

    Complete answer would describe the CA compromise, issuance of fraudulent certificates for google.com and other domains, the use in man-in-the-middle attacks in Iran, the removal of DigiNotar's root from browsers, and the subsequent improvements in CA security (e.g., Certificate Transparency).

  3. Compare RSA Signatures and ECDSA

    Write a 500-word report comparing RSA signatures and ECDSA. Address:

  4. Sample Answer

    Complete answer would compare key sizes (e.g., 3072-bit RSA vs 256-bit ECC), performance (RSA signing is slower, ECDSA verification is fast), security (both based on hard problems; ECDSA has smaller keys), padding (RSA uses PSS, ECDSA has built-in randomness), and adoption (both are used; ECDSA is preferred in TLS 1.3).

  5. Analyze a Certificate Chain

    Obtain the certificate chain of a website (e.g., using OpenSSL). Describe the chain, including the root, intermediate, and end-entity certificates. Verify the signatures and identify the algorithms used.

  6. Sample Answer

    Complete answer would include the command used (e.g., openssl s_client -connect example.com:443 -showcerts), the output showing the chain, and analysis of the root CA, intermediate CA, and server certificate. It would note the signature algorithms (e.g., RSA-SHA256, ECDSA-SHA256), validity dates, and key sizes.

  7. Design a PKI for an Organization

    Design a PKI for a medium-sized organization with 1000 employees, using internal CA and client certificates. Specify:

  8. Sample Answer

    Complete answer would propose an offline root CA, an online issuing CA, automated certificate enrollment using SCEP or EST, CRL distribution via HTTP, and use of certificates for authentication (TLS client certificates) and signing (S/MIME). Private keys would be stored on smart cards or HSMs.

  9. Mini-Project: Implement RSA Signature with PSS

    Implement RSA signature generation and verification using the PSS padding scheme (or use a library that supports it). Test with a sample message. Report on:

  10. Sample Answer

    Complete answer would include code (e.g., using OpenSSL or a language library), sample key generation, signing a message, verifying the signature, and a discussion of the salt length and MGF. It would note that PSS signatures are randomized, so two signatures of the same message differ.

Summary

This tutorial has provided a comprehensive examination of digital signatures and the Public Key Infrastructure (PKI) that supports them. We began by defining digital signatures and their core properties: authentication, integrity, and non-repudiation. We explored the major signature schemes—RSA signatures (with PSS padding), DSA, ECDSA, and EdDSA—each with its own strengths and security considerations. We emphasized the critical importance of secure nonce generation in DSA/ECDSA and the advantages of deterministic schemes like EdDSA.

We then introduced PKI, the framework that binds public keys to identities through digital certificates. We examined the X.509 certificate format, the roles of Certificate Authorities (CAs) and Registration Authorities (RAs), and the certificate lifecycle—from generation to issuance to renewal. We discussed revocation mechanisms, including CRLs and OCSP, and their role in maintaining trust.

We compared different trust models: hierarchical (web PKI), web of trust (PGP), and direct trust. We surveyed standards and formats (X.509, PKCS, PEM, DER) and explored real-world applications: TLS, S/MIME, code signing, document signing, and blockchain.

The case studies illustrated the real-world impact of PKI vulnerabilities and the importance of robust CA security, timely revocation, and algorithm agility. These lessons underscore the need for continuous vigilance in the PKI ecosystem.

With this knowledge, you are now equipped to understand, implement, and evaluate digital signatures and PKI in cryptographic systems, and to appreciate their role in enabling secure digital communication and transactions.

Connection to the Next Tutorial

In Tutorial 2.16: Cryptographic Protocols and Applications, we will bring together symmetric encryption, MACs, hash functions, and public-key cryptography to examine complete cryptographic protocols such as TLS, SSH, IPsec, and PGP. You will see how digital signatures and PKI are integrated into practical secure communication systems.