From 89f20340d5a4c14ab76d3612cd33fff8894602ec Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Thu, 1 Oct 2015 15:54:04 +0200 Subject: cbfstool: Add support for hashes as file metadata They allow optimizing a verification of a whole CBFS image by only dealing with the headers (assuming you choose to trust the hash algorithm(s)). The format allows for multiple hashes for a single file, and cbfstool can handle them, but right now it can't generate such headers. Loosely based on Sol's work in http://review.coreboot.org/#/c/10147/, but using the compatible file attribute format. vboot is now a hard dependency of the build process, but we import it into the tree for quite a while now. Change-Id: I9f14f30537d676ce209ad612e7327c6f4810b313 Signed-off-by: Patrick Georgi Reviewed-on: http://review.coreboot.org/11767 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- util/cbfstool/cbfs_image.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'util/cbfstool/cbfs_image.h') diff --git a/util/cbfstool/cbfs_image.h b/util/cbfstool/cbfs_image.h index baceb51373a2..f6029761777c 100644 --- a/util/cbfstool/cbfs_image.h +++ b/util/cbfstool/cbfs_image.h @@ -36,6 +36,10 @@ struct cbfs_image { * enum comp_algo if it's supported, or a number < 0 otherwise. */ int cbfs_parse_comp_algo(const char *name); +/* Given the string name of a hash algorithm, return the corresponding + * id if it's supported, or a number < 0 otherwise. */ +int cbfs_parse_hash_algo(const char *name); + /* Given a pointer, serialize the header from host-native byte format * to cbfs format, i.e. big-endian. */ void cbfs_put_header(void *dest, const struct cbfs_header *header); @@ -184,4 +188,10 @@ struct cbfs_file_attribute *cbfs_file_next_attr(struct cbfs_file *file, struct cbfs_file_attribute *cbfs_add_file_attr(struct cbfs_file *header, uint32_t tag, uint32_t size); + +/* Adds an extended attribute to header, containing a hash of buffer's data of + * the type specified by hash_type. + * Returns 0 on success, -1 on error. */ +int cbfs_add_file_hash(struct cbfs_file *header, struct buffer *buffer, + enum vb2_hash_algorithm hash_type); #endif -- cgit v1.2.3