From 75cce6c89961e567fc9d8f9918abf7eb8080af02 Mon Sep 17 00:00:00 2001 From: Kevin Balthaser Date: Mon, 4 Dec 2023 08:55:17 -0500 Subject: [PATCH] Move SHA256 of empty string to constant. --- packages/opal-common/opal_common/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/opal-common/opal_common/utils.py b/packages/opal-common/opal_common/utils.py index 4da85533..d39fa309 100644 --- a/packages/opal-common/opal_common/utils.py +++ b/packages/opal-common/opal_common/utils.py @@ -79,6 +79,9 @@ def getSignatureKey(key, dateStamp, regionName, serviceName): kSigning = sign(kService, "aws4_request") return kSigning + # SHA256 of empty string. This is needed when S3 request payload is empty. + SHA256_EMPTY = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + t = datetime.utcnow() amzdate = t.strftime("%Y%m%dT%H%M%SZ") datestamp = t.strftime("%Y%m%d") @@ -138,7 +141,7 @@ def getSignatureKey(key, dateStamp, regionName, serviceName): return { "x-amz-date": amzdate, - "x-amz-content-sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "x-amz-content-sha256": SHA256_EMPTY, "Authorization": authorization_header, }