Make SHA library accessible to calling firmware

And add a vb2_digest_buffer() call which produces the hash of a buffer
all in a single function call.  That function actually already
existed, but was in a unit test file rather than in the library
itself.  It's a small function, so adding it won't increase the size
of the library significantly - or at all, on platforms which compile
with -ffunction-sections.

This allows coreboot to reuse this SHA library for hashing CBFS
entries and file data.  All it has to do is #define
NEED_VB2_SHA_LIBRARY and then #include "vb2_api.h".

BUG=chromium:482652
BRANCH=none
TEST=make -j runtests

Change-Id: Ice2d0929324b58b2665f3989b5b887225f6ef61e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/269523
Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
Randall Spangler
2015-05-05 16:06:50 -07:00
committed by ChromeOS Commit Bot
parent 7dd3bd0fcf
commit f81fce91bf
4 changed files with 83 additions and 56 deletions

View File

@@ -6,6 +6,10 @@
/* APIs between calling firmware and vboot_reference
*
* DO NOT INCLUDE THE HEADERS BELOW DIRECTLY! ONLY INCLUDE THIS FILE!
*
* Using vb2api.h as the single point of contact between calling firmware and
* vboot allows subsequent refactoring of vboot (renaming of headers, etc.)
* without churning other projects' source code.
*/
#ifndef VBOOT_VB2_API_H_
@@ -14,6 +18,11 @@
/* Standard APIs */
#include "../2lib/include/2api.h"
/* SHA library */
#ifdef NEED_VB2_SHA_LIBRARY
#include "../2lib/include/2sha.h"
#endif
/*
* Coreboot should not need access to vboot2 internals. But right now it does.
* At least this forces it to do so through a relatively narrow hole so vboot2