दुर्गा बेरागी Durga Beragi, homeEnter the study →

Library › Cryptography, blockchain and crypto

Cryptography Engineering

Niels Ferguson, Bruce Schneier and Tadayoshi Kohno · 2010 · John Wiley & Sons

Real systems fail at the edges. How to build them right.

About the book

Niels Ferguson, Bruce Schneier and Tadayoshi Kohno published Cryptography Engineering in 2010. It is a revision and expansion of Practical Cryptography, which Ferguson and Schneier published in 2003. Where Applied Cryptography surveyed many algorithms, this book shows how to build a secure system with a few well-chosen components. The authors work through designing a secure channel, then cover block ciphers and modes, hash functions, message authentication, implementation issues, generating randomness, primes, Diffie-Hellman, RSA, a key negotiation protocol, clocks, key servers, public-key infrastructure and storing secrets. They describe Fortuna, a random number generator design. The book includes exercises and was used in university courses.

Key ideas

  • Security is a chain, and attackers go for the weakest link. Strong encryption does nothing if the keys, the random numbers, the implementation or the users are weak.
  • Complexity is the enemy of security. Designs should use a few components with clear properties, because every extra option and feature adds new ways for the system to fail.
  • Cryptographers should think like attackers and be professionally paranoid. Systems should be designed for a long working life against attackers who will grow stronger over time.
  • Most failures occur in implementation, not in algorithms. Side channels, poor error handling, bad memory management and wrong parameters can break designs that are mathematically sound.
  • Good randomness is essential and hard to get. The authors explain why naive random number generators fail in practice and describe Fortuna as a more robust design.
  • Public-key infrastructure is harder than it looks. Certificates, revocation and trust between separate organisations raise practical problems that the underlying mathematics does nothing to solve.

Why it is on this shelf

Anyone who stores keys, signs transactions or builds wallets needs this book's engineering discipline. It explains why sound mathematics still fails in practice and how to design defensively against that. The authors state their opinions plainly and then justify each one.

How to start reading it

Read the opening chapters on the context of cryptography and the security mindset. Then follow the secure channel design through. Read the implementation and randomness chapters closely; that is where most real systems break.

About this book

Cryptography Engineering: Design Principles and Practical Applications was published by John Wiley and Sons in 2010. Its authors are Niels Ferguson, Bruce Schneier and Tadayoshi Kohno. It is a revised and expanded version of Practical Cryptography, which Ferguson and Schneier published in 2003. The new edition added Kohno as an author, brought the material up to date, and added exercises so that the book could be used for university teaching.

The book was written in reaction to a pattern its authors had seen many times. By the early 2000s, good cryptographic algorithms were freely available. Strong ciphers and hash functions had been published, analysed and standardised. Yet the systems built with them kept failing. Encrypted protocols leaked data. Random number generators produced predictable keys. Software that called the right functions called them in the wrong order, or ignored error codes, or left keys lying in memory. The algorithms were rarely the problem. Everything around them was.

The question the book sets out to answer is how to build a system that uses cryptography and is actually secure. It does not try to survey all of cryptography. It deliberately teaches a small set of tools and shows how to combine them correctly, with attention to the places where real systems break: implementation, randomness, key management, protocols and human factors. Its stance is opinionated. The authors tell the reader what to use and what to avoid, and they give reasons.

The intended readers are engineers and students who will design or implement systems that use cryptography. A reader needs to be comfortable with programming and with basic mathematics. No deep theory is required. The book explains the number theory it needs as it goes, and it keeps formal proofs to a minimum. In tone it is closer to a senior colleague's advice than to a textbook's exposition.

This study edition is a companion to the book. It explains the book's main ideas and attitudes in our own words, with our own examples, places it among its neighbours on the shelf, and offers a plan for reading it. It does not reproduce the book's designs, recommendations in detail, or exercises, and it is no substitute for reading the authors' reasoning in full.

The authors

Niels Ferguson is a Dutch cryptographer. Early in his career he worked on digital cash systems, and he later worked with Schneier at Counterpane Internet Security before joining Microsoft, where he contributed to the design of cryptographic components in Windows, including work associated with the BitLocker disk encryption feature. He was a member of the team that designed the Twofish block cipher, a finalist in the competition that selected the Advanced Encryption Standard, and he contributed to the Skein hash function, a finalist in the later competition for SHA-3. He is also known for cryptanalysis, including work showing weaknesses in a random number generator standard that was later at the centre of public controversy.

Bruce Schneier is an American security technologist and writer. His first major book, Applied Cryptography, appeared in 1994 and introduced a generation of programmers to cryptographic algorithms. He designed or co-designed the Blowfish and Twofish ciphers, the Yarrow random number generator with John Kelsey and Niels Ferguson, and the Fortuna generator with Ferguson. He founded Counterpane Internet Security, and he has written a long-running newsletter on security and a series of books for general readers, including Secrets and Lies, Beyond Fear, Liars and Outliers, Data and Goliath, and Click Here to Kill Everybody. Over time his writing moved from algorithms toward the human, economic and political sides of security. That movement is visible in this book, which spends as much effort on context as on mathematics.

Tadayoshi Kohno is an American computer scientist who was a professor at the University of Washington. His doctoral work was in cryptography, including the analysis of authenticated encryption and protocols such as the secure shell. He became widely known for research on the security of real devices: work showing that implanted medical devices and modern cars could be attacked through their wireless and electronic interfaces, and studies of security and privacy for new technologies. His presence in this edition brings a researcher's eye for attacks on deployed systems and a teacher's concern with how security thinking can be learned.

