scrypt: A new key derivation function Doing our best to thwart TLAs armed with ASICs Colin Percival Tarsnap cperciva@tarsnap.com May 9, 2009 Colin Percival Tarsnap cperciva@tarsnap.com scrypt: A new key derivation function scrypt: A new key derivation function Making bcrypt obsolete Colin Percival Tarsnap cperciva@tarsnap.com May 9, 2009 Colin Percival Tarsnap cperciva@tarsnap.com scrypt: A new key derivation function scrypt: A new key derivation function Are you sure your SSH keys are safe? Colin Percival Tarsnap cperciva@tarsnap.com May 9, 2009 Colin Percival Tarsnap cperciva@tarsnap.com scrypt: A new key derivation function What are key derivation functions? You have a password. You want a generate a derived key from that password. Verifying passwords for user authentication. Encrypting or signing files. In most situations where passwords are used, they are passed to a key derivation function first. In most situations where key derivation functions aren’t used, they should be! Examples of key derivation functions: DES CRYPT [R. Morris, 1979] MD5 CRYPT [P. H. Kamp, 1994] bcrypt [N. Provos and D. Mazières, 1999] PBKDF2 [B. Kaliski, 2000] MD5 (not really a key derivation function!) Colin Percival Tarsnap cperciva@tarsnap.com scrypt: A new key derivation function Security of key derivation functions Attack model: Assume that the attacker can mount an offline attack. Attacker has access to /etc/master.passwd and wants to find the users’ passwords. Attacker has an encrypted file and wants to decrypt it. For all reasonable key derivation functions, the only feasible attack is to repeatedly try passwords until you find the right one. This is called a “brute force” attack. If it takes twice as long to check if a password is correct, it will take twice as long to find the right password. . . . as long as the attacker is using the same software as you. Colin Percival Tarsnap cperciva@tarsnap.com scrypt: A new key derivation function Hardware-based brute force attacks CREDIT: Randall Munroe / xkcd.com Colin Percival Tarsnap cperciva@tarsnap.com scrypt: A new key derivation function Hardware-based brute force attacks Some organizations have the resources to design and fabricate custom password-cracking integrated circuits. The US National Security Agency The UK Government Communications Headquarters? The Communications Security Establishment of Canada? The Chinese government? Organized crime? The Electronic Frontier Foundation? Using ASICs, it is possible to pack many copies of a cryptographic circuit onto a single piece of silicon. Moore’s law: Every 18–24 months, a new generation of semiconductor manufacturing processes makes CPUs faster. . . . password-cracking ASICs get faster AND can fit more copies of a password-cracking circuit. Colin Percival Tarsnap cperciva@tarsnap.com scrypt: A new key derivation function Hardware brute-force attack cost The cost of a hardware brute-force attack is meaured in dollar-seconds. Password cracking is embarrassingly parallel, so if you use twice as much hardware you can crack the key in half the time. Cost of ASICs ≍ size of ASICs. A strong key derivation function is one which can only be computed by using a large circuit for a long time. J. Kelsey, B. Schneier, C. Hall and D. Wagner, 1998: Use “32-bit arithmetic and moderately large amounts of RAM”. An example of a “moderately large amount of RAM”: 1 kB. If we use a ridiculously large amount of RAM, hardware attacks will be even more expensive. Colin Percival Tarsnap cperciva@tarsnap.com scrypt: A new key derivation function Memory-hard algorithms Definition A memory-hard algorithm on a Random Access Machine is an algorithm which uses  S(n) space and T (n) operations, where S(n) ∈ Ω T (n)1−ǫ . Conceptually, a memory-hard algorithm is one which comes close to using the largest amount of storage possible for an algorithm with the same running time. . . . and consequently the largest circuit area possible. The HEKS key derivation algorithm [A.G. Reinhold, 1999] is memory-hard, but it isn’t very secure, since it can be effectively parallelized. Secure key derivation functions require a large die area and a lot of time to compute. Colin Percival Tarsnap cperciva@tarsnap.com scrypt: A new key derivation function Sequential memory-hard functions Definition A sequential memory-hard function is a function which (a) can be computed by a memory-hard algorithm on a Random Access Machine in T (n) operations; and (b) cannot be computed on a Parallel Random Access Machine with S ∗ (n) processors and S ∗ (n) space in expected time T ∗ (n) where S ∗ (n)T ∗ (n) = O(T (n)2−x ) for any x > 0. Not only do memory-hard functions require lots of storage, but they also cannot be parallelized efficiently. If we can find a key derivation function which is sequential memory-hard, it should be very secure against hardware attack. Colin Percival Tarsnap cperciva@tarsnap.com scrypt: A new key derivation function ROMix Algorithm (ROMix) Given a hash function H, an input B, and an integer parameter N, compute Vi = H i (B) 0≤i