Which mobile OS's provide a primitive to generate crypto-quality randomness that applications can use?

On desktop systems, these features are pervasive. Unix provides /dev/urandom. Windows provides CryptGenRandom. Do mobile OS's provide something like this? Do they provide any support so that developers don't have to write their own code to collect entropy from multiple sources and combine it to get a seed? (That's something that's error-prone and non-trivial for developers, so I'm looking for support from the platform -- whether it's the OS, or libraries, or something else.)

I would welcome answers that specify a mobile OS, whether it does/does not provide this support, and if yes, what the interface for developers to use is.


iOS on iPhone provides entropy from all standard inputs like accelerometers, compass, radio baseband, as well as from certain parts of the circuitry which picks up interference at all levels. Random bits are available to app developers via the SecRandomCopyBytes() function.

I don't have info on other platforms.

  • This time you get the "what I would have said" +1.
    – user185
    Feb 15 '11 at 12:01
  • @Graham - it helped I just had dinner with 2 Apple security folks, and the guy who was in charge of iPhone hardware development on Sunday and it was one of the questions I asked them:-)
    – Rory Alsop
    Feb 15 '11 at 16:47
  • @Rory, thanks for the comment. I must confess I found your answer a bit ambiguous. Does iOS expose an easy-to-use interface to the developer to get crypto-quality random numbers? (e.g., by collecting all this entropy, combining it to get a good seed, running it through a crypto-quality PRNG, etc.) Or are you saying that all these sources of entropy are present on iOS, and a developer could write his/her own code to do all that? If iOS does provide it, do you know what interface developers can use to obtain crypto-quality random numbers?
    – D.W.
    Feb 15 '11 at 18:25
  • @D.W. I don't know the detail but I will go and ask and update my post when I know.
    – Rory Alsop
    Feb 15 '11 at 18:42
  • 2
    On iOS you use the SecRandomCopyBytes() function to get crypto-strong random numbers from /dev/random. You can't access /dev/random directly.
    – user185
    Feb 18 '11 at 10:29

Android provides java.util.SecureRandom in its Java-based API, which is supposed to be a cryptographically secure PRNG, feeding on whatever the base platform provides as source of robust alea. Android is based upon a Linux kernel, so chances are that there is a /dev/urandom of some kind.

Similarly, Nokia's Maemo and its successor MeeGo, being Linux-based, offer a /dev/urandom.


Blackberry OS provides net.rim.device.api.crypto.RandomSource to signed apps. It harvests randomness from various sources on the device, just like the iOS RNG. Note that the crypto package also contains various PRNG classes, which are not cryptographically random.

  • Device initialization requires the user to slam their fist into the keypad randomly for a while.
    – Incognito
    Feb 17 '11 at 21:48

To complete the picture: Silverlight and XNA both offer the usual .NET System.Security.Cryptography, which includes RNGCryptoServiceProvider. Therefore that class can be used on Windows Phone 7. The documentation says this offers cryptographically-strong randomness, but doesn't explain how this is ensured.


Symbian mobile OS also provides a crypto-quality RNG, as described here.

Thanks to John Kemp, who provided this information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.