From 698f7074dc644ef0b83c80d6cbc142dba4460798 Mon Sep 17 00:00:00 2001 From: Matt Perry Date: Wed, 4 Nov 2015 14:50:04 -0500 Subject: [PATCH] Ensure seedRandom doesn't throw if /dev/urandom doesn't exist. --- .../src/flutter/sky/packages/flx/lib/signing.dart | 14 ++++++++++---- engine/src/flutter/sky/packages/flx/pubspec.yaml | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/sky/packages/flx/lib/signing.dart b/engine/src/flutter/sky/packages/flx/lib/signing.dart index 0aca7944e3..eb0ef7d63f 100644 --- a/engine/src/flutter/sky/packages/flx/lib/signing.dart +++ b/engine/src/flutter/sky/packages/flx/lib/signing.dart @@ -30,10 +30,16 @@ class CipherParameters { // Disclaimer: I don't really understand why we need 2 parameters for // cipher's API. Future seedRandom() async { - RandomAccessFile file = await new File("/dev/urandom").open(); - Uint8List key = new Uint8List.fromList(await file.read(16)); - Uint8List iv = new Uint8List.fromList(await file.read(16)); - _initRandom(key, iv); + try { + RandomAccessFile file = await new File("/dev/urandom").open(); + Uint8List key = new Uint8List.fromList(await file.read(16)); + 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; diff --git a/engine/src/flutter/sky/packages/flx/pubspec.yaml b/engine/src/flutter/sky/packages/flx/pubspec.yaml index 34d48d8788..2f5843b3a8 100644 --- a/engine/src/flutter/sky/packages/flx/pubspec.yaml +++ b/engine/src/flutter/sky/packages/flx/pubspec.yaml @@ -1,5 +1,5 @@ name: flx -version: 0.0.7 +version: 0.0.8 author: Flutter Authors description: Library for dealing with Flutter bundle (.flx) files homepage: http://flutter.io