Evaluating Cryptosystems
Presented as “Hacking Cryptosystems” in the Hackers & Threats track at RSA 2002.
Paul Kocher
President & Chief Scientist,
Cryptography Research, Inc.
www.cryptography.com
607 Market St., 5th Floor, San Francisco, CA 94105
© 2002 Cryptography Research, Inc. All rights reserved. The Cryp tography Research logo is a trademark
of Cryptography Research, Inc. All trademarks are the property of their respective owners. The
information contained in this presentation is provided without a ny guarantee or warrantee whatsoever.
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 1
About Cryptography Research
n Specialize in high-risk systems
n Highly technical; Hands-on + theoretical expertise
n Crypto, risk management, hardware, networking…
n Industries: Financial, content, networking, wireless
n Consulting, licensing & research
n Consulting: Evaluation, implementation, design
n Licensing: Tamper-resistance/DPA technologies
n Research: Real attacks & countermeasures
n Emphasis on applied work
n Practical, reliable solutions to real problems
n Systems designed by CRI engineers protected >$40B in 2001
n Many well-known clients…
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 2
1
Why this talk?
n Most cryptosystems are designed to stop
the wrong kind of attacker.
n Uncreative adversaries with big budgets
- not -
n Creative adversaries with small budgets
Talk describes how reviewers and attackers actually
break cryptosystems – Not academic attacks…
Purpose: Help designers/purchasers prevent problems.
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 3
© 2002 by Paul Kocher
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 4
2
Attacker ROI
n Attackers invest resources in pursuit of a goal.
n Choose approaches to maximize reward / cost
n Best attack: Yields system master keys, repeatable, low
NRE, no countermeasure, resellable, undetectable…
n Only “lowest hanging fruit” matters
n Example: Key size is almost always irrelevant
n 64 bits: ~290,000 GHz-years Equally
n 128 bits: ~5 trillion trillion GHz-years impractical
n 40 bits: ~6.4 GHz-days Easily breakable
(Assumes 1000 clocks per key test. Times are average; max = 2X.)
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 5
Design vs. Attack
Designer Attacker
Goal: Create & demonstrate Goal: Demonstrate & exploit
security insecurity
Responsible for entire system Must find just one problem
n Must understand n Can ignore many aspects
everything of system
n Complexity = bad n Helped by complexity
n Highly-constrained n Few constraints
Resources should be Resources commensurate with
commensurate with risk opportunity
n Whose risk…? n Money, pride, thrill… [next]
High-assurance cryptosystems typically involve
>10X more effort on validation than implementation.
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 6
3
Mounting an Attack
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 7
Homework
n Target’s security objectives
n Comparative analysis
n Compare with similar or sketch a design
n Anything missing? extraneous? confusing?
Business
n How have similar systems failed?
Network
n Implementation details Protocol
Crypto
n Design compromises Software
n Unsolvable problems? OS
n Underlying technologies CPU
n Understand all aspects / levels of the system Microcode
Logic cell
Transistor
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 8
4
Security Perimeters
n Designers should isolate keys & critical components
n Putting “all your eggs in one basket” is actually good
n Risking all your eggs in many baskets is dangerous.
n Fewer critical components means they can be tested better.
n Exploring security perimeters
n Is the inside of the perimeter too complex?
n Is there a meaningful perimeter at all?
n Example: Typical Windows PC is too complex to secure internally.
n Excessive complexity, no compartmentalization…
n What can cross the perimeter?
n APIs, network protocols, chip I/Fs, control/audit/backup data…
n Analyze single points of failure (inside & outside) [next]
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 9
Single Points of Failure
n Identify SPFs
n Focus on poorly-compartmentalized portions
n Are any critical portions overly complex?
n What non-critical portions can compromise security?
n Examples of typical SPFs
n RNGs, operating systems, data backup systems
n Configuration & key data storage
n Software (O/S, BIOS, drivers, application... Major problem!)
n Hardware (computational errors, information leaks…)
n Revocation / validation / risk management systems
n Threshold cryptography is not a complete solution
n Usually removes operational SPFs, but not design SPFs
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 10
5
4 Characteristics of Most Flaws
n SPFs that bypass the crypto algorithms
n Buffer overflows, alg negotiation, scripting…
n Interactions between components
n memcmp timing, bignum limits, system()…
n Complexity
n Design effort for k-flaw system >(LOC)2
n Inexperienced engineers
n Incorrect assumptions, reliance on obscurity,
failure to document/review, overconfidence…
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 11
Where to Begin
n No script for how to test a crypto product
n Standardized reviews will catch standardized attacks
n Looking for a problem doesn’t guarantee finding it
n Reviewer must thoroughly understand each attack
n Not an alternative for reviewer knowledge
n Major problem for Common Criteria, ITSEC, FIPS, etc…
n Lists will always be incomplete
n Can also be tediously long
n Difficult to organize
n Attacks combine multiple areas
n No standard taxonomy, etc.
n Most attacks are not applicable to most products
n But reviews need to start somewhere
n Evaluation standards can provide a structured framework
n Attack lists can help jog reviewer’s memory (at least!)
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 12
6
Collecting Information
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 13
Tools
n General
n Crypto toolkits (Crypto++, CryptoLib, etc.)
n Statistical toolkits (custom)
n Bignum libraries (NTL for Lattice Reduct.)
n Compiler, system analysis tools, debugger (SoftIce)
n Network traffic recorder (tcpdump)
n Attack checklists
n Brute force / disaster recovery
n FPGA board / CPU farm
n Password dictionaries
n Hard drive imaging tools
n Password recovery tools/services (AccessData…)
n Tamper Resistance
n DPA workstation
n Oscilloscope
n X-ray
n Probe station, microscopes, e-beam, FIB
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 14
7
Collecting Information
n Published specifications
n Open literature
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 15
Collecting Information
n Published specifications
n Open literature
n Network & bus I/O
Recording traffic using a SCSI bus analyzer.
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 16
8
Collecting Information
n Published specifications
n Open literature
n Network & bus I/O
n Timing
n Power consumption
Hardware for monitoring I/O,
timing, and power data from
smart cards & other crypto chips
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 17
Collecting Information
n Published specifications
n Open literature
n Network & bus I/O
n Timing
n Power consumption
n Defective computations
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 18
9
Collecting Information
n Published specifications
n Open literature
n Network & bus I/O
n Timing
n Power consumption
n Defective computations
n Error messages
n Failure modes
Given a valid RSA signature:
S = M d mod n, where n = p · q
and a defective signature S' that is
correct mod p and incorrect mod q,
then:
p = GCD(n, S – S')
q = p / n.
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 19
Collecting Information
n Published specifications
n Open literature
n Network & bus I/O
n Timing
n Power consumption
n Defective computations
n Error messages
n Failure modes
n Disk/memory contents
n Swap files
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 20
10
Collecting Information
n Published specifications
n Open literature
n Network & bus I/O
n Timing
n Power consumption
n Defective computations
n Error messages
n Failure modes
n Disk/memory contents
n Swap files
n Chip imaging
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 21
Collecting Information
n Published specifications
n Open literature RNG_CreateContext()
n Network & bus I/O (seconds, microseconds) = time of day;
n Timing /* Time elapsed since 1970 */
n Power consumption
n Defective computations pid = process ID;
n Error messages ppid = parent process ID;
n Failure modes
a = mklcpr(microseconds);
n Disk/memory contents
n Swap files b = mklcpr(pid + seconds + (ppid << 12));
n Chip imaging seed = MD5(a, b);
n RNG seed data
mklcpr(x) /* not cryptographically significant;
shown for completeness */
return ((0xDEECE66D*x+0x2BBB62DC) >>1);
Netscape 1.1 seeding process (pseudocode)
From: Goldberg, Ian and Wagner, David, “Randomness and the
Netscape Browser”, Dr. Dobbs Journal, Jan. 1996
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 22
11
Collecting Information
n Published specifications
n Open literature
n Network & bus I/O
n Timing
n Power consumption
n Defective computations
n Error messages
n Failure modes
n Disk/memory contents
n Swap files
n Chip imaging
n RNG seed data
n Backup / restore
n Traffic analysis
n Illegal & questionable activities
n Dumpster diving
n Inside jobs
n Social engineering
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 23
Code Reviews
n Exhaustive checking = Pain in the %#@$.
n Time consuming & tedious
n Many engineers write awful code
n Spaghetti code is often easier to rewrite than to review
n Working from a disassembly is slower
n Language issues
n Not all variables have English names
n Documentation / comments often poor
n Alternative: Hypothesis + sanity testing of critical areas/SPFs
n Key generation, usage, storage
n RNG (including seeding)
n Error handling
n Debug/test modes
n Memory handling (swap, alloc, paging…)
n Common bugs (buffer overflows, etc.)
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 24
12
Key Areas
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 25
Algorithms
n Don’t bother with internals of good algorithms
n Useful research, but not productive for a product eval.
n Most proprietary ciphers are bad…
n Inexperienced designers often unhelpful, paranoid, overconfident
n Cryptanalysis is tedious – other attacks may be easier…
n Pushing the envelope is dangerous
n Quick tests
n Is the ciphertext obviously nonrandom?
n Compressable? Biased frequency distribution?
n Is the scheme published?
n Broken?
n Who designed it?
n Public key schemes
n Based on a (believed) “hard” problem?
n Is security truly equivalent? Is problem truly hard?
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 26
13
Good Algorithms Used Badly
n Implementation errors
n DES S tables, PGPDisk CAST bug…
n Computation errors
n Induce with buffer overflows…
n Stream cipher key reuse
n Marginal key sizes (e.g., DES)
n Time/memory tradeoff
n Same ciphertext under many keys
n Poor key management
n Nonrandom / insecure derivation?
n Is the correct value used as the key?
n Are keys stored securely?
n On-line Unix/Windows servers?
n Are keys managed securely?
n Revocation, etc?
n Poor modes of operation
n 3DES with internal CBC
n DES MACs
n ECB
This image shows the result of
encrypting a bitmap of the
RSA 2002 conference brochure
using triple DES in ECB mode.
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 27
Certificational Weaknesses
n Many weaknesses aren’t practical to exploit
n Algorithms and hardware usually fail gradually
n Most attacks are improved incrementally
n Protocols and software usually fail catastrophically
n Huge problem…
n Difficult to view problems objectively
n Imperfections aren’t necessarily fatal
n No useful security system has zero risk
n But… if numerous holes found, there are probably more
n Certificational weaknesses =
avenues for further analysis
n Fixable problems à sign of poor design
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 28
14
Protocol Analysis
n Many approaches (intuitive to formal).
n Example:
n Describe what is supposed to happen
n E.g.: Client & server negotiate a strong shared key or fail.
n On three (big) pieces of paper:
• Chart the protocol flow
n Include every message that can be sent
n Error messages, optional messages, etc.
‚ List what can be discovered about each cryptographic value.
n Each crypto step generally reveals something new.
n List everything (helps catch unintended interactions)
ƒ Diagram the state machine of each participant
n Include negotiated options, failure states, crypto, etc.
n Reconcile possible end states against objectives.
n Check for missing “free” functionality, excessive complexity…
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 29
Common Protocol Weak Spots
n Algorithm negotiation
n Version negotiation (backward + forward)
n Man-in-the-middle
n Message replay (within a session, multiple sessions)
n Message forwarding & impersonation
n E.g.: A connects to B, who connects to C pretending to be A.
n Certificate handling & validation (or lack thereof)
n Out -of-sequence messages
n Error handling reveals information
n Denial of service
n Timing analysis
n Excessive complexity or lack of defined state machine
n Improper or inadequate use of hash functions
n Inefficiencies (round trips…)
n Redundant information
n Management/debug functions (code upgrades, etc.)
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 30
15
Contact Information
For more information, or to discuss how Cryptography
Research can help with a security problem:
Paul Kocher
[email protected]
Tel: 415.397.0123
www.cryptography.com
We’re hiring! If you are technically strong and want to work on
challenging crypto and security problems, please send a resume!
Cryptography Research, Inc: L e a d e r I n A d v a n c e d C r y p t o s y s t e m s™ 31
16