The three authors share a background in both design and attack. Each has built cryptographic systems and broken others. That double experience is the source of the book's main quality: it treats design as an argument with a future attacker.

The shape of the argument

The book is organised in a deliberate order, and the order is part of its teaching. It moves from attitude, to the protection of messages, to the creation of keys, to the management of keys over time, and finally to practical matters around the work.

Attitude first

The book opens not with algorithms but with the context in which cryptography is used. It explains why security is different from other engineering properties, introduces the mindset of the attacker, and describes how to think about threats and trade-offs. It insists that cryptography is only one small part of a secure system, and that its job is to be the part that does not fail.

Protecting messages

The first technical movement assumes that two parties already share a secret key and asks how to protect the messages they exchange. It introduces block ciphers, the modes that turn them into encryption for long messages, hash functions and message authentication codes. It then assembles these into a complete design for a secure channel, the basic object that carries protected messages between two parties. It ends by turning to implementation and the ways good designs go wrong in code.

Creating keys

The second movement asks where the shared key comes from. It starts with randomness, which every key needs, and treats it at length. It then introduces the number theory needed for public-key methods, explains Diffie-Hellman and RSA as the authors recommend using them, and introduces the general problem of protocol design. It builds a key negotiation protocol step by step, showing the attacks that each step must resist. Again it ends with implementation concerns.

Managing keys over time

The third movement turns to the long life of keys and the infrastructure around them. It covers clocks, which many protocols silently rely on; key servers; public-key infrastructure, examined first as an ideal and then as a messy reality; and the problem of storing secrets on devices and in human memory. This part is the least mathematical and, in the authors' view, among the most important.

Around the work

The book closes with practical matters: standards, patents, and the role of experts. These short discussions reflect the authors' experience of how security decisions are actually made in organisations.

The method under the order

Under this order is a single method. The authors pick a small number of components, define what each must do, and then compose them with care, considering at each step how an attacker would exploit any gap. They prefer a simple design that they can reason about to a flexible design that they cannot. They make choices explicit and explain them. A reader who follows this method through the book learns less a list of recipes than a way of working.

Key idea one: the weakest link

The first idea the book presses is that security is a property of the whole system, and that a system is only as strong as its weakest part. An attacker does not attack the strongest component. An attacker looks for the cheapest way in.

Consider a house with a reinforced steel door and an open kitchen window. The quality of the door is irrelevant to a burglar who walks past it. In computing, the steel door is often the cipher. Modern ciphers are so strong that breaking them directly is far beyond any realistic attacker. So attackers go elsewhere: the password that unlocks the key, the computer on which the key is stored, the server that holds the data before encryption, the employee who can be tricked into sending it, the software update that can be forged, the backup copy left unprotected.

This has a practical consequence for how effort should be spent. Strengthening an already strong component adds nothing if a weaker one remains. A designer who chooses a 256-bit key and then protects it with a short password has a system whose real strength is the password. A system that uses excellent encryption but lets users bypass it by clicking a warning has a system whose real strength is user patience. The authors repeatedly ask the reader to find the weakest link first and to fix that.

The idea is easy to state and hard to apply, because weak links are often outside the part of the system that the designer is responsible for. The book's response is to widen the designer's field of view. A cryptographer must think about the operating system, the hardware, the protocol around the cryptography, the people who use it, and the procedures for recovering when something goes wrong. A narrow focus on algorithms is, in this view, a failure of professional duty.

A common confusion is to take the weakest link idea as an argument against strong cryptography. It is the opposite. The point of strong cryptography is to make sure that the cryptography is never the weakest link, so that attention can go elsewhere. The authors want the cryptographic core to be so conservative that nobody needs to think about it again.

Key idea two: professional paranoia

The book asks its readers to adopt what the authors call a professional paranoia. This is not anxiety. It is a disciplined habit of asking, for every part of a design, how it could be made to fail by someone who wants it to.

Ordinary engineering deals with failures that arise by chance. A bridge must carry its expected load with a margin for unusual loads, winds and wear. These forces are indifferent. Security engineering deals with an adversary who is intelligent, patient and creative, and who will search for the exact conditions under which the system misbehaves. A bug that would occur once in a billion random inputs may be triggered every time by an attacker who constructs that input deliberately. This changes everything about how one designs and tests.

The authors describe how to cultivate the attacker's mindset. Look at everyday systems and ask how they could be cheated. Look at every assumption in a design and ask what happens if it is false. Assume that the attacker knows the design, has more time than you, and will find the cheapest path. Treat any behaviour that is not specified as a possible opening. The book's exercises encourage readers to apply this to news stories and products, writing short security reviews of real systems. Kohno has written elsewhere about teaching this habit to students.

This mindset carries a cost that the book acknowledges. Paranoia must be professional, applied to the system and not to colleagues. A security engineer who rejects every proposal is not useful. The goal is to find and fix weaknesses while still shipping systems that people can use. The authors frame security as a balance of risks and costs, not an absolute.

An illustration from outside computing helps. A good proofreader does not read a page as its author does, following the meaning. A good proofreader reads letter by letter, looking for the errors the author's mind skips over. Professional paranoia is a proofreader's reading of a system: deliberately ignoring what the design is meant to do in order to see what it can be made to do.

