host: Deduplicate keyblock creation in host_keyblock

Extract a shared alloc_keyblock() helper to allocate the keyblock
header, copy the packed data key, initialize the signature descriptors,
and compute the SHA-512 keyblock hash for both vb2_create_keyblock()
and vb2_create_keyblock_external().

BUG=b:124141368
TEST=make runtests
BRANCH=none
TAG=agy
CONV=2efa1fd4-161e-459c-95ac-49f549088989

Change-Id: I0345e13a7cdd40dcc4c4ff9f99f636a904df7bdc
Signed-off-by: Jakub Czapiga <czapiga@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/8497137
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: chromeos-auto-retry@chromeos-bot.iam.gserviceaccount.com <chromeos-auto-retry@chromeos-bot.iam.gserviceaccount.com>
1 file changed