Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

PGP, S/MIME and SET

Notes comparing PGP, S/MIME and SET: how each provides confidentiality, integrity and authentication for email and electronic payments, their trust models, message formats and typical algorithms.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Engineers implement or evaluate secure email and electronic-payment systems. PGP, S/MIME and SET are real-world protocols that show different design choices: PGP for decentralised email protection, S/MIME for certificate-based enterprise email, and SET for secure card payments. Knowing their message flows and trust models helps you design, debug and answer exam questions on email and payment security.

Key ideas

  • Authentication: the sender (or payer) is provably who they claim to be (achieved by digital signatures and certificates).

Definitions and exact protocol concepts:

  • PGP (Pretty Good Privacy): a hybrid cryptosystem for securing email and files that combines symmetric encryption for bulk data, public-key encryption for encrypting the symmetric session key, optional compression, and digital signatures for authentication. PGP uses a web-of-trust: users sign each other's public keys; trust is established by chains of signatures rather than a central CA.

    Assumptions: recipient has a usable public key; sender can or chooses to verify key bindings via signatures; cryptographic primitives are secure.

    Typical PGP message flow (recommended ordering):

    1. Compute a hash of the plaintext; generate a digital signature using the sender's private key on that hash, and attach the signature to the plaintext (signed message).
    2. Compress the signed message (optional) to reduce size and remove predictable patterns.
    3. Generate a random symmetric session key K; encrypt the compressed, signed message with a symmetric cipher under K.
    4. Encrypt K with recipient's public key(s) and attach the encrypted session key(s) to the message.
    5. Optionally ASCII-armour for transport.

    Draw for exams: two boxes labelled "Sender" and "Recipient". From Sender: Plaintext -> [Hash & Sign using SK_Sender] -> [Compress] -> [Encrypt with Symmetric K] -> [Encrypt K with PK_Recipient] -> Transmit. At Recipient: decrypt K -> decrypt data -> decompress -> verify signature.

  • S/MIME (Secure/Multipurpose Internet Mail Extensions): an Internet-standard for securing MIME data. It uses X.509 certificates and a hierarchical Certificate Authority (CA) trust model. S/MIME messages follow the Cryptographic Message Syntax (CMS) (signed-data, enveloped-data, etc.). Recommended practice is sign-then-encrypt so recipients can verify the origin after decryption.

    Assumptions: parties possess X.509 certificates that bind identities to public keys and a CA chain that the recipient trusts, and they perform certificate path validation and revocation checking (CRLs/OCSP).

    S/MIME message types to know: signed-data (a MIME entity containing content plus signature), enveloped-data (content encrypted with a symmetric key; symmetric key encrypted for recipients), signed-and-enveloped (sign-then-encrypt composition by nesting). In exams draw the MIME content-type nesting: outer application/pkcs7-mime; smime-type=enveloped-data containing inner application/pkcs7-mime; smime-type=signed-data (sign-then-encrypt). Alternatively, a detached signature uses multipart/signed with an application/pkcs7-signature part.

  • SET (Secure Electronic Transaction): a protocol designed for secure credit-card payments over open networks. Actors: Cardholder (customer), Merchant, and Payment Gateway/Issuer (bank). Key idea: merchant must get order information (OI) but not see payment account data (PI), while bank must see PI but not unnecessary OI. SET achieves this with dual signatures and use of certificates for authentication.

    Dual-signature concept (exact construction used in SET): compute separate hashes for the order information (MD = Hash(OI)) and payment information (PD = Hash(PI)). Compute a combined hash H = Hash(MD || PD) where || denotes concatenation. The cardholder creates a digital signature DS = Sign_SK_Cardholder(H). Then the cardholder sends OI, MD and DS to the merchant (merchant cannot read PI); sends {PI encrypted under the PG’s public key}, PD and DS to the payment gateway (typically via the merchant). The DS proves linkage between OI and PI without revealing PI to the merchant.

    Draw: three boxes (Cardholder, Merchant, Payment Gateway). From Cardholder two arrows: to Merchant send {OI, MD, DS}; to PG send {Encrypted PI for PG, PD, DS}.

  • Algorithms and choices (conceptual): PGP and S/MIME are hybrid: symmetric cipher (e.g., AES) for data; asymmetric for key transport and signatures. PGP historically used RSA and ElGamal/Diffie–Hellman for encryption and DSA/RSA for signatures; S/MIME (CMS) commonly uses RSA (and modern ECDH/ECDSA), not ElGamal. Hash functions (SHA-1 legacy, SHA-256 modern) compute message digests. SET specified RSA and X.509 certificates and employed cardholder and merchant certificates with certificate authorities.

Formulas

C = E_sym(K, M) — ciphertext C is symmetric encryption of message M under key K. Symbols: E_sym = symmetric encryption function (e.g., AES-CBC), K = symmetric key (bits), M = message (bytes). Applies to bulk data.