Key idea three: complexity is the enemy

The book returns again and again to one claim: complexity is the worst enemy of security. Every option, feature, mode and extension adds code that can contain bugs and interactions that nobody has fully analysed. A simple system can be understood and tested. A complex one cannot.

This principle explains several of the book's choices. Instead of offering a menu of algorithms, the authors recommend a small set and tell the reader to use those. Instead of protocols that negotiate among many options, they prefer protocols with fixed choices. Instead of flexible formats, they prefer formats that are unambiguous and easy to parse. They argue that the convenience of options is mostly an illusion, because each option is a decision that someone will eventually make badly, and because negotiation itself can be attacked. Real protocols have suffered from attacks in which an adversary persuaded both ends to fall back to a weaker option than either would have chosen.

The book also discusses modular design as a way to manage the complexity that cannot be avoided. Each component should have a clear interface and a clear security property. Components should be composed in ways whose security can be argued from the properties of the parts. When a component is replaced, its replacement should provide the same property. This is the same discipline as good software design, applied with an adversary in mind.

An analogy from cooking may help. A dish with three excellent ingredients, each well understood, is easier to get right than a dish with thirty, each of which interacts with the others. A small error in the thirty-ingredient dish may be invisible until it ruins the meal. Security protocols behave the same way, except that the person eating the meal is trying to find the flaw.

The principle is often confused with a demand for minimal functionality. That is not quite the point. Systems may need many features. The principle is that the security-critical core should be small, simple and isolated, so that complexity elsewhere cannot reach it. The authors want designers to draw a tight boundary around what must be correct and to keep that part as plain as possible.

Key idea four: conservative security margins

The authors take a cautious view of how strong cryptographic components should be. They argue that systems are used for much longer than expected, that attacks only get better over time, and that the cost of extra strength is usually small. So they recommend generous margins.

One example is their treatment of security levels. A common target in the period was a security level of 128 bits, meaning that an attacker would need about two to the power 128 operations to break the system. The authors point out that some attacks, such as collision attacks that exploit the birthday paradox, cut the effective strength of a value in half. A hash output or key of a given length may therefore provide only half the security one might naively expect against certain attacks. Their response is to use sizes large enough that even after such reductions the target level remains. In practice this means preferring 256-bit keys and hash outputs where 128-bit security is the goal.

A second example is their attitude to new or lightly studied algorithms. They advise using components that have survived long public scrutiny, and they are suspicious of novel designs, including their own, until others have attacked them. They also suggest, in places, adding modest safety measures that cost little and protect against unexpected weaknesses, such as small changes to hash function use that defend against known structural properties of common hash constructions.

The reasoning behind this caution comes from the asymmetry of costs. If a system is stronger than needed, the cost is a little extra computation. If it is weaker than needed, the cost may be the complete loss of what it protects, often discovered years later and impossible to undo. Data encrypted today may be recorded by an adversary and attacked decades from now. Long-lived systems, such as those protecting archives, medical records or financial ledgers, therefore deserve particular conservatism.

The principle is not a call for maximum strength at any cost. In constrained settings, such as small devices with limited power, trade-offs are real. The authors' view is that in most software the cost of cryptography is small compared with everything else, and that cutting margins to save a little time is usually a false economy.

Key idea five: the secure channel

At the heart of the book's first technical part is a single, concrete object: the secure channel. Two parties share a secret key and want to exchange a sequence of messages so that an attacker who controls the network can neither read them nor change them undetected. The authors design such a channel in detail, and the design serves as a teaching vehicle for the whole approach.

The secure channel requires more than encryption. It requires authentication of every message, so that tampering is detected. It requires protection against replay, so that an attacker cannot resend an old valid message. It requires protection against reordering and deletion, or at least detection of them, so that the receiver knows the sequence is intact. It requires a way to handle very long sessions and to stop before internal counters run out. It requires separate keys for each direction and for each function, derived from the shared secret, so that the same key is never used in two roles.

The book shows how a few components meet these requirements together. A block cipher in a suitable mode provides confidentiality. A message authentication code provides integrity. A message number, included in what is authenticated, provides ordering and replay protection. Key derivation provides separate keys for each purpose. The authors also discuss the order in which encryption and authentication are applied, a question on which the field has thought hard, and they give their reasoning for the order they choose. Since the book appeared, practice has moved strongly toward combined authenticated encryption modes, which handle both functions in one well-analysed construction. A modern reader should note the book's reasoning and also the later consensus.

The value of this exercise is not the specific design. It is the way of thinking it demonstrates. Before building anything, list precisely what the channel must guarantee. Then make sure each guarantee is provided by a specific mechanism, and that the mechanisms do not interfere. Then think about what happens at the edges: the first message, the last message, a message that fails to verify, a counter that wraps around. Most attacks on real protocols live at exactly those edges.

Readers often treat a secure channel as equivalent to encryption. The book's design shows why that is wrong. Encryption without authentication allows tampering. Authentication without sequence numbers allows replay. Separate components that are each secure can be combined insecurely. The secure channel is the smallest unit that makes the right promises, and almost every secure protocol, from the web's TLS to messaging apps, contains one.

Key idea six: implementation is where systems break

The book devotes two separate sections to implementation, one in each of its first two technical parts. This reflects a strong conviction: most real security failures are not failures of algorithms or even of designs, but of code.

