Bruce Schneier

 
 

Practical Cryptography

Table of Contents

Prefacexvii
How to Read this Bookxix
1 Our Design Philosophy1
1.1 The Evils of Performance2
1.2 The Evils of Features5
2 The Context of Cryptography7
2.1 The Role of Cryptography8
2.2 The Weakest Link Property9
2.3 The Adversarial Setting11
2.4 Practical Paranoia12
2.4.1 Attack13
2.5 Threat Model15
2.6 Cryptography Is Not the Solution17
2.7 Cryptography Is Very Difficult18
2.8 Cryptography Is the Easy Part19
2.9 Background Reading20
3 Introduction to Cryptography21
3.1 Encryption21
3.1.1 Kerckhoffs' Principle23
3.2 Authentication23
3.3 Public-Key Encryption26
3.4 Digital Signatures28
3.5 PKI29
3.6 Attacks30
3.6.1 Ciphertext-Only31
3.6.2 Known Plaintext31
3.6.3 Chosen Plaintext32
3.6.4 Chosen Ciphertext32
3.6.5 Distinguishing Attacks33
3.6.6 Birthday33
3.6.7 Meet in the Middle34
3.6.8 Other Types of Attack36
3.7 Security Level36
3.8 Performance37
3.9 Complexity39
I Message Security41
4 Block Ciphers43
4.1 What Is a Block Cipher?43
4.2 Types of Attack44
4.3 The Ideal Block Cipher46
4.4 Definition of Block Cipher Security46
4.4.1 Parity of a Permutation49
4.5 Real Block Ciphers50
4.5.1 DES51
4.5.2 AES 55
4.5.3 Serpent58
4.5.4 Twofish59
4.5.5 Other AES Finalists61
4.5.6 Equation-Solving Attacks62
4.5.7 Which Block Cipher Should I Choose?63
4.5.8 What Key Size Should I Use?65
5 Block Cipher Modes67
5.1 Padding68
5.2 ECB69
5.3 CBC70
5.3.1 Fixed IV70
5.3.2 Counter IV70
5.3.3 Random IV71
5.3.4 Nonce-Generated IV72
5.4 OFB73
5.5 CTR75
5.6 Newer Modes76
5.7 Which Mode Should I Use?77
5.8 Information Leakage79
5.8.1 Chances of a Collision80
5.8.2 How to Deal With Leakage81
5.8.3 About Our Math82
6 Hash Functions83
6.1 Security of Hash Functions84
6.2 Real Hash Functions86
6.2.1 MD587
6.2.2 SHA-188
6.2.3 SHA-256, SHA-384, and SHA-51289
6.3 Weaknesses of Hash Functions89
6.3.1 Length Extensions90
6.3.2 Partial-Message Collision91
6.4 Fixing the Weaknesses92
6.4.1 A Thorough Fix92
6.4.2 A More Efficient Fix93
6.5 Which Hash Function Should I Choose?95
6.6 Future Work95
7 Message Authentication Codes97
7.1 What a MAC Does97
7.2 The Ideal MAC98
7.3 MAC Security98
7.4 CBC-MAC99
7.5 HMAC101
7.5.1 HMAC versus SHAd103
7.6 UMAC104
7.6.1 Size of MAC104
7.6.2 Which UMAC?105
7.6.3 Platform Flexibility106
7.6.4 Amount of Analysis106
7.6.5 Why Mention UMAC at All?107
7.7 Which MAC to Choose?107
7.8 Using a MAC108
8 The Secure Channel111
8.1 Problem Statement111
8.1.1 Roles111
8.1.2 Key112
8.1.3 Messages or Stream113
8.1.4 Security Properties113
8.2 Order of Authentication and Encryption115
8.3 Outline117
8.3.1 Message Numbers117
8.3.2 Authentication119
8.3.3 Encryption119
8.3.4 Frame Format120
8.4 Details120
8.4.1 Initialization121
8.4.2 Sending a Message122
8.4.3 Receiving a Message123
8.4.4 Message Order125
8.5 Alternatives126
8.6 Conclusion127
9 Implementation Issues (I)129
9.1 Creating Correct Programs131
9.1.1 Specifications131
9.1.2 Test and Fix132
9.1.3 Lax Attitude133
9.1.4 So How Do We Proceed?134
9.2 Creating Secure Software135
9.3 Keeping Secrets136
9.3.1 Wiping State136
9.3.2 Swap File138
9.3.3 Caches140
9.3.4 Data Retention by Memory141
9.3.5 Access by Others143
9.3.6 Data Integrity144
9.3.7 What to Do145
9.4 Quality of Code146
9.4.1 Simplicity146
9.4.2 Modularization147
9.4.3 Assertions148
9.4.4 Buffer Overflows149
9.4.5 Testing149
9.5 Side-Channel Attacks150
9.6 Conclusion152
II Key Negotiation153
10 Generating Randomness155
10.1 Real Random156
10.1.1 Problems With Using Real Random Data158
10.1.2 Pseudorandom Data158
10.1.3 Real Random Data and PRNGs159
10.2 Attack Models for a PRNG160
10.3 Fortuna161
10.4 The Generator162
10.4.1 Initialization164
10.4.2 Reseed165
10.4.3 Generate Blocks165
10.4.4 Generate Random Data166
10.4.5 Generator Speed167
10.5 Accumulator167
10.5.1 Entropy Sources168
10.5.2 Pools169
10.5.3 Implementation Considerations171
Distribution of Events Over Pools171
Running Time of Event Passing172
10.5.4 Initialization174
10.5.5 Getting Random Data174
10.5.6 Add an Event176
10.6 Seed File Management177
10.6.1 Write Seed File178
10.6.2 Update Seed File178
10.6.3 When to Read and Write the Seed File179
10.6.4 Backups179
10.6.5 Atomicity of File System Updates180
10.6.6 First Boot181
10.7 So What Should I Do?182
10.8 Choosing Random Elements182
11 Primes185
11.1 Divisibility and Primes186
11.2 Generating Small Primes188
11.3 Computations Modulo a Prime190
11.3.1 Addition and Subtraction191
11.3.2 Multiplication192
11.3.3 Groups and Finite Fields192
11.3.4 The GCD Algorithm194
11.3.5 The Extended Euclidean Algorithm195
11.3.6 Working Modulo 2197
11.4 Large Primes197
11.4.1 Primality Testing200
11.4.2 Evaluating Powers204
12 Diffie-Hellman207
12.1 Groups208
12.2 Basic DH210
12.3 Man in the Middle211
12.4 Pitfalls212
12.5 Safe Primes214
12.6 Using a Smaller Subgroup215
12.7 The Size of p216
12.8 Practical Rules218
12.9 What Could Go Wrong220
13 RSA223
13.1 Introduction223
13.2 The Chinese Remainder Theorem224
13.2.1 Garner's Formula225
13.2.2 Generalizations226
13.2.3 Uses227
13.2.4 Conclusion228
13.3 Multiplication Modulo n228
13.4 RSA Defined229
13.4.1 Digital Signatures with RSA230
13.4.2 Public Exponents230
13.4.3 The Private Key232
13.4.4 The Size of n233
13.4.5 Generating RSA Keys233
13.5 Pitfalls Using RSA236
13.6 Encryption237
13.7 Signatures240
14 Introduction to Cryptographic Protocols245
14.1 Roles245
14.2 Trust246
14.2.1 Risk248
14.3 Incentive248
14.4 Trust in Cryptographic Protocols251
14.5 Messages and Steps251
14.5.1 The Transport Layer252
14.5.2 Protocol and Message Identity253
14.5.3 Message Encoding and Parsing254
14.5.4 Protocol Execution States255
14.5.5 Errors255
14.5.6 Replay and Retries257
15 Key Negotiation Protocol261
15.1 The Setting261
15.2 A First Try262
15.3 Protocols Live Forever264
15.4 An Authentication Convention265
15.5 A Second Attempt265
15.6 A Third Attempt267
15.7 Our Final Protocol268
15.8 Different Views of the Protocol271
15.8.1 Alice's View271
15.8.2 Bob's View272
15.8.3 Attacker's View272
15.8.4 Key Compromise273
15.9 Computational Complexity of the Protocol274
15.9.1 Optimization Tricks275
15.10 Protocol Complexity276
15.11 A Gentle Warning277
15.12 Key Negotiation from a Password277
16 Implementation Issues (II)279
16.1 Large Integer Arithmetic279
16.1.1 Wooping281
16.1.2 Checking DH Computations284
16.1.3 Checking RSA Encryption285
16.1.4 Checking RSA Signatures286
16.1.5 Conclusion286
16.2 Faster Multiplication286
16.3 Side-Channel Attacks288
16.3.1 Countermeasures289
16.4 Protocols290
16.4.1 Protocols Over a Secure Channel291
16.4.2 Receiving a Message291
16.4.3 Timeouts293
III Key Management295
17 The Clock297
17.1 Uses for a Clock297
17.1.1 Expiration297
17.1.2 Unique Value298
17.1.3 Monotonicity298
17.1.4 Real-Time Transactions299
17.2 Using the Real-Time Clock Chip299
17.3 Security Dangers300
17.3.1 Setting the Clock Back300
17.3.2 Stopping the Clock301
17.3.3 Setting the Clock Forward302
17.4 Creating a Reliable Clock302
17.5 The Same-State Problem304
17.6 Time306
17.7 Conclusion307
18 Key Servers309
18.1 Basics310
18.2 Kerberos310
18.3 Simpler Solutions311
18.3.1 Secure Connection312
18.3.2 Setting Up a Key312
18.3.3 Rekeying313
18.3.4 Other Properties313
18.4 What to Choose314
19 The Dream of PKI315
19.1 A Very Short PKI Overview315
19.2 PKI Examples316
19.2.1 The Universal PKI316
19.2.2 VPN Access317
19.2.3 Electronic Banking317
19.2.4 Refinery Sensors317
19.2.5 Credit Card Organization317
19.3 Additional Details318
19.3.1 Multilevel Certificates318
19.3.2 Expiration319
19.3.3 Separate Registration Authority320
19.4 Conclusion321
20 PKI Reality323
20.1 Names323
20.2 Authority326
20.3 Trust326
20.4 Indirect Authorization327
20.5 Direct Authorization328
20.6 Credential Systems330
20.7 The Modified Dream332
20.8 Revocation333
20.8.1 Revocation List333
20.8.2 Fast Expiration335
20.8.3 Revocation Is Required335
20.9 So What Is a PKI Good For?336
20.10 What to Choose337
21 PKI Practicalities339
21.1 Certificate Format339
21.1.1 Permission Language340
21.1.2 The Root Key340
21.2 The Life of a Key341
21.3 Why Keys Wear Out343
21.4 So What Should You Do?345
22 Storing Secrets347
22.1 Disk347
22.2 Human Memory348
22.2.1 Salting and Stretching350
22.3 Portable Storage353
22.4 Secure Token353
22.5 Secure UI355
22.6 Biometrics356
22.7 Single Sign-On357
22.8 Risk of Loss358
22.9 Secret Sharing358
22.10 Wiping Secrets360
22.10.1 Paper360
22.10.2 Magnetic Storage360
22.10.3 Solid-State Storage362
IV Miscellaneous363
23 Standards365
23.1 The Standards Process365
23.1.1 The Standard367
23.1.2 Functionality367
23.1.3 Security368
23.2 SSL369
23.3 AES: Standardization by Competition370
24 Patents373
24.1 Prior Art373
24.2 Continuations374
24.3 Vagueness375
24.4 Reading Patents375
24.5 Licensing376
24.6 Defensive Patents377
24.7 Fixing the Patent System378
24.8 Disclaimer379
25 Involving Experts381
Acknowledgments385
Bibliography387
Index397

up to Practical Cryptography

Schneier.com is a personal website. Opinions expressed are not necessarily those of BT Counterpane.