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