The authors describe several families of implementation failure. One is plain bugs: buffer overflows and similar memory errors that let attackers take control of a program, after which no cryptography matters. Another is incorrect handling of errors and edge cases, such as accepting a message that failed verification, or responding differently to different kinds of invalid input and so revealing information. A third is careless handling of secrets in memory: keys left in buffers after use, copied by the operating system into swap files, or exposed in crash dumps.

A fourth family is side channels. A program can leak information through how long it takes, how much power it draws, or how it uses the processor's cache, even if its outputs are correct. A comparison that stops at the first wrong byte of a password check takes less time when the first byte is wrong, and an attacker who measures response times can recover the correct value byte by byte. Implementations of public-key operations whose running time depends on secret bits have been attacked in the same way. The book discusses the general problem and the defensive habit of writing code whose behaviour does not depend on secret values.

The book also takes a position on how to write security-critical code. It recommends clear specifications before coding, simple and readable code over clever code, careful testing including tests of failure cases, and defensive checks at every interface. It recognises that programming languages and tools matter, and that some languages make certain classes of bugs far easier to commit. It treats quality as a security property in itself.

A good analogy is a bank vault built to a perfect design by a contractor who leaves a ventilation duct wide enough to crawl through. The architect's plans were sound. The building was not. Most of the security incidents that make the news have this shape. The book's lasting service is to keep the reader's attention on the building, not only on the plans.

Key idea seven: randomness

Every cryptographic key must be unpredictable. Nonces and initialisation vectors often must be too. Signature schemes based on discrete logarithms need fresh random values each time, and a repeated or predictable value can reveal the private key. So randomness is not a detail. It is a foundation, and the book treats it at length.

Computers are deterministic machines. They do not produce randomness on their own. A system must gather unpredictable data from the physical world, such as timing of hardware events, noise in sensors or dedicated hardware sources, and then turn this raw material into a steady supply of high-quality random bits. The raw material is uneven and its quality is hard to measure. An attacker may be able to observe or influence some of it. Many real systems have failed at this step. Well-known cases include a widely used open-source cryptography package in which a code change crippled the randomness used for key generation for about two years, and studies that found large numbers of devices on the internet sharing keys or prime factors because they generated keys at boot time with too little randomness.

The book explains the structure of a good cryptographic random number generator. A generator stretches a secret internal state into output using a strong cipher or similar primitive, and updates its state so that past outputs cannot be reconstructed if the state is later stolen. An accumulator collects unpredictable events from many sources. A reseeding mechanism uses accumulated entropy to refresh the generator's state, so that even if an attacker learns the state at some point, the generator recovers once enough fresh unpredictability has come in.

The authors present Fortuna, a design by Ferguson and Schneier that addresses a hard question: how to reseed safely without being able to measure how much real entropy each source provides. Fortuna's idea is to spread incoming events across a number of pools and to use them on a staggered schedule, so that some pools are used often and others rarely. Whatever the actual rate of good entropy, some pool will eventually collect enough to defeat an attacker who knows the earlier state. The design avoids the need for estimates that the authors regarded as unreliable. Variants of this approach have been used in operating systems.

A common confusion is between statistical randomness and cryptographic unpredictability. A sequence can look random to statistical tests and still be predictable to someone who knows how it was made. The standard random functions in many programming languages are of this kind, designed for simulations, not security. Using them for keys is a classic mistake, and the book warns against it plainly.

Key idea eight: public-key tools, used with care

The book's treatment of public-key cryptography is notably practical. It explains the number theory needed, including modular arithmetic, how to test whether a large number is prime, and how to generate primes safely. It then presents Diffie-Hellman and RSA not as elegant formulas but as tools with sharp edges that must be handled in specific ways.

For Diffie-Hellman, the authors explain that the bare mathematical exchange leaves many questions open. Which group should be used, and how large should it be? How should the parties check that the values they receive are valid members of the intended group, so that an attacker cannot send a value that forces the shared secret into a small set of possibilities? How should the shared secret be turned into keys? Each of these questions has caused failures in real protocols. Attacks in which a party is tricked into using a weak or small subgroup, or into accepting a malformed value, are well documented. The book recommends checks and parameter choices that close these gaps.

For RSA, the book explains why the raw operation must never be used directly to encrypt or sign. The raw operation is deterministic, so identical messages give identical ciphertexts. It has mathematical structure that an attacker can exploit, for instance by combining signatures on related messages. And small messages or small exponents can lead to trivial attacks. The authors explain that RSA must always be wrapped in a careful encoding: for encryption, a randomised method of turning a short secret into a full-size input; for signatures, a method that ties the signature to a hash of the message in a way that destroys the structure. They give their reasoning for the particular approaches they recommend.

A recurring point is that public-key operations should do as little as possible. They are slow and their mathematics is intricate. The book's pattern is to use public-key methods only to establish or authenticate a symmetric key, and then hand everything else to the simpler and better understood symmetric tools. This keeps the complex part small, in line with the earlier principle about complexity.

The book also discusses key sizes and their evolution. Because factoring algorithms and computing power improve, the size of RSA modulus needed for a given security level grows over time, and much faster than the corresponding symmetric key size. The authors give recommendations suited to their time and explain how to think about the question in the future. Since the book appeared, elliptic curve methods, which the book discusses less fully, have become the more common choice for new systems because they give equivalent security with much shorter keys. A modern reader should apply the book's reasoning to these newer tools.

