Reading from /dev/urandom in binary instead of text mode.
This fixes a bug when avbtool is run with Python 3.
This change is still compatible with Python 2.
Bug: 154739970
Bug: 151336743
Test: external/avb$ atest :all
Test: ./aftltool_integration_test.py
Change-Id: I3d500e2b5c0b6becc741f2c247fbc4ba1a000228
diff --git a/avbtool.py b/avbtool.py
index 85f8ca1..aaf0a46 100755
--- a/avbtool.py
+++ b/avbtool.py
@@ -3610,7 +3610,7 @@
# size as the hash size. Don't populate a random salt if this
# descriptor is being created to use a persistent digest on device.
hash_size = digest_size
- with open('/dev/urandom') as f:
+ with open('/dev/urandom', 'rb') as f:
salt = f.read(hash_size)
else:
salt = b''