Yarrow algorithm explained

The Yarrow algorithm is a family of cryptographic pseudorandom number generators (CSPRNG) devised by John Kelsey, Bruce Schneier, and Niels Ferguson and published in 1999. The Yarrow algorithm is explicitly unpatented, royalty-free, and open source; no license is required to use it. An improved design from Ferguson and Schneier, Fortuna, is described in their book, Practical Cryptography

Yarrow was used in FreeBSD, but is now superseded by Fortuna.[1] Yarrow was also incorporated in iOS[2] and macOS for their /dev/random devices, but Apple has switched to Fortuna since 2020 Q1.[3]

Name

The name Yarrow alludes to the use of the yarrow plant in the random generating process of I Ching divination. Since the Xia dynasty (to), Chinese have used yarrow stalks for divination. Fortunetellers divide a set of 50 yarrow stalks into piles and use modular arithmetic recursively to generate two bits of random information[4] that have a non-uniform distribution.

Principles

Yarrow's main design principles are: resistance to attacks, easy use by programmers with no cryptography background, and reusability of existing building blocks. The former widely used designs such as ANSI X9.17 and RSAREF 2.0 PRNG have loopholes that provide attack opportunities under some circumstances. Some of them are not designed with real-world attacks in mind. Yarrow also aims to provide easy integration, to enable system designers with little knowledge of PRNG functionality.[5]

Design

Components

The design of Yarrow consists of four major components: an entropy accumulator, a reseed mechanism, a generation mechanism, and reseed control.

Yarrow accumulates entropy into two pools: the fast pool, which provides frequent reseeds of the key to keep the duration of key compromises as short as possible; the slow pool, which provides rare but conservative reseeds of the key. This makes sure that the reseed is secured even when the entropy estimates are very optimistic.

The reseed mechanism connects the entropy accumulator to the generating mechanism. Reseeding from the fast pool uses the current key and the hash of all inputs to the fast pool since startup to generate a new key; reseeding from the slow pool behaves similarly, except it also uses the hash of all inputs to the slow pool to generate a new key. Both of the reseedings reset the entropy estimation of the fast pool to zero, but the last one also sets the estimation of the slow pool to zero. The reseeding mechanism updates the key constantly, so that even if the key of pool information is known to the attacker before the reseed, they will be unknown to the attacker after the reseed.

The reseed control component is leveraging between frequent reseeding, which is desirable but might allow iterative guessing attacks, and infrequent reseeding, which compromises more information for an attacker who has the key. Yarrow uses the fast pool to reseed whenever the source passes some threshold values, and uses the slow pool to reseed whenever at least two of its sources pass some other threshold value. The specific threshold values are mentioned in the Yarrow-160 section.

Design philosophy

Yarrow assumes that enough entropy can be accumulated to ensure that the PRNG is in an unpredictable state. The designers accumulate entropy in the purpose of keeping the ability to recover the PRNG even when the key is compromised. Similar design philosophy is taken by RSAREF, DSA and ANSI X9.17 PRNGs.

Yarrow-160

The Yarrow uses two important algorithms: a one-way hash function and a block cipher. The specific description and properties are listed in the table below.

Algorithms Properties What Yarrow-160 uses
Hash function h(x)
  • One-way
  • m-bit output size
  • collision intractable

Given input values, the

Mselections of output values are uniformly distributed over m-bit values. SHA-1 hash function
Block cipher E
  • Resistant to known-plaintext and chosen-plaintext attacks

High statistical performance of outputs when given highly patterned inputs.

Three-key Triple DES

Generation

Yarrow-160 uses three-key Triple DES in counter mode to generate outputs. is an n-bit counter value; is the key. In order to generate the next output block, Yarrow follows the functions shown here.

Yarrow keeps count of the output block, because once the key is compromised, the leak of the old output before the compromised one can be stopped immediately. Once some system security parameter is reached, the algorithm will generate bits of PRNG output and use them as the new key. In Yarrow-160, the system security parameter is set to be 10, which means . The parameter is intentionally set to be low to minimize the number of outputs that can be backtracked.

Reseed

The reseed mechanism of Yarrow-160 uses SHA-1 and Triple DES as the hash function and block cipher. The details steps are in the original paper.

Implementation of Yarrow-160

Yarrow-160 has been implemented in Java, and for FreeBSD. The examples can be found in "An implementation of the Yarrow PRNG for FreeBSD"[6] by Mark R. V. Murray.

Pros and cons of Yarrow

Pros

Cons

External links

Notes and References

  1. Web site: [base] Revision 284959]. Svnweb.freebsd.org. 18 October 2016.
  2. Web site: iOS Security . October 2012 . Apple.com . 2016-10-21.
  3. Web site: Random number generation. 2020-10-26. Apple Support. en.
  4. Web site: Questions & Answers about Yarrow . Schneier . Bruce . Bruce Schneier . Schneier on Security . 2016-02-15 . The fortuneteller would divide a set of 50 stalks into piles, then repeatedly use modular arithmetic to generate two random bits..
  5. Kelsey . John . Schneier . Bruce . Ferguson . Niels . Yarrow-160: Notes on the Design and Analysis of the Yarrow Cryptographic Pseudorandom Number Generator . Sixth Annual Workshop on Selected Areas in Cryptography . August 1999 . 1758 . 13–33 . 10.1007/3-540-46513-8_2 .
  6. Web site: An implementation of the Yarrow PRNG for FreeBSD. 18 October 2016.
  7. Web site: Stevens . Marc . Bursztein . Elie . Karpman . Pierre . Albertini . Ange . Markov . Yarik . 2017-02-23 . SHAttered . 2017-04-27 . SHAttered.
  8. Web site: Fortuna Cryptographically Secure PRNG : AN0806 - Application Note . Silabs.com . 2016-10-21.
  9. Web site: Fortuna – A Cryptographically Secure Pseudo Random Number Generator – CodeProject. citadel. 4 March 2004 . 18 October 2016.