This idea is often misunderstood as a claim that public-key cryptography is fragile. It is better seen as a claim that its interface is unforgiving. The underlying mathematics is sound. The ways to misuse it are many and subtle. The book's role is to fence them off.

Key idea nine: protocols are where the attacker lives

A cryptographic protocol is a sequence of messages exchanged by parties to achieve a goal, such as agreeing on a key or proving identity. The book introduces protocol design with a warning: protocols are notoriously hard to get right, and many published protocols, including some designed by experts, were later found to be flawed.

The reason is that a protocol involves several parties with different knowledge, running possibly many sessions at once, over a network the attacker controls. The attacker can intercept, delay, replay, reorder, modify and inject messages. The attacker can start sessions with honest parties under false pretences and use messages from one session in another. A protocol that is secure when run once between two honest parties can collapse when an attacker interleaves two runs. A famous example from the research literature is a short authentication protocol proposed in the late 1970s and shown, nearly two decades later, to allow an attacker to impersonate one party to another by relaying messages between two sessions.

The book teaches a set of habits for protocol design. Be clear about the trust each party places in the others. Make every message unambiguous, carrying enough context, such as identities, roles and session identifiers, that it cannot be reused in a different place. Authenticate what is meant, not just what is sent, so that each party confirms not only the bytes but their interpretation. Assume that every message may be replayed or forged unless protected. Think about the order of messages and what each party knows at each point.

The book then designs a key negotiation protocol step by step, beginning with a simple version and showing how an attacker would break it, then adding protections, and repeating. This method is itself the main lesson. A reader learns to see a protocol as a sequence of claims that an attacker will try to falsify, and to check each claim against every way the attacker might interfere.

The authors also raise the economic and human side of protocols. Protocols embody relationships of trust between parties, and those relationships change. A protocol that assumes a server is honest fails when the server is compromised. A protocol that assumes users read warnings fails when they do not. Designing protocols requires asking not only what the messages do but what the parties actually are.

For readers of the blockchain books on this bay, this idea is directly relevant. Consensus protocols, wallet interactions, bridges between chains and smart contracts are protocols in exactly this sense, run in a hostile environment with very high stakes. Many of the large losses in decentralised finance came not from broken cryptographic primitives but from protocol logic that could be driven into states its designers did not foresee. The book's habits apply directly.

Key idea ten: the dream and reality of PKI

Public-key cryptography solves the problem of exchanging secret keys, but it creates a new one: how do you know that a public key really belongs to the person or server you think it does? If an attacker can substitute their own public key for your friend's, every message you encrypt goes to the attacker. Public-key infrastructure, or PKI, is the system of certificates and authorities meant to solve this problem. The book gives it an unusual amount of attention, and it is one of its most valuable parts.

The authors first describe the ideal. A trusted certificate authority signs statements binding names to public keys. Everyone knows the authority's public key. To check someone's key, you check the authority's signature on their certificate. Chains of authorities extend this to large systems. Revocation lists or online checks let authorities withdraw certificates when keys are lost or misused. In this ideal, PKI would make secure communication between strangers routine.

They then examine reality, and the picture is less tidy. Who is the authority, and why should everyone trust it? A single global authority is a single point of failure and a point of political control. Many authorities, as on the web, mean that the system is only as trustworthy as the least careful of them, since any of them can issue a certificate for any name. What does a name mean? Names are ambiguous, people share names, and organisations change. How does revocation work when the parties checking certificates are offline or do not bother to check? How long should certificates last, and who pays for their management? Each question has answers, but none of them is clean.

The authors argue that PKI works best within a single organisation or application, where one party controls the authority and the meaning of names is clear, and works least well as a universal infrastructure for the whole world. Events after the book appeared have illustrated the point. In 2011 a certificate authority based in the Netherlands was compromised and fraudulent certificates were issued for major domains, which led to the authority's collapse. Responses since then, such as public logs of all issued certificates, have improved the web's PKI, but its basic structure remains a compromise of exactly the kind the book describes.

The lesson for designers is to ask early and plainly how keys will be bound to identities in their system, and to accept that this is often the hardest part of the design. Cryptocurrency systems give one answer by refusing to bind keys to names at all: the key is the identity, and whoever holds it owns the funds. That choice avoids certificate authorities but transfers the full burden of key protection to users, with consequences visible in the large amounts of value lost to misplaced or stolen keys.

Key idea eleven: storing secrets

Keys must live somewhere. The book's final technical discussions concern where and how. A key on a disk can be copied. A key in memory can be read by other software or extracted from a stolen machine. A key derived from a password is only as strong as the password. A key on a special device may be safe, but the device can be lost. A key held only in a person's memory is lost when the person forgets or dies. Every option has a failure mode, and the book walks through them.

The treatment of passwords is especially useful. Human-chosen passwords contain far less unpredictability than their length suggests, because people choose words, names and patterns. An attacker who obtains a stored password verifier can try candidate passwords at enormous speed. The defences the book explains are salting, which adds a unique random value to each password before processing so that one computation cannot be reused across many users, and stretching, which deliberately makes each password check slow so that guessing is expensive. Modern password hashing functions designed to be costly in memory as well as time extend this idea further.

