
Real-World Cryptography
Description
Book Introduction
The world's most practical cryptography guidebook
Cryptography is an essential foundation of IT security.
To stay ahead of system attackers, you need to understand the tools, frameworks, and protocols that secure your networks and applications.
This book teaches practical skills for developers, system administrators, and security practitioners.
Instead of complex mathematics or technical terms, modern cryptography techniques are explained using various illustrations and real-world examples.
You can learn everything from fundamentals to cutting-edge technologies, including hash functions, signatures, HTTPS, secure messaging, quantum-resistant cryptography, and cryptocurrencies. Written by a cryptography engineer actively contributing to Internet standards, including TLS, this book is accessible even to practitioners new to the field.
Cryptography is an essential foundation of IT security.
To stay ahead of system attackers, you need to understand the tools, frameworks, and protocols that secure your networks and applications.
This book teaches practical skills for developers, system administrators, and security practitioners.
Instead of complex mathematics or technical terms, modern cryptography techniques are explained using various illustrations and real-world examples.
You can learn everything from fundamentals to cutting-edge technologies, including hash functions, signatures, HTTPS, secure messaging, quantum-resistant cryptography, and cryptocurrencies. Written by a cryptography engineer actively contributing to Internet standards, including TLS, this book is accessible even to practitioners new to the field.
- You can preview some of the book's contents.
Preview
index
Translator's Preface xii
Recommendation xiii
Beta Reader Review xv
Beginning with xvii
Acknowledgments xxii
About this book xxiii
About the cover xxvii
PART I Primitives: The Stuff of Cryptography
CHAPTER 1 Getting Started 3
1.1 Cryptography Protects Protocols 4
1.2 Symmetric Cryptography: What is Symmetric Encryption? 5
1.3 Kerkhoff's Principle: Keep Your Height a Secret 7
1.4 Asymmetric Cryptography: Two Keys Are Better Than One 10
__1.4.1 How to share secrets, key exchange 10
__1.4.2 Asymmetric encryption is different from symmetric encryption! 13
__1.4.3 Digital Signatures: Not So Different from Pen and Paper Signatures 15
1.5 Classification of Cryptography 17
1.6 Theoretical Cryptography vs. Real-World Cryptography 19
1.7 From Theory to Reality: Simulations for Making Cryptography a Reality 20
1.8 Warning 25
Summary 26
CHAPTER 2 Hash Functions 27
2.1 What is a hash function? 27
2.2 Security Properties of Hash Functions 30
2.3 Security Constraints of Hash Functions 32
2.4 Practical Uses of Hash Functions 34
__2.4.1 commit 34
__2.4.2 Subresource Integrity 35
__2.4.3 BitTorrent 35
__2.4.4 Thor 35
2.5 Standardized Hash Functions 36
__2.5.1 SHA-2 Hash Function 37
__2.5.2 SHA-3 Hash Function 41
__2.5.3 Two XOFs, SHAKE and cSHAKE 44
__2.5.4 Tuple Hash, Resolving Ambiguity 46
2.6 Password Hash 48
Summary 50
CHAPTER 3 Message Authentication Code 51
3.1 A representative example of MAC, stateless cookies 51
3.2 Code Example 54
3.3 Security Properties of MAC 56
__3.3.1 Forgery of Authentication Tags 56
__3.3.2 Authentication tag length 57
__3.3.3 Replay Attack 58
__3.3.4 Periodic Authentication Tag Verification 59
3.4 MAC 61 in the Real World
__3.4.1 Message Authentication 61
__3.4.2 Key Derivation 61
__3.4.3 Cookie Integrity 61
__3.4.4 Hash Table 62
3.5 MAC 62 in Practice
__3.5.1 Hash-based MAC, HMAC 62
__3.5.2 cSHAKE-based MAC, KMAC 63
3.6 SHA-2 and Variable-Length Attacks 64
Summary 67
CHAPTER 4: Authentication and Encryption 69
4.1 What is a ciphertext? 70
4.2 AES Block Encryption 71
__4.2.1 Level of Security Provided by AES 72
__4.2.2 AES Interface 73
__4.2.3 Inside AES 74
4.3 Encrypted Penguin and CBC Mode 75
4.4 What if authentication is required? AES-CBC-HMAC 78
4.5 All-in-one architecture: Authentication and encryption 80
__4.5.1 AEAD 80
__4.5.2 AES-GCM AEAD 82
__4.5.3 ChaCha20-Poly1305 86
4.6 Other Symmetric Encryption 90
__4.6.1 Key Wrapping 91
__4.6.2 Nonce Misuse Prevention Authentication Encryption 91
__4.6.3 Disk Encryption 91
__4.6.4 Database Encryption 92
Summary 92
CHAPTER 5 KEY EXCHANGE 95
5.1 What is Key Exchange? 96
5.2 DH Key Exchange 99
__5.2.1 Group Theory 99
__5.2.2 Diffie-Hellman Foundation, Discrete Logarithm Problem 103
__5.2.3 Diffie-Hellman Standard 105
5.3 ECDH Key Exchange 106
__5.3.1 What is an Elliptic Curve? 107
__5.3.2 How ECDH Key Exchange Works 110
__5.3.3 Elliptic Curve Diffie-Hellman Standard 112
5.4 Small Subgroup Attacks and Other Security Considerations 114
Summary 117
CHAPTER 6 Asymmetric and Hybrid Encryption 119
6.1 What is Asymmetric Encryption? 120
6.2 Practical Asymmetric and Hybrid Encryption 122
__6.2.1 Key Exchange and Key Encapsulation 122
__6.2.2 Hybrid Encryption 123
6.3 RSA Asymmetric Cryptography: The Worst and the Less Worst 127
__6.3.1 Textbook RSA 127
__6.3.2 Why not use RSA PKCS#1 v1.5? 131
__6.3.3 RSA-OAEP Asymmetric Encryption 133
6.4 ECIES Hybrid Encryption 136
Summary 138
CHAPTER 7 Signatures and Zero-Knowledge Proofs 139
7.1 What is a Signature? 140
__7.1.1 How to Sign and Verify Signatures in Practice 141
__7.1.2 Primary Use of Signatures: Authenticated Key Exchange 142
__7.1.3 Real-World Use Case: Public Key Infrastructure 143
7.2 ZKP: The Origin of Signatures 144
__7.2.1 Schnorr Identification Protocol: Interactive ZKP 145
__7.2.2 Signatures as Non-Interactive ZKPs 148
7.3 Recommended Signature Algorithm 149
__7.3.1 Insecure Standard, RSA PKCS#1 v1.5 150
__7.3.2 Improved Standard, RSA-PSS 153
__7.3.3 ECDSA 154
__7.3.4 EdDSA 157
7.4 Subtle Properties of Signature Systems 160
__7.4.1 Alternative Attack 160
__7.4.2 Malleability of Signatures 162
Summary 162
CHAPTER 8 Randomness and Secrecy 165
8.1 What is randomness? 166
8.2 Slow Randomness? Use a PRNG 167
8.3 Ensuring Randomness in Practice 171
8.4 Random Number Generation and Security Considerations 173
8.5 Public Randomness 175
8.6 Key Derivation and HKDF 177
8.7 Key Management and Secret Management 181
8.8 Decentralizing Trust through Threshold Cryptography 183
Summary 186
PART II Protocols: A Recipe for Cryptography
CHAPTER 9 SECURE TRANSMISSION 189
9.1 Secure Transport Protocols, SSL and TLS 190
__9.1.1 SSL to TLS 190
__9.1.2 Using TLS in Practice 191
9.2 How the TLS Protocol Works 193
__9.2.1 TLS Handshake 194
__9.2.2 How TLS 1.3 Encrypts Application Data 207
9.3 The Current State of the Encrypted Web 208
9.4 Other Transport Protocols 211
9.5 A Modern Alternative to TLS, the Noise Protocol Framework 211
__9.5.1 Various Handshakes of Noise 212
__9.5.2 Noise Handshake 213
Summary 214
CHAPTER 10 END-TO-END ENCRYPTION 215
10.1 Why is end-to-end encryption necessary? 216
10.2 The Source of Trust You Can't Find Anywhere 217
10.3 Email Encryption Failure 219
__10.3.1. PGP? GPG? How Does It Work? 219
__10.3.2 Web of Trust: Extending Trust Between Users 222
__10.3.3 The real issue is finding the key 223
__10.3.4 If not PGP, what are the alternatives? 224
10.4 Secure Messaging: Modern End-to-End Encryption with Signal 226
__10.4.1 Trust, but verify. More user-friendly than WOT 227
__10.4.2 Signal Protocol Handshake, X3DH 230
__10.4.3 Post-handshake protocol for signals, double ratchet 233
10.5 Current End-to-End Encryption 238
Summary 240
CHAPTER 11 USER AUTHENTICATION 243
11.1 Reviewing Certification 243
11.2 User Authentication, the Journey to Eliminating Passwords 245
__11.2.1 The Master of Passwords, SSO and Password Manager 248
__11.2.2 Want to prevent password exposure? Use asymmetric password authentication key exchange. 249
__11.2.3 O TP is not an actual password.
Switching without a password using symmetric keys 253
__11.2.4 Replacing Passwords with Asymmetric Keys 257
11.3 User-assisted authentication: Pairing devices with human assistance 260
__11.3.1 Preshared Key 261
__11.3.2 Symmetric Password Authentication Key Exchange Using CPace 263
__11.3.3 Has My Key Exchange Been MITM-Attackered? Check SAS 264
Summary 267
CHAPTER 12: The "Cryptocurrency" in "Cryptocurrency"? 269
12.1 A Brief Introduction to BFT Consensus Algorithms 270
__12.1.1 The Problem of Resilience: Distributed Protocols for Structure 270
__12.1.2 Decentralization Solving the Problem of Trust 272
__12.1.3 The Problem of Scale: Permissionless and Censorship-Resistant Networks 273
12.2 How Bitcoin Works 275
__12.2.1 How Bitcoin Manages User Balances and Transactions 276
__12.2.2 The Digital Gold Mine: Mining BTC 278
__12.2.3 Fork Hell! Mining Dispute Resolution 281
__12.2.4 Reducing Block Size Using Merkle Trees 284
12.3 Cryptocurrency Overview 286
__12.3.1 Volatility 286
__12.3.2 Delay time 286
__12.3.3 Blockchain Size 287
__12.3.4 Confidentiality 287
__12.3.5 Energy Efficiency 288
12.4 DMBFT: BFT Consensus Protocol 288
__12.4.1 Two Properties of BFT Consensus Protocols: Safety and Liveness 288
__12.4.2 Round 289 of the DMBFT Protocol
__12.4.3 How much dishonesty can a protocol tolerate? 290
__12.4.4 DMBFT Voting Rules 291
__12.4.5 When is a transaction confirmed? 292
__12.4.6 The Hidden Intuition Behind DMBFM's Safety 293
Summary 295
CHAPTER 13 Hardware Cryptography 297
13.1 Attacker Models in Modern Cryptography 297
13.2 Hardware: The Savior of Untrusted Environments 299
__13.2.1 White-Box Cryptography 300
__13.2.2 Smart Cards and Security Elements 300
__13.2.3 HSM 303, Loved by Banks
__13.2.4.
Great standardization of security elements, TPM 305
__13.2.5 Secure Computing with TEE 308
13.3 Which solution should I choose? 309
13.4 Leak-Resistant Cryptography and Side-Channel Attack Defenses 311
__13.4.1 Constant-Time Programming 313
__13.4.2 Masking and Blinding 315
__13.4.3 How to Deal with Flaw Attacks 316
Summary 316
CHAPTER 14 Cryptography in the Quantum Computer Age 319
14.1 What is a Quantum Computer? 320
__14.1.1 Exploring the Small, Quantum Mechanics 320
__14.1.2 From the Birth of Quantum Computers to Quantum Supremacy 323
__14.1.3 Grover and Shor's Algorithm 324
__14.1.4 Post-Quantum Cryptography Against Quantum Computers 326
14.2 All you need is a hash function! Hash-based signatures 326
__14.2.1 OTS 327 via Lamport Signature
__14.2.2 WOTS and Small Key 329
__14.2.3 Multi-signature via XMSS and SPHINCS+ 330
14.3 Shorter Keys and Signatures Using Lattice-Based Cryptography 333
__14.3.1 What is a Lattice? 333
__14.3.2 Learning from Errors 335
__14.3.3 Lattice-Based Key Exchange, Kyber 337
__14.3.4 Lattice-Based Signature Scheme, Dilithium 339
14.4 Are Quantum Computers a Horror? 340
Summary 342
CHAPTER 15: Next-Generation Cryptography 345
15.1 MPC 346, the more you play together, the better
__15.1.1 PSI 347
__15.1.2 General Purpose MPC 348
__15.1.3 MPC's current 350
15.2 FHE and the Future of the Encrypted Cloud 350
__15.2.1 Example of RSA Encryption and Homomorphic Encryption 351
__15.2.2 Various Homomorphic Encryption 351
__15.2.3 The Key to FHE, Bootstrapping 352
__15.2.4 Error-Based Learning-Based FHE System 354
__15.2.5 Where to use it? 356
15.3 General Purpose ZKP 357
__15.3.1 How zk-SNARKs Work 359
__15.3.2 Isomorphic commit 360 that hides part of the evidence
__15.3.3 Bilinear Pairing to Improve Isomorphic Commit 361
__15.3.4 Where is the brevity? 361
__15.3.5 Program to Polynomial 362
__15.3.6 The program is for computers.
What we need is an arithmetic circuit 363
__15.3.7 R1CS Arithmetic Circuit 364
__15.3.8 From R1CS to Polynomials 364
__15.3.9 Computing the Hidden Polynomial in the Exponent 365
Summary 367
CHAPTER 16 The End of Cryptography 369
16.1 The tedious task of finding suitable cryptographic primitives or protocols 370
16.2 How to Use Cryptographic Primitives and Protocols? Standards and Format Verification 371
16.3 Where are the good libraries? 374
16.4 Developers Are the Enemy? Cryptography Misuse 376
16.5 Easy-to-Use Security 377
16.6 Cryptography is Not an Island 378
16.7 Cryptography Practitioners' Responsibilities: Don't Test Your Own Cryptography 379
Summary 381
Practice Problem Answer 383
Search 388
Recommendation xiii
Beta Reader Review xv
Beginning with xvii
Acknowledgments xxii
About this book xxiii
About the cover xxvii
PART I Primitives: The Stuff of Cryptography
CHAPTER 1 Getting Started 3
1.1 Cryptography Protects Protocols 4
1.2 Symmetric Cryptography: What is Symmetric Encryption? 5
1.3 Kerkhoff's Principle: Keep Your Height a Secret 7
1.4 Asymmetric Cryptography: Two Keys Are Better Than One 10
__1.4.1 How to share secrets, key exchange 10
__1.4.2 Asymmetric encryption is different from symmetric encryption! 13
__1.4.3 Digital Signatures: Not So Different from Pen and Paper Signatures 15
1.5 Classification of Cryptography 17
1.6 Theoretical Cryptography vs. Real-World Cryptography 19
1.7 From Theory to Reality: Simulations for Making Cryptography a Reality 20
1.8 Warning 25
Summary 26
CHAPTER 2 Hash Functions 27
2.1 What is a hash function? 27
2.2 Security Properties of Hash Functions 30
2.3 Security Constraints of Hash Functions 32
2.4 Practical Uses of Hash Functions 34
__2.4.1 commit 34
__2.4.2 Subresource Integrity 35
__2.4.3 BitTorrent 35
__2.4.4 Thor 35
2.5 Standardized Hash Functions 36
__2.5.1 SHA-2 Hash Function 37
__2.5.2 SHA-3 Hash Function 41
__2.5.3 Two XOFs, SHAKE and cSHAKE 44
__2.5.4 Tuple Hash, Resolving Ambiguity 46
2.6 Password Hash 48
Summary 50
CHAPTER 3 Message Authentication Code 51
3.1 A representative example of MAC, stateless cookies 51
3.2 Code Example 54
3.3 Security Properties of MAC 56
__3.3.1 Forgery of Authentication Tags 56
__3.3.2 Authentication tag length 57
__3.3.3 Replay Attack 58
__3.3.4 Periodic Authentication Tag Verification 59
3.4 MAC 61 in the Real World
__3.4.1 Message Authentication 61
__3.4.2 Key Derivation 61
__3.4.3 Cookie Integrity 61
__3.4.4 Hash Table 62
3.5 MAC 62 in Practice
__3.5.1 Hash-based MAC, HMAC 62
__3.5.2 cSHAKE-based MAC, KMAC 63
3.6 SHA-2 and Variable-Length Attacks 64
Summary 67
CHAPTER 4: Authentication and Encryption 69
4.1 What is a ciphertext? 70
4.2 AES Block Encryption 71
__4.2.1 Level of Security Provided by AES 72
__4.2.2 AES Interface 73
__4.2.3 Inside AES 74
4.3 Encrypted Penguin and CBC Mode 75
4.4 What if authentication is required? AES-CBC-HMAC 78
4.5 All-in-one architecture: Authentication and encryption 80
__4.5.1 AEAD 80
__4.5.2 AES-GCM AEAD 82
__4.5.3 ChaCha20-Poly1305 86
4.6 Other Symmetric Encryption 90
__4.6.1 Key Wrapping 91
__4.6.2 Nonce Misuse Prevention Authentication Encryption 91
__4.6.3 Disk Encryption 91
__4.6.4 Database Encryption 92
Summary 92
CHAPTER 5 KEY EXCHANGE 95
5.1 What is Key Exchange? 96
5.2 DH Key Exchange 99
__5.2.1 Group Theory 99
__5.2.2 Diffie-Hellman Foundation, Discrete Logarithm Problem 103
__5.2.3 Diffie-Hellman Standard 105
5.3 ECDH Key Exchange 106
__5.3.1 What is an Elliptic Curve? 107
__5.3.2 How ECDH Key Exchange Works 110
__5.3.3 Elliptic Curve Diffie-Hellman Standard 112
5.4 Small Subgroup Attacks and Other Security Considerations 114
Summary 117
CHAPTER 6 Asymmetric and Hybrid Encryption 119
6.1 What is Asymmetric Encryption? 120
6.2 Practical Asymmetric and Hybrid Encryption 122
__6.2.1 Key Exchange and Key Encapsulation 122
__6.2.2 Hybrid Encryption 123
6.3 RSA Asymmetric Cryptography: The Worst and the Less Worst 127
__6.3.1 Textbook RSA 127
__6.3.2 Why not use RSA PKCS#1 v1.5? 131
__6.3.3 RSA-OAEP Asymmetric Encryption 133
6.4 ECIES Hybrid Encryption 136
Summary 138
CHAPTER 7 Signatures and Zero-Knowledge Proofs 139
7.1 What is a Signature? 140
__7.1.1 How to Sign and Verify Signatures in Practice 141
__7.1.2 Primary Use of Signatures: Authenticated Key Exchange 142
__7.1.3 Real-World Use Case: Public Key Infrastructure 143
7.2 ZKP: The Origin of Signatures 144
__7.2.1 Schnorr Identification Protocol: Interactive ZKP 145
__7.2.2 Signatures as Non-Interactive ZKPs 148
7.3 Recommended Signature Algorithm 149
__7.3.1 Insecure Standard, RSA PKCS#1 v1.5 150
__7.3.2 Improved Standard, RSA-PSS 153
__7.3.3 ECDSA 154
__7.3.4 EdDSA 157
7.4 Subtle Properties of Signature Systems 160
__7.4.1 Alternative Attack 160
__7.4.2 Malleability of Signatures 162
Summary 162
CHAPTER 8 Randomness and Secrecy 165
8.1 What is randomness? 166
8.2 Slow Randomness? Use a PRNG 167
8.3 Ensuring Randomness in Practice 171
8.4 Random Number Generation and Security Considerations 173
8.5 Public Randomness 175
8.6 Key Derivation and HKDF 177
8.7 Key Management and Secret Management 181
8.8 Decentralizing Trust through Threshold Cryptography 183
Summary 186
PART II Protocols: A Recipe for Cryptography
CHAPTER 9 SECURE TRANSMISSION 189
9.1 Secure Transport Protocols, SSL and TLS 190
__9.1.1 SSL to TLS 190
__9.1.2 Using TLS in Practice 191
9.2 How the TLS Protocol Works 193
__9.2.1 TLS Handshake 194
__9.2.2 How TLS 1.3 Encrypts Application Data 207
9.3 The Current State of the Encrypted Web 208
9.4 Other Transport Protocols 211
9.5 A Modern Alternative to TLS, the Noise Protocol Framework 211
__9.5.1 Various Handshakes of Noise 212
__9.5.2 Noise Handshake 213
Summary 214
CHAPTER 10 END-TO-END ENCRYPTION 215
10.1 Why is end-to-end encryption necessary? 216
10.2 The Source of Trust You Can't Find Anywhere 217
10.3 Email Encryption Failure 219
__10.3.1. PGP? GPG? How Does It Work? 219
__10.3.2 Web of Trust: Extending Trust Between Users 222
__10.3.3 The real issue is finding the key 223
__10.3.4 If not PGP, what are the alternatives? 224
10.4 Secure Messaging: Modern End-to-End Encryption with Signal 226
__10.4.1 Trust, but verify. More user-friendly than WOT 227
__10.4.2 Signal Protocol Handshake, X3DH 230
__10.4.3 Post-handshake protocol for signals, double ratchet 233
10.5 Current End-to-End Encryption 238
Summary 240
CHAPTER 11 USER AUTHENTICATION 243
11.1 Reviewing Certification 243
11.2 User Authentication, the Journey to Eliminating Passwords 245
__11.2.1 The Master of Passwords, SSO and Password Manager 248
__11.2.2 Want to prevent password exposure? Use asymmetric password authentication key exchange. 249
__11.2.3 O TP is not an actual password.
Switching without a password using symmetric keys 253
__11.2.4 Replacing Passwords with Asymmetric Keys 257
11.3 User-assisted authentication: Pairing devices with human assistance 260
__11.3.1 Preshared Key 261
__11.3.2 Symmetric Password Authentication Key Exchange Using CPace 263
__11.3.3 Has My Key Exchange Been MITM-Attackered? Check SAS 264
Summary 267
CHAPTER 12: The "Cryptocurrency" in "Cryptocurrency"? 269
12.1 A Brief Introduction to BFT Consensus Algorithms 270
__12.1.1 The Problem of Resilience: Distributed Protocols for Structure 270
__12.1.2 Decentralization Solving the Problem of Trust 272
__12.1.3 The Problem of Scale: Permissionless and Censorship-Resistant Networks 273
12.2 How Bitcoin Works 275
__12.2.1 How Bitcoin Manages User Balances and Transactions 276
__12.2.2 The Digital Gold Mine: Mining BTC 278
__12.2.3 Fork Hell! Mining Dispute Resolution 281
__12.2.4 Reducing Block Size Using Merkle Trees 284
12.3 Cryptocurrency Overview 286
__12.3.1 Volatility 286
__12.3.2 Delay time 286
__12.3.3 Blockchain Size 287
__12.3.4 Confidentiality 287
__12.3.5 Energy Efficiency 288
12.4 DMBFT: BFT Consensus Protocol 288
__12.4.1 Two Properties of BFT Consensus Protocols: Safety and Liveness 288
__12.4.2 Round 289 of the DMBFT Protocol
__12.4.3 How much dishonesty can a protocol tolerate? 290
__12.4.4 DMBFT Voting Rules 291
__12.4.5 When is a transaction confirmed? 292
__12.4.6 The Hidden Intuition Behind DMBFM's Safety 293
Summary 295
CHAPTER 13 Hardware Cryptography 297
13.1 Attacker Models in Modern Cryptography 297
13.2 Hardware: The Savior of Untrusted Environments 299
__13.2.1 White-Box Cryptography 300
__13.2.2 Smart Cards and Security Elements 300
__13.2.3 HSM 303, Loved by Banks
__13.2.4.
Great standardization of security elements, TPM 305
__13.2.5 Secure Computing with TEE 308
13.3 Which solution should I choose? 309
13.4 Leak-Resistant Cryptography and Side-Channel Attack Defenses 311
__13.4.1 Constant-Time Programming 313
__13.4.2 Masking and Blinding 315
__13.4.3 How to Deal with Flaw Attacks 316
Summary 316
CHAPTER 14 Cryptography in the Quantum Computer Age 319
14.1 What is a Quantum Computer? 320
__14.1.1 Exploring the Small, Quantum Mechanics 320
__14.1.2 From the Birth of Quantum Computers to Quantum Supremacy 323
__14.1.3 Grover and Shor's Algorithm 324
__14.1.4 Post-Quantum Cryptography Against Quantum Computers 326
14.2 All you need is a hash function! Hash-based signatures 326
__14.2.1 OTS 327 via Lamport Signature
__14.2.2 WOTS and Small Key 329
__14.2.3 Multi-signature via XMSS and SPHINCS+ 330
14.3 Shorter Keys and Signatures Using Lattice-Based Cryptography 333
__14.3.1 What is a Lattice? 333
__14.3.2 Learning from Errors 335
__14.3.3 Lattice-Based Key Exchange, Kyber 337
__14.3.4 Lattice-Based Signature Scheme, Dilithium 339
14.4 Are Quantum Computers a Horror? 340
Summary 342
CHAPTER 15: Next-Generation Cryptography 345
15.1 MPC 346, the more you play together, the better
__15.1.1 PSI 347
__15.1.2 General Purpose MPC 348
__15.1.3 MPC's current 350
15.2 FHE and the Future of the Encrypted Cloud 350
__15.2.1 Example of RSA Encryption and Homomorphic Encryption 351
__15.2.2 Various Homomorphic Encryption 351
__15.2.3 The Key to FHE, Bootstrapping 352
__15.2.4 Error-Based Learning-Based FHE System 354
__15.2.5 Where to use it? 356
15.3 General Purpose ZKP 357
__15.3.1 How zk-SNARKs Work 359
__15.3.2 Isomorphic commit 360 that hides part of the evidence
__15.3.3 Bilinear Pairing to Improve Isomorphic Commit 361
__15.3.4 Where is the brevity? 361
__15.3.5 Program to Polynomial 362
__15.3.6 The program is for computers.
What we need is an arithmetic circuit 363
__15.3.7 R1CS Arithmetic Circuit 364
__15.3.8 From R1CS to Polynomials 364
__15.3.9 Computing the Hidden Polynomial in the Exponent 365
Summary 367
CHAPTER 16 The End of Cryptography 369
16.1 The tedious task of finding suitable cryptographic primitives or protocols 370
16.2 How to Use Cryptographic Primitives and Protocols? Standards and Format Verification 371
16.3 Where are the good libraries? 374
16.4 Developers Are the Enemy? Cryptography Misuse 376
16.5 Easy-to-Use Security 377
16.6 Cryptography is Not an Island 378
16.7 Cryptography Practitioners' Responsibilities: Don't Test Your Own Cryptography 379
Summary 381
Practice Problem Answer 383
Search 388
Detailed image
.jpg)
Into the book
Let's say Queen Alice needs to send a letter to Sir Bob, who lives in a castle far away.
Queen Alice asks her loyal messenger to ride his trusty horse across the perilous lands to deliver a precious message to Sir Bob.
But she doesn't completely trust the messenger.
(…) What Queen Alice needs is a protocol that mimics the act of transmitting a message to Sir Bob without an intermediary.
This is a practically unsolvable problem unless you introduce cryptography (or teleportation).
The cryptographic algorithm invented long ago to solve this problem is the symmetric encryption algorithm (also called a cipher).
--- p.5
This issue is also a vulnerability that I have discovered several times during my technical audits.
When verifying an authentication tag, the comparison between the received authentication tag and the calculated authentication tag must be performed within a constant time.
That is, assuming the received tags are of the correct size, the comparison should always take the same amount of time.
The inconsistent time taken to compare two authentication tags may be due to the two tags reflecting different moments during the comparison.
This would allow an attack to measure the time taken for verification and then regenerate a valid authentication tag byte by byte.
This type of attack is called a timing attack.
The following page explains this through a metaphor.
/ Fortunately, cryptography libraries that implement MACs also provide convenient functions that allow you to verify authentication tags in constant time.
As a practical example, Example 3.3 shows how to implement constant-time comparison of authentication tags in Golang.
--- p.59
First, to encrypt the message to Alice, we use (EC)DH-based key exchange with Alice's public key and a key pair generated from it (called an ephemeral key pair).
You can then use the shared secret obtained with an authenticated symmetric encryption algorithm such as AES-GCM to encrypt a longer message to send to Alice (Figure 6.19).
/ Then you can send the temporary public key and ciphertext to Alice.
Alice performs a key exchange with her own key pair using the temporary public key.
You can then use the result to decrypt the ciphertext and get the original message.
--- p.136
There are countless places outside of cryptography where randomness is needed.
Even simple Unix programs like ls require randomness! Exploiting bugs in programs can lead to fatal consequences, so binaries employ various tricks to defend against low-level attacks.
One of them is address space layout randomization (ASLR), which randomizes the memory layout of a process each time it runs, requiring random numbers.
Another example is the network protocol TCP, which uses random numbers each time a connection is created to generate an unpredictable sequence of numbers, preventing attacks that attempt to hijack the connection.
(…) NIST, wanting to be different (as always), calls its PRNG a deterministic random bit generator (DRBG).
--- pp.167~168
Some attackers have free access to the device, while others have a limited amount of time to execute their attack.
Let's imagine the following scenario:
You left your smartphone or laptop in your hotel room, and a 'malicious' maid came in, opened the device, used low-budget tools to modify the system, and then put the device back where it was.
When you return to your room, the device is in its original place and appears untouched.
This is known as an evil maid attack and can be generalized to many situations (e.g. carrying a device in checked luggage during a flight, storing sensitive keys in an insecure data center, etc.).
--- p.299
Since most asymmetric algorithms used today rely on discrete logarithms or factoring problems, Shor's algorithm is fatal to asymmetric cryptography.
Of course, discrete logarithms and factorization remain difficult mathematical problems, and algorithm parameters can be increased in size to improve defense against quantum computers.
Unfortunately, however, in 2017, Bernstein et al. showed that parameter expansion, while effective, is highly impractical.
The study estimated that increasing the parameters of RSA to 1 terabyte would be necessary to achieve quantum resistance.
Parameter sizes of this magnitude are unrealistic.
Queen Alice asks her loyal messenger to ride his trusty horse across the perilous lands to deliver a precious message to Sir Bob.
But she doesn't completely trust the messenger.
(…) What Queen Alice needs is a protocol that mimics the act of transmitting a message to Sir Bob without an intermediary.
This is a practically unsolvable problem unless you introduce cryptography (or teleportation).
The cryptographic algorithm invented long ago to solve this problem is the symmetric encryption algorithm (also called a cipher).
--- p.5
This issue is also a vulnerability that I have discovered several times during my technical audits.
When verifying an authentication tag, the comparison between the received authentication tag and the calculated authentication tag must be performed within a constant time.
That is, assuming the received tags are of the correct size, the comparison should always take the same amount of time.
The inconsistent time taken to compare two authentication tags may be due to the two tags reflecting different moments during the comparison.
This would allow an attack to measure the time taken for verification and then regenerate a valid authentication tag byte by byte.
This type of attack is called a timing attack.
The following page explains this through a metaphor.
/ Fortunately, cryptography libraries that implement MACs also provide convenient functions that allow you to verify authentication tags in constant time.
As a practical example, Example 3.3 shows how to implement constant-time comparison of authentication tags in Golang.
--- p.59
First, to encrypt the message to Alice, we use (EC)DH-based key exchange with Alice's public key and a key pair generated from it (called an ephemeral key pair).
You can then use the shared secret obtained with an authenticated symmetric encryption algorithm such as AES-GCM to encrypt a longer message to send to Alice (Figure 6.19).
/ Then you can send the temporary public key and ciphertext to Alice.
Alice performs a key exchange with her own key pair using the temporary public key.
You can then use the result to decrypt the ciphertext and get the original message.
--- p.136
There are countless places outside of cryptography where randomness is needed.
Even simple Unix programs like ls require randomness! Exploiting bugs in programs can lead to fatal consequences, so binaries employ various tricks to defend against low-level attacks.
One of them is address space layout randomization (ASLR), which randomizes the memory layout of a process each time it runs, requiring random numbers.
Another example is the network protocol TCP, which uses random numbers each time a connection is created to generate an unpredictable sequence of numbers, preventing attacks that attempt to hijack the connection.
(…) NIST, wanting to be different (as always), calls its PRNG a deterministic random bit generator (DRBG).
--- pp.167~168
Some attackers have free access to the device, while others have a limited amount of time to execute their attack.
Let's imagine the following scenario:
You left your smartphone or laptop in your hotel room, and a 'malicious' maid came in, opened the device, used low-budget tools to modify the system, and then put the device back where it was.
When you return to your room, the device is in its original place and appears untouched.
This is known as an evil maid attack and can be generalized to many situations (e.g. carrying a device in checked luggage during a flight, storing sensitive keys in an insecure data center, etc.).
--- p.299
Since most asymmetric algorithms used today rely on discrete logarithms or factoring problems, Shor's algorithm is fatal to asymmetric cryptography.
Of course, discrete logarithms and factorization remain difficult mathematical problems, and algorithm parameters can be increased in size to improve defense against quantum computers.
Unfortunately, however, in 2017, Bernstein et al. showed that parameter expansion, while effective, is highly impractical.
The study estimated that increasing the parameters of RSA to 1 terabyte would be necessary to achieve quantum resistance.
Parameter sizes of this magnitude are unrealistic.
--- p.325
Publisher's Review
The present and future of cryptography: learning through pictures instead of formulas, examples instead of history, and applications instead of theory.
Cryptography is the foundation of IT security, including web APIs, user services, and blockchain, but there aren't many books on it worth reading.
Books that start with history, like the Caesar cipher or the Vigenère cipher, are boring.
What elements make up modern cryptography, what protocols are commonly used, what attacks have occurred, and what does the future of cryptography hold with the advent of quantum computers?
What practitioners are curious about is this.
Instead of delving into the history of cryptography or legacy algorithms, the author fills the book with real-world, large-scale use cases today, including TLS, the Noise Protocol framework, the Signal Protocol, cryptocurrencies (the author claims this is the first cryptography book with a full chapter on cryptocurrencies!), HSMs, and threshold cryptography.
Although there are no formulas, we have tried to make the explanation easy to understand by inserting numerous pictures, including Alice and Bob, who are familiar to us.
The author himself did not know how the elliptic curve mathematics he learned in college was used in real-world algorithms, and many developers are causing security failures by making 'implementation' mistakes. Therefore, for each chapter, he included example snippets written in various languages such as Java, JavaScript, Golang, and Rust, using 'good' libraries.
Rich diagrams and case studies help developers, system administrators, and security practitioners learn cryptographic concepts like authentication, encryption, and confidentiality, as well as tools, frameworks, and protocols to stay ahead of attackers.
This is the most practical and modern cryptography book, covering everything from the basics like hash functions and signatures to cryptographic protocols like HTTPS and secure messaging, and cutting-edge technologies like post-quantum cryptography (quantum-resistant cryptography) and cryptocurrencies.
Key Contents
Best practices when using cryptography
ㆍ Illustrations and explanations of cryptographic algorithms
ㆍ Implementation of digital signatures and zero-knowledge proofs
ㆍ Hardware solutions to prepare for attacks, etc.
How to identify and fix bad practices
ㆍ Selecting the appropriate cryptographic tool for each problem
Cryptography is the foundation of IT security, including web APIs, user services, and blockchain, but there aren't many books on it worth reading.
Books that start with history, like the Caesar cipher or the Vigenère cipher, are boring.
What elements make up modern cryptography, what protocols are commonly used, what attacks have occurred, and what does the future of cryptography hold with the advent of quantum computers?
What practitioners are curious about is this.
Instead of delving into the history of cryptography or legacy algorithms, the author fills the book with real-world, large-scale use cases today, including TLS, the Noise Protocol framework, the Signal Protocol, cryptocurrencies (the author claims this is the first cryptography book with a full chapter on cryptocurrencies!), HSMs, and threshold cryptography.
Although there are no formulas, we have tried to make the explanation easy to understand by inserting numerous pictures, including Alice and Bob, who are familiar to us.
The author himself did not know how the elliptic curve mathematics he learned in college was used in real-world algorithms, and many developers are causing security failures by making 'implementation' mistakes. Therefore, for each chapter, he included example snippets written in various languages such as Java, JavaScript, Golang, and Rust, using 'good' libraries.
Rich diagrams and case studies help developers, system administrators, and security practitioners learn cryptographic concepts like authentication, encryption, and confidentiality, as well as tools, frameworks, and protocols to stay ahead of attackers.
This is the most practical and modern cryptography book, covering everything from the basics like hash functions and signatures to cryptographic protocols like HTTPS and secure messaging, and cutting-edge technologies like post-quantum cryptography (quantum-resistant cryptography) and cryptocurrencies.
Key Contents
Best practices when using cryptography
ㆍ Illustrations and explanations of cryptographic algorithms
ㆍ Implementation of digital signatures and zero-knowledge proofs
ㆍ Hardware solutions to prepare for attacks, etc.
How to identify and fix bad practices
ㆍ Selecting the appropriate cryptographic tool for each problem
GOODS SPECIFICS
- Date of issue: January 20, 2023
- Page count, weight, size: 424 pages | 806g | 188*245*22mm
- ISBN13: 9791192469539
- ISBN10: 1192469534
You may also like
카테고리
korean
korean