class CommandTpm implements Tpm {

    static int parseNvramSizeFromNvInfoOutput(final String commandOutput) {
        // trim the ends and split on lines.
        String[] lines = commandOutput.trim().split("\\r?\\n");

        // search lines for the first "Size" line, which contains the # of bytes to
        // read at the location
        for (String line : lines) {
            if (line.startsWith("Size")) {
                String rawSizeValue = line.split(":")[1].trim();
                // The value after the ":" contains the decimal and hex values.
                // Parse out the decimal portion
                String decimalSizeStr = rawSizeValue.split(" ")[0];
                return Integer.parseInt(decimalSizeStr);
            }
        }

        throw new RuntimeException("Failed to find size from EC's NVRAM area");
    }

}