autoupdate: Set the hash_sha256 in devserver (omaha) response
The new changes in update_engine requires the new hex based sha256 hash sent by
omaha to be checked. But, currently in devserver we only sent base64 ecndoed
sha256. This CL adds hash_sha256 in the package tag of the response by
calculating the hex based sha256 hash of the payload.
BUG=chromium:821599
TEST=cros flash
Change-Id: I4449d90513db2dcd1424a6693ec7ce172135d689
Reviewed-on: https://chromium-review.googlesource.com/961586
Commit-Ready: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
(cherry picked from commit 9e2adaebc313a9d73b19519c69fe90f3c58e33d8)
Reviewed-on: https://chromium-review.googlesource.com/998656
Reviewed-by: Keith Haddow <haddowk@chromium.org>
Commit-Queue: Keith Haddow <haddowk@chromium.org>
Tested-by: Keith Haddow <haddowk@chromium.org>
diff --git a/autoupdate_lib.py b/autoupdate_lib.py
index eb39412..23091e9 100644
--- a/autoupdate_lib.py
+++ b/autoupdate_lib.py
@@ -6,6 +6,8 @@
from __future__ import print_function
+import base64
+import binascii
import datetime
import os
import time
@@ -63,7 +65,7 @@
<manifest version="999999.0.0">
<packages>
<package hash="%(sha1)s" name="%(filename)s" size="%(size)s"
- required="true"/>
+ hash_sha256="%(hash_sha256)s" required="true"/>
</packages>
<actions>
<action event="postinstall"
@@ -174,6 +176,8 @@
response_values = GetCommonResponseValues()
response_values['sha1'] = sha1
response_values['sha256'] = sha256
+ # sha256 is base64 encoded, encode it to hex.
+ response_values['hash_sha256'] = binascii.hexlify(base64.b64decode(sha256))
response_values['size'] = size
response_values['url'] = url
(codebase, filename) = os.path.split(url)