Files
system76-coreboot/src/lib/metadata_hash.c
Elyes HAOUAS 0322bc5ed8 src: Remove unused <cbmem.h>
Change-Id: I2279e2d7e6255a88953b2485c1f1a3b51a72c65e
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50182
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2021-02-03 08:56:35 +00:00

27 lines
887 B
C

/* SPDX-License-Identifier: GPL-2.0-only */
/* This file is part of the coreboot project. */
#include <assert.h>
#include <metadata_hash.h>
#include <symbols.h>
__attribute__((used, section(".metadata_hash_anchor")))
static struct metadata_hash_anchor metadata_hash_anchor = {
/* This is the only place in all of coreboot where we actually need to use this. */
.magic = DO_NOT_USE_METADATA_HASH_ANCHOR_MAGIC_DO_NOT_USE,
.cbfs_hash = { .algo = CONFIG_CBFS_HASH_ALGO }
};
struct vb2_hash *metadata_hash_get(void)
{
return &metadata_hash_anchor.cbfs_hash;
}
vb2_error_t metadata_hash_verify_fmap(const void *fmap_buffer, size_t fmap_size)
{
struct vb2_hash hash = { .algo = metadata_hash_anchor.cbfs_hash.algo };
memcpy(hash.raw, metadata_hash_anchor_fmap_hash(&metadata_hash_anchor),
vb2_digest_size(hash.algo));
return vb2_hash_verify(fmap_buffer, fmap_size, &hash);
}