The book also discusses secure hardware, such as smart cards and security modules, and the human procedures that surround secrets: backups, key recovery, splitting a key among several people so that no single person can use or lose it, and destroying keys reliably when they are no longer needed. It points out that the hardest part of storing secrets is often not technical but organisational: deciding who should have access, and arranging for recovery without creating a back door.

A reader interested in digital assets will find this the most immediately practical part of the book. Seed phrases written on paper, hardware wallets, multi-signature schemes and threshold signatures are all answers to the problem the book describes. Each trades one risk for another. The book gives the reader the vocabulary to compare them honestly.

Key idea twelve: time, standards and experts

Two smaller themes complete the book's view of practice. The first is time. Many security mechanisms rely on clocks: certificates expire, tickets have lifetimes, logs carry timestamps, and replay protection may use time. Yet clocks on ordinary computers can be wrong, can drift, and can be changed by an attacker who controls the network time service or the machine itself. The book treats the clock as a security component that needs its own analysis. It discusses how to obtain reliable time and how to design systems that degrade safely when time cannot be trusted. Few books on cryptography give this subject any attention at all.

The second theme is the institutional setting of security work. Standards are necessary for interoperability, but they are often produced by committees whose compromises add options and complexity, and they can be slow to correct. Patents have shaped which algorithms were used and when. Experts are needed, but expertise is uneven, and claims of security from vendors are often unsupported. The authors advise readers to rely on well-reviewed public designs, to be wary of proprietary claims, and to get independent review for anything important. They also counsel humility: even experts make mistakes, which is why public analysis over time is the main source of confidence.

These themes connect to the book's larger argument. Security is not a property that a designer can add at the end. It emerges from many decisions, technical and organisational, made over a system's life. The cryptographer's job is to make the cryptographic part reliable and to help everyone else see where the real risks lie.

Key idea thirteen: one key, one job

A principle that runs quietly through the whole book deserves a chapter of its own: a key should be used for exactly one purpose. The same secret should not encrypt in one place and authenticate in another, should not serve both directions of a conversation, and should not be shared between two different protocols. When many keys are needed, they should be derived from a master secret through a careful one-way process, each labelled for its role.

The reason is that cryptographic components are analysed on the assumption that their keys are independent and used only as intended. When one key is used in two roles, the outputs of one role may help an attacker against the other. A classic illustration is a system that uses the same key for a block cipher in encryption mode and for a message authentication code built from the same cipher. Under some constructions, values revealed by one function can be fed into the other to forge or decrypt. Each component is secure alone. Their combination under a shared key is not.

A household analogy makes the point. A family that uses one key for the front door, the car, the safe and the office has made life convenient and made every lock as weak as the most exposed one. If the car key is copied at a garage, the safe is open. Separate keys limit the damage of any one loss. In cryptography, derivation makes separate keys cheap: one shared secret can yield as many independent keys as needed, with no extra burden on the people involved.

The same principle explains other recommendations in the book. Separate keys for each direction of a secure channel prevent an attacker from reflecting a message back to its sender and having it accepted. Separate keys for each session limit how much data any single key protects, and so limit what an attacker gains by breaking one. Regular key replacement, built into long sessions, keeps counters from running out and gives a fresh start if an earlier key has leaked. A related property, often called forward secrecy, ensures that stealing a long-term key today does not unlock past sessions, because each session's key was derived from values that were then erased.

This idea is easy to neglect because it rarely shows up in algorithm descriptions. It lives in the glue between components. That is exactly why the book stresses it. Much of security engineering, in the authors' presentation, is the careful design of glue.

For readers of the blockchain books on this bay, the same principle appears in hierarchical deterministic wallets, which derive many addresses and keys from a single seed so that different accounts and purposes do not share keys. It appears too in the separation between keys used to sign transactions and keys used to encrypt backups. Where these separations have been neglected, losses have followed.

The tradition around it

What it answers

The most direct predecessor of this book is Schneier's own Applied Cryptography, published in 1994 with a second edition in 1996. That book was a catalogue. It described a great many algorithms and protocols with source code and became a standard reference for programmers. Its very breadth turned out to be a problem: readers took algorithms from it and assembled systems without understanding how to combine them safely. Schneier later wrote that the systems built from his first book were often insecure despite using good algorithms. Practical Cryptography, and then Cryptography Engineering, were in part a correction. They narrowed the menu and taught composition and implementation.

Schneier's Secrets and Lies, published in 2000, made the broader argument for general readers: that security is a process, not a product, and that cryptography alone cannot provide it. Cryptography Engineering applies that insight to the engineer's daily work.

Its neighbours on this bay

Introduction to Modern Cryptography by Katz and Lindell is the natural partner. It teaches what security means and how to prove that primitives and schemes achieve it. Cryptography Engineering assumes such primitives exist and teaches how not to waste their strength. Read together, they cover the distance from definition to deployment. The two books sometimes differ in emphasis, especially on questions such as the order of encryption and authentication, and comparing their reasoning is instructive.

Serious Cryptography by Jean-Philippe Aumasson is a more recent practical book that covers many of the same tools with updated recommendations, including authenticated encryption modes and modern elliptic curves. It makes a good second reading after this one. The Handbook of Applied Cryptography by Menezes, van Oorschot and Vanstone remains a reference for precise descriptions of algorithms and standards.

