[bitbake-devel] [PATCH v3 1/7] bitbake: utils.py: add sha384_file and sha512_file functions
Jean-Marie LEMETAYER
jean-marie.lemetayer at savoirfairelinux.com
Wed Nov 20 09:34:06 UTC 2019
This commit adds the "sha384_file" and "sha512_file" functions in order
to check the integrity of the downloaded npm packages as npm now use
subresource integrity:
https://w3c.github.io/webappsec-subresource-integrity
Signed-off-by: Jean-Marie LEMETAYER <jean-marie.lemetayer at savoirfairelinux.com>
---
lib/bb/utils.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index d035949b..34152855 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -562,6 +562,30 @@ def sha1_file(filename):
s.update(line)
return s.hexdigest()
+def sha384_file(filename):
+ """
+ Return the hex string representation of the SHA384 checksum of the filename
+ """
+ import hashlib
+
+ s = hashlib.sha384()
+ with open(filename, "rb") as f:
+ for line in f:
+ s.update(line)
+ return s.hexdigest()
+
+def sha512_file(filename):
+ """
+ Return the hex string representation of the SHA512 checksum of the filename
+ """
+ import hashlib
+
+ s = hashlib.sha512()
+ with open(filename, "rb") as f:
+ for line in f:
+ s.update(line)
+ return s.hexdigest()
+
def preserved_envvars_exported():
"""Variables which are taken from the environment and placed in and exported
from the metadata"""
--
2.20.1
More information about the bitbake-devel
mailing list