Contents Preface xi Prologue 1 1 The Foundations of Encryption 15 What Is a Cipher 17 Shannon’s Encryption Model 20 The Relationship Between the Encryption Key and the Decryption Key 21 Classic Encryption Methods 24 Caesar Cipher 24 Substitution Cipher 25 Polyalphabetic Cipher 26 Transposition Cipher 27 Cipher Security 28 The Substitution Cipher’s Key Space 31 Permutation Combination and Frequency Analysis 32 The Polyalphabetic Cipher’s Key Space 33 The Transposition Cipher’s Key Space 34 When Breaking Classical Encryption is Possible 37 Perfectly Secure Encryption 37 2 Symmetric-Key Algorithms 47 Binary Digits and Logical Operators 48 Symmetric-Key Algorithms 59 Stream Ciphers 65 Block Ciphers 68 CBC Mode 71 DES Ciphers 72 The Basic Configuration of a Feistel Cipher 73 Involution 74 Generating DES Encryption Subkeys 77 The DES Round Function f 78 The Full Structure of DES Encryption and Decryption 79 3-DES Encryption and AES Encryption 80 An Outline of AES 85 Simplified DES Encryption and Decryption 89
Converting Data into Binary 89 Generating a DES Ciphertext 90 Perform the Initial Permutation 91 Separate Data into Higher and Lower-Order Bits 92 Feistel Rounds Variant 92 Swap the Higher and Lower-Order Bits 95 Perform the Final Permutation 95 Decrypting a DES Ciphertext 97 Perform the Initial Permutation 97 Separate Data into Higher and Lower-Order Bits 97 Round 1 97 Round 2 98 Generating DES Keys 100 Perform Permuted Choice PC 1 101 Rotate the Bits 102 Perform Permuted Choice PC 2 102 Rotate the Bits Again 103 Compress the Bits 103 How Reduced DES Differs from Real DES 104 3 Public-Key Encryption 105 The Basics of Public-Key Encryption 106 Mathematical Dependencies of Public-Key Encryption 115 One-Way Functions 116 The Birth of RSA Encryption 119 Prime Numbers and Integer Factorization 120 Types of Primality Tests 129 Modulo Operations 134 Addition and Subtraction in Modulo Operations 137 Multiplication and Division of Modulo Operations 146 Fermat’s Little Theorem and Euler’s Theorem 152 Fermat the Father of Number Theory 153 Fermat’s Method and Pseudoprime Numbers 155 Euler’s Theorem 156 The Mathematician Euler 157 Euler Function on the Product of Two Prime Numbers 158 The Structure of RSA Encryption 161 RSA Encryption Encryption and Decryption 163 Generating an RSA Encryption Key 165 Verifying That the Public Key e and Private Key d Work in RSA Encryption 166 How to Make Public Keys and Private Keys 167 Generating a Ciphertext Using RSA 169 Decrypting a Ciphertext Using RSA 171 Contents
Public-Key Encryption and Discrete Logarithm Problems 173 Discrete Logarithm Problems 174 Encryption and Decryption in ElGamal Encryption 176 The Extended Euclidean Algorithm 181 Calculating the Private Key in RSA Key Generation 182 4 Practical Applications of Encryption 185 Hybrid Encryption 186 Hash Functions and Message Authentication Codes 190 Falsification 190 Tampering Countermeasures 192 Hash Functions 193 Identity Fraud 194 Identity Fraud Countermeasures 195 Structure of Message Authentication Codes 196 Repudiation 197 Drawbacks of Message Authentication Codes 199 Digital Signatures 200 Repudiation Measures 200 The Workings of a Digital Signature 201 Man-in-the-Middle Attack 203 Using Certificates to Protect Against Man-in-the-Middle Attacks 204 Public-Key Infrastructure 206 Zero-Knowledge Interactive Proof 217 Preparatory Stage 217 Implementation Stage Verification Process 218 Methods of Identity Fraud 220 Anti-Identity Fraud in a Zero-Knowledge Interactive Proof 222 What Next 224 Pseudorandom Numbers and Encryption Security 224 PGP 224 SSL TLS 225 Quantum Cryptography 225 Biometrics 225 Index 227 Contents