Replace usage of md5 with sha256 for generation of mojo app ids.

Before we start adding more uses of mojo app ids we should use
to a non-broken hash function. :)

What was holding me back before was I wasn't aware of us having an
incremental hash api other than base/md5.h (others in base only operate
on the full input data), however it turns out that the crypto/ library
has one in crypto/secure_hash.h.

R=abarth@chromium.org
BUG=

Review URL: https://codereview.chromium.org/868253006
This commit is contained in:
Eric Seidel 2015-01-29 12:59:48 -08:00
parent 084737b0fb
commit c5416c52ce
2 changed files with 11 additions and 2 deletions

View File

@ -44,10 +44,10 @@ def compute_path_to_app_id_map(paths, cache, cache_mtime):
for path in paths:
app_id = get_cached_app_id(path, cache, cache_mtime)
if not app_id:
logging.info('md5sum %s' % path)
logging.info('sha256sum %s' % path)
# Example output:
# f82a3551478a9a0e010adccd675053b9 png_viewer.mojo
output = subprocess.check_output(['md5sum', path])
output = subprocess.check_output(['sha256sum', path])
app_id = output.strip().split()[0]
path_to_app_id_map[path] = app_id
return path_to_app_id_map
@ -78,8 +78,13 @@ def main():
' to match expected dlopen names from mojo_shell\'s NetworkLoader.')
parser.add_argument('links_dir', type=str)
parser.add_argument('build_dir', type=str)
parser.add_argument('-f', '--force', action='store_true')
parser.add_argument('-v', '--verbose', action='store_true')
args = parser.parse_args()
if args.verbose:
logging.getLogger().setLevel(logging.INFO)
if not os.path.isdir(args.links_dir):
logging.fatal('links_dir: %s is not a directory' % args.links_dir)
sys.exit(1)
@ -87,6 +92,8 @@ def main():
# Some of the .so files are 100s of megabytes. Cache the md5s to save time.
cache_path = os.path.join(args.build_dir, '.app_id_cache')
cache, cache_mtime = read_app_id_cache(cache_path)
if args.force:
cache_mtime = None
paths = library_paths(args.build_dir)
path_to_app_id_map = compute_path_to_app_id_map(list(paths),

View File

@ -194,6 +194,8 @@ class SkyDebugger(object):
self.pids['sky_command_port'] = args.command_port
if is_android:
subprocess.check_call([ADB_PATH, 'root'])
# We could make installing conditional on an argument.
apk_path = os.path.join(self.paths.build_dir, 'apks',
ANDROID_APK_NAME)