Commit e337b1d2 authored by Matt Perry's avatar Matt Perry

Ensure seedRandom doesn't throw if /dev/urandom doesn't exist.

parent d74a7517
...@@ -30,10 +30,16 @@ class CipherParameters { ...@@ -30,10 +30,16 @@ class CipherParameters {
// Disclaimer: I don't really understand why we need 2 parameters for // Disclaimer: I don't really understand why we need 2 parameters for
// cipher's API. // cipher's API.
Future seedRandom() async { Future seedRandom() async {
RandomAccessFile file = await new File("/dev/urandom").open(); try {
Uint8List key = new Uint8List.fromList(await file.read(16)); RandomAccessFile file = await new File("/dev/urandom").open();
Uint8List iv = new Uint8List.fromList(await file.read(16)); Uint8List key = new Uint8List.fromList(await file.read(16));
_initRandom(key, iv); Uint8List iv = new Uint8List.fromList(await file.read(16));
_initRandom(key, iv);
} on FileSystemException {
// TODO(mpcomplete): need an entropy source on Windows. We might get this
// for free from Dart itself soon.
print("Warning: Failed to seed random number generator. No /dev/urandom.");
}
} }
SecureRandom _random; SecureRandom _random;
......
name: flx name: flx
version: 0.0.7 version: 0.0.8
author: Flutter Authors <flutter-dev@googlegroups.com> author: Flutter Authors <flutter-dev@googlegroups.com>
description: Library for dealing with Flutter bundle (.flx) files description: Library for dealing with Flutter bundle (.flx) files
homepage: http://flutter.io homepage: http://flutter.io
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment