Commit ee8f325b authored by Devon Carew's avatar Devon Carew

add timing info for flx creation

parent 0c05666e
...@@ -123,7 +123,7 @@ class RunCommand extends RunCommandBase { ...@@ -123,7 +123,7 @@ class RunCommand extends RunCommandBase {
debugPort: debugPort debugPort: debugPort
); );
printTrace('Finished start command.'); printTrace('Finished $name command.');
return result; return result;
} }
} }
......
...@@ -256,7 +256,7 @@ Future<int> build( ...@@ -256,7 +256,7 @@ Future<int> build(
Future<int> assemble({ Future<int> assemble({
Map manifestDescriptor: const {}, Map manifestDescriptor: const {},
ArchiveFile snapshotFile: null, ArchiveFile snapshotFile,
String assetBasePath: defaultAssetBasePath, String assetBasePath: defaultAssetBasePath,
String materialAssetBasePath: defaultMaterialAssetBasePath, String materialAssetBasePath: defaultMaterialAssetBasePath,
String outputPath: defaultFlxOutputPath, String outputPath: defaultFlxOutputPath,
...@@ -287,11 +287,15 @@ Future<int> assemble({ ...@@ -287,11 +287,15 @@ Future<int> assemble({
if (fontManifest != null) if (fontManifest != null)
archive.addFile(fontManifest); archive.addFile(fontManifest);
await CipherParameters.get().seedRandom(); printTrace('Calling CipherParameters.seedRandom().');
CipherParameters.get().seedRandom();
AsymmetricKeyPair keyPair = keyPairFromPrivateKeyFileSync(privateKeyPath); AsymmetricKeyPair keyPair = keyPairFromPrivateKeyFileSync(privateKeyPath);
printTrace('KeyPair from $privateKeyPath: $keyPair.');
printTrace('Encoding zip file.');
Uint8List zipBytes = new Uint8List.fromList(new ZipEncoder().encode(archive)); Uint8List zipBytes = new Uint8List.fromList(new ZipEncoder().encode(archive));
ensureDirectoryExists(outputPath); ensureDirectoryExists(outputPath);
printTrace('Creating flx at ${outputPath}.');
Bundle bundle = new Bundle.fromContent( Bundle bundle = new Bundle.fromContent(
path: outputPath, path: outputPath,
manifest: manifestDescriptor, manifest: manifestDescriptor,
......
...@@ -72,7 +72,7 @@ class Bundle { ...@@ -72,7 +72,7 @@ class Bundle {
this.path, this.path,
this.manifest, this.manifest,
contentBytes, contentBytes,
AsymmetricKeyPair keyPair: null AsymmetricKeyPair keyPair
}) : _contentBytes = contentBytes { }) : _contentBytes = contentBytes {
assert(path != null); assert(path != null);
assert(manifest != null); assert(manifest != null);
......
...@@ -20,6 +20,7 @@ class CipherParameters { ...@@ -20,6 +20,7 @@ class CipherParameters {
final String signerAlgorithm = 'SHA-256/ECDSA'; final String signerAlgorithm = 'SHA-256/ECDSA';
final String hashAlgorithm = 'SHA-256'; final String hashAlgorithm = 'SHA-256';
final ECDomainParameters domain = new ECDomainParameters('prime256v1'); final ECDomainParameters domain = new ECDomainParameters('prime256v1');
SecureRandom get random { SecureRandom get random {
if (_random == null) if (_random == null)
_initRandom(new Uint8List(16), new Uint8List(16)); _initRandom(new Uint8List(16), new Uint8List(16));
...@@ -29,12 +30,16 @@ class CipherParameters { ...@@ -29,12 +30,16 @@ class CipherParameters {
// Seeds our secure random number generator using data from /dev/urandom. // Seeds our secure random number generator using data from /dev/urandom.
// Disclaimer: I don't really understand why we need 2 parameters for // Disclaimer: I don't really understand why we need 2 parameters for
// pointycastle's API. // pointycastle's API.
Future seedRandom() async { void seedRandom() {
if (_random != null)
return;
try { try {
RandomAccessFile file = await new File("/dev/urandom").open(); RandomAccessFile file = new File("/dev/urandom").openSync();
Uint8List key = new Uint8List.fromList(await file.read(16)); Uint8List key = new Uint8List.fromList(file.readSync(16));
Uint8List iv = new Uint8List.fromList(await file.read(16)); Uint8List iv = new Uint8List.fromList(file.readSync(16));
_initRandom(key, iv); _initRandom(key, iv);
file.closeSync();
} on FileSystemException { } on FileSystemException {
// TODO(mpcomplete): need an entropy source on Windows. We might get this // TODO(mpcomplete): need an entropy source on Windows. We might get this
// for free from Dart itself soon. // for free from Dart itself soon.
......
...@@ -34,7 +34,7 @@ main() async { ...@@ -34,7 +34,7 @@ main() async {
// Set up a key generator. // Set up a key generator.
CipherParameters cipher = CipherParameters.get(); CipherParameters cipher = CipherParameters.get();
await cipher.seedRandom(); cipher.seedRandom();
ECKeyGeneratorParameters ecParams = new ECKeyGeneratorParameters(cipher.domain); ECKeyGeneratorParameters ecParams = new ECKeyGeneratorParameters(cipher.domain);
ParametersWithRandom<ECKeyGeneratorParameters> keyGeneratorParams = ParametersWithRandom<ECKeyGeneratorParameters> keyGeneratorParams =
new ParametersWithRandom<ECKeyGeneratorParameters>(ecParams, cipher.random); new ParametersWithRandom<ECKeyGeneratorParameters>(ecParams, cipher.random);
......
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