liveBook · Manning

What you will learn in Hacking Cryptography

Write, break, and fix real-world implementations

by Kamran Khan and Bill Cox

Chapter by chapter

Chapter 1: Introduction

1.1 What is cryptography? · 1.2 How does cryptography work? · 1.2.1 Confidentiality · 1.2.2 Integrity · 1.2.3 Authenticity · 1.3 Attacks on cryptographic theory vs. attacks on implementations · 1.4 What will you learn in this book? · 1.5 Summary

What you learn in chapter 1 →

Chapter 2: Random number generators

2.1 Why do we need random numbers for cryptography? · 2.1.1 Uniform distribution: Making things harder to guess · 2.1.2 Entropy: Quantifying unpredictability · 2.2 Understanding different types of RNGs · 2.2.1 True random number generators (TRNGs) · 2.2.2 Pseudo random number generators (PRNGs) · 2.2.3 Cryptographically secure pseudorandom number generators (CSPRNGs) · 2.3 Summary

What you learn in chapter 2 →

Chapter 3: Implementing and exploiting RNGs

3.1 Implementing and exploiting Mersenne Twister-based RNGs · 3.1.1 Implementing MT19937 · 3.1.2 Exploiting MT19937 · 3.2 Implementing and exploiting the Dual Elliptic Curve Deterministic Random Bit Generator · 3.2.1 Building block for DUAL_EC_DRBG: Big numbers · 3.2.2 Building block for DUAL_EC_DRBG: Elliptic curves · 3.2.3 Implementing DUAL_EC_DRBG · 3.2.4 Exploiting DUAL_EC_DRBG · 3.3 Summary

What you learn in chapter 3 →

Chapter 4: Stream ciphers

4.1 Symmetric key encryption · 4.1.1 The exclusive-or (XOR) operation and its role in cryptography · 4.1.2 One-time pads and their practical limitations · 4.2 Linear feedback shift registers (LFSRs) · 4.2.1 Implementing LFSRs · 4.2.2 Exploiting LFSRs · 4.3 RC4 encryption and Wi-Fi security · 4.3.1 Implementing RC4 · 4.3.2 Exploiting RC4 in WEP using the Fluhrer, Mantin, and Shamir (FMS) attack · 4.4 Summary

What you learn in chapter 4 →

Chapter 5: Block ciphers

5.1 Important block ciphers · 5.2 Padding: Making data fit blocks neatly · 5.3 Modes of operation for block ciphers · 5.4 Padding oracles and how to attack them · 5.4.1 Implementing a padding oracle server · 5.4.2 Exploiting a padding oracle · 5.5 Browser Exploit Against SSL/TLS: The BEAST attack · 5.5.1 Simulating a vulnerable browser for BEAST · 5.5.2 Exploiting the BEAST vulnerability · 5.6 Summary

What you learn in chapter 5 →

Chapter 6: Hash functions

6.1 Hash functions as one-way digital fingerprints · 6.2 Security properties of hash functions · 6.3 Important hash functions · 6.3.1 The Merkle–Damgård construction · 6.3.2 Cryptographic sponges: Permutation-based hash functions · 6.4 Attacks on hash functions · 6.4.1 Collision attacks · 6.4.2 Example: Exploiting hash functions using rainbow tables · 6.5 Summary

What you learn in chapter 6 →

Chapter 7: Message authentication codes

7.1 Message integrity and authenticity · 7.2 Different types of MACs · 7.3 Secret-prefix MACs and length-extension attacks · 7.3.1 Implementing a bank API that uses secret-prefix hashing for authentication · 7.3.2 Exploiting secret-prefix MACs using length-extension attacks · 7.4 Secret-suffix MACs and collision attacks · 7.5 HMACs: Hash-based MACs · 7.6 Summary

What you learn in chapter 7 →

Chapter 8: Public-key cryptography

8.1 Asymmetric cryptography: Splitting the secret key into public and private portions · 8.2 Mathematical theory behind public-key cryptography · 8.2.1 Prime numbers and how to find them · 8.2.2 Probabilistic testing of prime numbers and the important role of RNGs in generating them · 8.2.3 Trapdoor functions · 8.3 Types of public-key cryptography systems · 8.3.1 Discrete logarithms · 8.3.2 Integer factorization and the RSA cryptosystem · 8.4 Exploiting RSA · 8.4.1 Common-factors attack and the effect of poor random number generation on cryptographic security · 8.4.2 Wiener’s attack: Exploiting short secret exponents in textbook RSA · 8.5 Summary

What you learn in chapter 8 →

Chapter 9: Digital signatures

9.1 Message authenticity using symmetric and asymmetric secrets · 9.2 Practical applications of digital signatures · 9.2.1 Certificates: Extending trust using digital signatures · 9.2.2 Code integrity: Ensuring software security using digital signatures · 9.2.3 Using signatures for digital contracts · 9.3 Forgery attacks on digital signatures · 9.4 Schoolbook RSA signatures · 9.5 The elliptic curve digital signature algorithm (ECDSA) · 9.5.1 Implementing vulnerable ECDSA signatures with reused nonces · 9.5.2 Exploiting reused nonces in ECDSA signatures · 9.6 RSA signature forgery with Bleichenbacher’s e = 3 attack · 9.6.1 PKCS#1 v1.5: Padding strikes again · 9.6.2 Implementing a vulnerable PKCS #1 v1.5 padding verifier · 9.6.3 Exploiting PKCS #1 v1.5 padding with Bleichenbacher e = 3 signature forgery · 9.6.4 Stitching prefix and suffix cube roots together to forge a signature · 9.7 Summary

What you learn in chapter 9 →

Chapter 10: Guidelines and common pitfalls for cryptographic implementations

10.1 A brief recap of attacks from previous chapters · 10.1.1 Random number generators · 10.1.2 Stream ciphers · 10.1.3 Block ciphers · 10.1.4 Hash functions · 10.1.5 Message authentication codes · 10.1.6 Asymmetric encryption · 10.1.7 Digital signatures · 10.2 One vulnerability to rule them all: Poor-quality randomness · 10.3 Padding: Challenges with fitting things neatly · 10.4 Constant-time implementations and timing attacks · 10.4.1 Comparing data in constant time · 10.4.2 Timing attacks and side-channel analysis · 10.5 Control flow and secrets: A dangerous mix · 10.6 Memory safety and buffer management · 10.7 Type safety: Challenges with interpreting raw bytes · 10.8 Miscellaneous considerations · 10.8.1 Handling sensitive values in general-purpose memory · 10.8.2 Time-of-check to time-of-use (TOCTOU) vulnerabilities · 10.8.3 Prefer authenticated encryption to combining primitives on your own · 10.8.4 Treating security as a product · 10.9 Summary

What you learn in chapter 10 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.