Randomly Failed! The State of Randomness in Current Java Implementations

Kai Michaelis, Christopher Meyer, and J¨ org Schwenk

Horst G¨ ortz Institute for IT-Security, Ruhr-University Bochum

{

kai.michaelis,christopher.meyer,joerg.schwenk

}

@rub.de

Abstract.

This paper investigates the Randomness of several Java Run- time Lib rar ies by ins pect ing the in teg rat ed Pse udo Ran dom Num ber Genera tors. Signiﬁ can t wea knesse s in diﬀere nt libraries includ ing An- droid, are uncovered.

1 In tr odu ct io n

With a market share of 33-50% [1], [2], [3] Android is currently the most popular mobile OS. Each of the 331-400 million sold devices (cf. [3]) is able to run Java applications written in Java. Java provides interfaces for diﬀerent Pseudo Ran- dom Number Generators (PRNGs), such as

SecureRandom

, which is intended for use by cryptographic schemes. But, only the API is speciﬁed - each library imple men ts own algorithms . Desi gning secure and reliabl e PRNGs is a hard and complicated task [4], as well as implementing these algorithms correctly. One of the worst idea s is t o im plement own unproved PRNG constructs. This paper examines the quality of th e random numbers generated by common Java libraries. In detail, the PRNGs, intended for use in cryptographic environ- ments, of Apache Harmony

1

, GNU Classpath

2

, OpenJDK

3

and Bounc yCastle

4

are inspected. It is shown that the over-all entropy of the Android PRNG can be reduc ed to 64 bits. Bey ond this, mu ltiple weakn esses of entrop y collectors are re vealed. However, some of these weaknesses only occur under special conditions (e.g., unavailable

/dev/

{

u

}

random

device). We clearly point out that we are not going to discuss the quality of random numbers generated by PRNGs shipped with Operating Systems (OS). Discussions of OS provided (P)RNG facilities can be found a t e. g., [5] , [6 ], [7 ].

2 Re l at ed W or k

Problems related to weak pseudo random number generators (PRNGs) have been topic of several previously published papers. In 2012 Argyros and Kiayias

1

2

http://www.gnu.org/software/classpath/

3

http://openjdk.java.net/

4

http://www.bouncycastle.org/

E. Dawson (Ed.): RSA 2013, LNCS 7779, pp. 129–144, 2013. c