For history, The Code Book by Simon Singh and Crypto by Steven Levy describe how strong cryptography became available to engineers in the first place. Levy's account of the export-control era explains why some of the protocols this book criticises were designed with deliberately weakened options, a legacy that later caused real attacks.

For the systems on this bay, Mastering Bitcoin and Mastering Ethereum describe wallets, transactions and contracts in engineering detail. Bitcoin and Cryptocurrency Technologies discusses key storage and the risks of custody. The Infinite Machine, The Cryptopians, Number Go Up and Going Infinite tell stories in which failures of key management, operational security and protocol design led to large losses. Reading them after this book, one sees the book's warnings played out at scale.

What came after

Since 2010 the field has moved in directions that both confirm and update the book. Authenticated encryption became the norm. Protocols such as TLS 1.3 removed many options, in keeping with the book's preference for simplicity. Constant-time implementation became standard practice in serious libraries. Large-scale attacks on side channels in processors, revealed from 2018 onward, showed that hardware itself can leak secrets across boundaries that software assumed were safe. Post-quantum cryptography began to enter real protocols. Throughout, the book's principles have served as a stable guide, even where its specific recommendations have aged.

Questions and criticisms

Specific advice ages

Any book that recommends particular algorithms and parameters will date, and this one is no exception. Some of its choices reflect the state of practice around 2010. Today's engineers would generally reach for authenticated encryption modes, modern elliptic curve methods, and newer password hashing functions, and would follow current guidance on key sizes. A reader should treat the book's specific recommendations as examples of reasoning, check them against current guidance, and keep the reasoning.

Opinion and disagreement

The book is openly opinionated. That is a virtue for teaching, since a clear recommendation is easier to learn from than a neutral survey. But some of its positions are contested. Its view on the ordering of encryption and authentication differs from what most of the field came to prefer, and its treatment of some topics reflects the authors' particular designs. A reader should notice where the book argues for a choice and evaluate the argument, not simply accept the conclusion.

Limited formal grounding

From the side of theory, the book can be criticised for relying on informal reasoning where proofs exist. Its arguments for the security of its designs are careful but not formal, and some subtle issues that formal analysis would catch can be missed by informal reasoning. The authors' answer, implicit in the book, is that most failures in practice lie outside what formal proofs cover. Both points are true, which is why the book should be read alongside a rigorous text.

The changing threat landscape

The book was written before several developments that changed the practice of security engineering: large-scale state surveillance programmes revealed in 2013, including evidence of interference with standards; the rise of cloud computing, in which keys and data live on infrastructure owned by others; the spread of smartphones with hardware-backed key storage; and the shift to memory-safe languages for security-critical code. Its principles cover these situations well, but a reader must do the work of applying them.

People at the edge of the system

The book says clearly that users are part of the system and often its weakest link, but its own designs are mostly built for software talking to software. It has less to say about the design of interfaces that ordinary people can use safely: how to present warnings that are not ignored, how to make key verification something people actually do, how to make recovery possible without creating new attacks. Research on usable security has grown a great deal since the book appeared and has shown that many failures blamed on careless users are failures of design. The messaging apps that brought end-to-end encryption to billions of people succeeded in part because they hid almost all key management from users, a choice with its own trade-offs. A reader should pair the book's principles with that later work, and should ask of any design not only whether it is correct but whether a tired, distracted person will use it correctly.

What has held up

The book's central claims have held up very well. The weakest link idea, the hostility to complexity, the insistence on conservative margins, the focus on implementation and randomness, and the scepticism about PKI have all been confirmed by a decade and more of incidents. Much of what has changed in practice since 2010 moved in the direction the book recommended: fewer options, simpler protocols, more careful implementations, and stronger defaults.

Why it is on this shelf

This book is here because it teaches what most failures in practice are about. A reader can understand cryptography perfectly in theory and still build a system that loses everything, through a weak random number generator, a leaked key, a careless protocol or an unchecked error. The book trains attention on those places.

For a reader of technology, it is a model of engineering judgement under adversarial conditions: how to choose, how to simplify, how to anticipate failure. For a reader of digital money and blockchain systems, it is directly practical. Wallets, exchanges and protocols that hold value are the systems it was written for, and the history of losses in that field is largely a history of ignoring its advice. For a reader of economics, its discussions of trust, incentives and institutions show security as a matter of costs and behaviour as much as mathematics.

For a reader of Vedanta and Jyotish, there is a further point of contact. Those traditions teach that knowledge must be joined to right practice, and that a sound principle wrongly applied gives no fruit. This book makes the same claim in an engineering setting. Mathematically perfect tools give no protection unless they are applied with discipline, humility and attention to detail. We keep it for that lesson as much as for its technical content.

How to read it

First, the attitude

Begin with the opening material on the context of cryptography and the security mindset. Read it slowly and more than once. Its ideas will be applied throughout, and they matter more than any single algorithm.

Then follow the secure channel

Read the first technical part in order, through the design of the secure channel. Keep a sheet of paper on which you write each requirement the channel must meet and the mechanism that meets it. When you finish, try to break your own summary: find a requirement without a mechanism, or two mechanisms that interfere. This exercise teaches the method better than any reading.

Read the implementation and randomness chapters closely

These are where most real systems break. Read them with code nearby. If you program, look at how a well-regarded open-source cryptography library handles the same issues, such as constant-time comparison, zeroing secrets, or seeding its random generator. Compare what you find with the book's advice.

