Modify release tools to replace certs in MMAC files.
Added support to perform a string replace of specified
dev keys with release keys when using the release tool
scripts.
Change-Id: Id0e945b0d62720c41f5ca9764a00de4bcdecaab4
Signed-off-by: rpcraig <rpcraig@tycho.ncsc.mil>
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 58582ba..a3217dd 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -954,3 +954,18 @@
return PARTITION_TYPES[fstab[mount_point].fs_type], fstab[mount_point].device
else:
return None
+
+
+def ParseCertificate(data):
+ """Parse a PEM-format certificate."""
+ cert = []
+ save = False
+ for line in data.split("\n"):
+ if "--END CERTIFICATE--" in line:
+ break
+ if save:
+ cert.append(line)
+ if "--BEGIN CERTIFICATE--" in line:
+ save = True
+ cert = "".join(cert).decode('base64')
+ return cert