diff options
Diffstat (limited to 'host/lib/include/host_misc.h')
-rw-r--r-- | host/lib/include/host_misc.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/host/lib/include/host_misc.h b/host/lib/include/host_misc.h index 1a59af54..96aba057 100644 --- a/host/lib/include/host_misc.h +++ b/host/lib/include/host_misc.h @@ -8,6 +8,8 @@ #ifndef VBOOT_REFERENCE_HOST_MISC_H_ #define VBOOT_REFERENCE_HOST_MISC_H_ +#include <stdbool.h> + #include "vboot_struct.h" #include "vboot_api.h" @@ -99,4 +101,25 @@ static inline const uint32_t roundup32(uint32_t v) */ uint32_t vb2_desc_size(const char *desc); +/** + * Parse byte from hex string. + * + * @param val Pointer to the value buffer + * @param str String to parse + * @return true on success, false otherwise. + * */ +bool parse_hex(uint8_t *val, const char *str); + + +/** + * Parse hash from string. + * + * @param buf Output buffer. Has to be at least `len` bytes long + * @param len Hash length in bytes + * @param str Hash string form. Has to be at least 2 * `len` long + * Whitespaces are ignored + * @return true on success, false otherwise. + */ +bool parse_hash(uint8_t *buf, size_t len, const char *str); + #endif /* VBOOT_REFERENCE_HOST_MISC_H_ */ |