K_enc = E_pub(PK_R, K) — encrypted session key using recipient public key. PK_R = recipient public key (RSA/ElGamal). Units: dimensionless (bitstrings).

h = H(M) — cryptographic hash of message M; H = hash function (SHA-256), output in bits.

s = Sign(SK_S, h) — digital signature s computed with sender's private key SK_S on hash h. For RSA signatures: s = h^d mod n where SK_S = (d, n); verify by h = s^e mod n where e is public exponent. Units: integers modulo n.

DS = Sign(SK_CH, Hash(MD || PD)) — SET dual signature DS where MD = Hash(OI), PD = Hash(PI); || = concatenation.

Worked examples

  1. RSA signature toy example (university-exam style, small values):
  • Given p=3, q=11 -> n = p·q = 33. φ(n) = (p−1)(q−1) = 2·10 = 20.
  • Choose e = 3 (gcd(3,20)=1). Compute d such that e·d ≡ 1 (mod 20). d = 7 because 3·7 = 21 ≡ 1 (mod 20).
  • Message m = 4 (assume hash of message = 4 and m < n).

Sign: s = m^d mod n = 4^7 mod 33.

  • 4^2 = 16; 4^4 = 16^2 = 256 ≡ 25 (mod 33).
  • 4^7 = 4^(4+2+1) = 25·16·4 = 1600 ≡ 16 (mod 33). So s = 16 (signature).

Verify: compute s^e mod n = 16^3 mod 33.

  • 16^2 = 256 ≡ 25; 16^3 = 25·16 = 400 ≡ 4 (mod 33) which equals m. Verified. Bold final: signature = 16.
  1. PGP hybrid example (toy numeric example):
  • Use same RSA public key as above for recipient (n=33, e=3). Sender chooses symmetric key K = 5 (small integer for toy symmetric cipher). Message M = 7.

Encrypt session key: K_enc = K^e mod n = 5^3 mod 33 = 125 mod 33 = 26. Encrypt message with symmetric key (toy symmetric: XOR): C = M xor K = 7 xor 5 = 2.

Sender sends {C = 2, K_enc = 26, signature on hash}. Recipient: recover K = K_enc^d mod n = 26^7 mod 33.

  • Compute 26^2 = 676 ≡ 16; 26^4 = 16^2 = 256 ≡ 25; 26^7 = 26^(4+2+1) = 25·16·26 = 25·416 = 10400 ≡ 5 (mod 33). So K=5. Decryption: M = C xor K = 2 xor 5 = 7. Recovered message = 7.

Note: real PGP uses secure symmetric ciphers (AES, etc.) and standard cryptographic padding; this is a toy XOR illustration.

  1. SET dual-signature toy example (exam style):
  • Let OI = "order 100" -> MD = Hash(OI) = 12 (toy hash). PI = "card 1234" -> PD = Hash(PI) = 20 (toy hash).
  • Compute H = Hash(MD || PD). For toy example let concatenation numeric H_input = 12||20 produce H = 1220 and Hash(H_input) = 99 (toy hash result).
  • Cardholder signs H with private key (use RSA example above where signing exponent d=7): s = 99^7 mod 33 = compute 99 mod33 = 0 so s=0. (This demonstrates in a real system hashes must be reduced properly; in exams you would choose numbers < n to avoid degenerate modulo.)

Result: Cardholder sends to Merchant {OI, MD, DS}; sends to Payment Gateway {Encrypted PI, PD, DS}. The DS links OI and PI without revealing PI to Merchant.

Common mistakes

  • Forgetting to encrypt the session key as well as the data in hybrid systems.
  • In SET: describing a single signature on PI only (the exam point is that SET uses a dual-signature that links OI and PI while keeping PI secret from merchant).
  • Using real hash outputs in toy arithmetic examples without ensuring they fit the modulus when doing small-RSA math (causes zero or trivial residues).

For your exam

Question types:

  • Definitions: define PGP, S/MIME, SET, dual signature, web-of-trust, X.509.
  • Short notes: message flow for PGP or S/MIME; compare trust models.
  • Derivations: show sign-then-encrypt vs encrypt-then-sign implications; show dual-signature construction and explain why it preserves confidentiality + linkage.
  • Numericals: small-RSA signature/encryption examples (use small primes), hybrid encryption arithmetic.
  • Diagrams: draw the sender/recipient flow for PGP and three-party flow for SET.

What full-marks answers include:

  • Clear definitions (bold terms), correct actor lists, correct step-by-step flows, correct reason why a design choice (e.g., sign-then-encrypt) is used, correct security property mapping (which step gives confidentiality/integrity/authentication), and a correct small numeric worked example if asked.

Quick check

  1. What trust model does PGP use? 2) In S/MIME which certificate type binds an identity to a public key? 3) What is the purpose of the dual signature in SET?

Answers: PGP uses the web-of-trust; S/MIME uses X.509 certificates (CA hierarchical model); dual signature links order info and payment info so merchant and payment gateway get what they must without revealing PI to the merchant.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?