Then the protocol work

Read the protocol material with a pencil. As each version of the key negotiation protocol appears, try to find the attack before the authors show it. You will often fail at first. That is the point: the skill grows with practice.

Finish with key management

Read the chapters on clocks, key servers, PKI and storing secrets as a set. They are less technical and can be read faster, but they contain some of the book's most durable insight. Relate each to a system you use: a web browser, a messaging app, a hardware wallet, a company login.

What to skip at first

On a first pass, you may skim the detailed number theory and the specific parameter recommendations. Return to the number theory when you need it, ideally alongside a more mathematical text. Treat the parameter recommendations as dated and look up current guidance when you need actual values.

Pace and exercises

Plan on six to eight weeks at a steady pace, longer if you do the exercises, which you should. The exercises that ask for security reviews of real products and news stories are especially valuable. Write a short review each week of some system you encounter.

A good review has a fixed shape. Name the assets the system protects. Name the likely attackers and what they want. List the places where the system could fail, starting with the cheapest for an attacker. Say which failures matter most and what you would change first. Keep each review to a single page. After a few weeks you will find that you notice weak links in ordinary products without trying, which is the habit the book most wants to build.

What to read next

From this bay, read Introduction to Modern Cryptography by Katz and Lindell to put the primitives on firm ground. Read Serious Cryptography for updated practical recommendations. Then read Bitcoin and Cryptocurrency Technologies and Mastering Bitcoin to apply what you have learned to systems that hold real value, and one of the narrative books, such as The Cryptopians or Number Go Up, to see what happens when these lessons are ignored.

Questions to carry

  • In a system you use daily, what is the weakest link, and is it cryptographic at all?
  • How does designing against an intelligent adversary differ from designing against random failure?
  • Why does adding options to a protocol so often weaken it?
  • When is a larger security margin worth its cost, and when is it not?
  • What must a secure channel guarantee beyond confidentiality?
  • Why is the order of encryption and authentication important, and what has practice settled on since the book appeared?
  • How can a program that produces correct outputs still leak secrets?
  • How would you tell whether a random number generator in a product is good enough for keys?
  • Why must raw RSA and raw Diffie-Hellman never be used directly?
  • What makes protocols with several parties and sessions so hard to get right?
  • Who decides which certificate authorities your browser trusts, and what would happen if one were compromised?
  • What are the trade-offs between storing a key in software, in hardware and in human memory?
  • How do salting and stretching change the economics of password guessing?
  • Which of the book's specific recommendations have aged, and which principles have not?

Words to know

  • Weakest link: The principle that a system's security is limited by its least secure component, which attackers will target.
  • Threat model: A statement of who the attackers are, what they can do and what they want.
  • Security level: The approximate amount of work, often expressed as a power of two, that an attacker needs to break a system.
  • Block cipher: A keyed function that encrypts fixed-size blocks of data, such as AES.
  • Mode of operation: A method for using a block cipher to encrypt messages of arbitrary length.
  • Initialisation vector: A value, often random or unique, used at the start of encryption so that identical messages give different ciphertexts.
  • Message authentication code: A short tag computed with a secret key that lets the receiver detect any change to a message.
  • Authenticated encryption: An encryption method that provides both confidentiality and integrity in one construction.
  • Secure channel: A protected connection between two parties that keeps messages secret, unaltered, in order and free of replays.
  • Replay attack: An attack in which a valid message is recorded and sent again later.
  • Side channel: Information leaked through timing, power use, cache behaviour or similar physical effects rather than through outputs.
  • Constant-time code: Code whose running time and memory access pattern do not depend on secret values.
  • Entropy: A measure of unpredictability; the raw material for cryptographic randomness.
  • Fortuna: A random number generator design by Ferguson and Schneier that uses multiple entropy pools to reseed safely without estimating entropy.
  • Reseeding: Refreshing a random generator's internal state with new unpredictable input.
  • Key negotiation: A protocol by which parties establish a shared secret key, usually with authentication.
  • Small subgroup attack: An attack in which malformed values force a Diffie-Hellman exchange into a small set of possible results.
  • Padding scheme: A structured, often randomised, encoding applied before an RSA operation to make it secure.
  • Public-key infrastructure: The system of certificates and authorities that binds public keys to identities.
  • Certificate authority: An organisation that signs certificates vouching that a public key belongs to a named party.
  • Revocation: The process of declaring a certificate invalid before its expiry, for example after a key is compromised.
  • Salt: A random value combined with a password before hashing so that identical passwords give different stored values.
  • Key stretching: Deliberately making password processing slow to raise the cost of guessing.
  • Security through obscurity: Relying on the secrecy of a design rather than of keys; generally regarded as unsound.

A note on this edition

This is a study edition written for this shelf in our own words. It is a companion to Cryptography Engineering by Ferguson, Schneier and Kohno, not a substitute for it. It explains the book's principles and main ideas, adds context and later developments, and suggests a way to read it. It does not reproduce the book's text, designs, specific recommendations in detail or exercises.

The book itself is in copyright. It is clear, practical and honest about difficulty, and it is worth getting from a library or a bookshop and reading with a pencil and, ideally, some code nearby. Where we mention facts beyond the book, they are general and widely known; where we were unsure of a detail, we have left it out.

Terms from this book with their own page: Entropy, Block cipher

More from “Cryptography, blockchain and crypto”

The whole section →