SEBA-666 use sha-256 instead of sha-1
Change-Id: I0046d900084f19f604f4208b0219c0ee35889df5
diff --git a/xos/coreapi/backupprocessor.py b/xos/coreapi/backupprocessor.py
index b270275..c8cbff6 100644
--- a/xos/coreapi/backupprocessor.py
+++ b/xos/coreapi/backupprocessor.py
@@ -52,13 +52,13 @@
raise Exception("Instrumented Failure: %s" % where)
def compute_checksum(self, fn):
- m = hashlib.sha1()
+ m = hashlib.sha256()
with open(fn, "rb") as f:
block = f.read(4096)
while block:
m.update(block)
block = f.read(4096)
- return "sha1:" + m.hexdigest()
+ return "sha256:" + m.hexdigest()
def try_models(self):
""" Returns True if django modeling is functional """
diff --git a/xos/coreapi/test_backupprocessor.py b/xos/coreapi/test_backupprocessor.py
index 70a9244..0e44f26 100644
--- a/xos/coreapi/test_backupprocessor.py
+++ b/xos/coreapi/test_backupprocessor.py
@@ -52,7 +52,7 @@
with open("/tmp/somefile", "w") as somefile:
somefile.write("test")
self.assertEqual(self.processor.compute_checksum("/tmp/somefile"),
- "sha1:da39a3ee5e6b4b0d3255bfef95601890afd80709")
+ "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
def test_try_models(self):
with patch("os.system") as os_system:
@@ -139,7 +139,7 @@
u'id': 3,
u'uuid': u'three',
u'file_details': {u'backend_filename': u'/var/run/xos/backup/local/mybackup',
- u'checksum': u'sha1:5eee38381388b6f30efdd5c5c6f067dbf32c0bb3',
+ u'checksum': u'sha256:35bafb1ce99aef3ab068afbaabae8f21fd9b9f02d3a9442e364fa92c0b3eeef0',
u'uri': u'file:///var/run/xos/backup/local/mybackup',
u'name': u'mybackup',
u'id': 7}}
diff --git a/xos/coreapi/xos_filetransfer_api.py b/xos/coreapi/xos_filetransfer_api.py
index bf632d3..4109540 100644
--- a/xos/coreapi/xos_filetransfer_api.py
+++ b/xos/coreapi/xos_filetransfer_api.py
@@ -57,7 +57,7 @@
def Upload(self, request_iterator, context):
backend_file = None
try:
- hasher = hashlib.sha1()
+ hasher = hashlib.sha256()
chunks_received = 0
bytes_received = 0
for chunk in request_iterator:
@@ -79,7 +79,7 @@
response.status = response.SUCCESS
response.chunks_received = chunks_received
response.bytes_received = bytes_received
- response.checksum = "sha1:" + hasher.hexdigest()
+ response.checksum = "sha256:" + hasher.hexdigest()
return response
finally: