
HexOctet format is used by openssl for FORMAT:HEX,OCT property in x509 certificates. Add a helper function to extract the integer numbers in HEX,OCT format to pass to openssl directly.
Signed-off-by: Manorit Chawdhry m-chawdhry@ti.com --- tools/dtoc/fdt_util.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py index f1f70568cfef..d51dbf5633d0 100644 --- a/tools/dtoc/fdt_util.py +++ b/tools/dtoc/fdt_util.py @@ -100,6 +100,26 @@ def EnsureCompiled(fname, tmpdir=None, capture_stderr=False): command.run(dtc, *args, capture_stderr=capture_stderr) return dtb_output
+def GetHexOctet(node, propname, default=None): + """Get an integer from a property in hex octet form required by openssl + + Args: + node: Node object to read from + propname: property name to read + default: Default value to use if the node/property do not exist + + Returns: + Integer value read as a String in Hex Octet Form + """ + prop = node.props.get(propname) + if not isinstance(prop.value, list) or len(prop.value) != 2: + value = GetInt(node, propname) + elif isinstance(prop.value, list) and len(prop.value) == 2: + value = GetInt64(node, propname) + + hex_value = '%x' % (value) + return ('0' * (len(hex_value) & 1)) + hex_value + def GetInt(node, propname, default=None): """Get an integer from a property