Files
OpenCellular/tests/vb2_convert_structs.h
Randall Spangler d274a2e953 vboot2: Add vb2_unpack_key2() and unit tests
This unpacks new-style packed keys.

For now, it can also handle old-style packed keys by passing them to
the old unpacking function.  Once we've switched over to new-style
keys in the signing scripts, we'll remove the old format to save code
size.

Also added is a test library which converts from old to new struct
formats.  That should eventually get absorbed into futility, and the
test keys directory should have both old and new format packed keys in
it.

BUG=chromium:423882
BRANCH=none
TEST=VBOOT2=1 make runtests

Change-Id: I0fe31f124781d1ea1efedab65dcd6130bfca18dd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225490
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-29 22:23:49 +00:00

37 lines
1.0 KiB
C

/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
*/
#ifndef VBOOT_REFERENCE_VB2_CONVERT_STRUCTS_H_
#define VBOOT_REFERENCE_VB2_CONVERT_STRUCTS_H_
#include "2struct.h"
/**
* Round up a size to a multiple of 32 bits (4 bytes).
*/
static __inline const uint32_t roundup32(uint32_t v)
{
return (v + 3) & ~3;
}
/**
* Convert a packed key from vboot data format to vboot2 data format.
*
* Intended for use by unit tests. Does NOT validate the original struct
* contents, just copies them.
*
* @param key Packed key in vboot1 format
* @param desc Description of packed key
* @param out_size Size of the newly allocated buffer
* @return a newly allocated buffer with the converted key. Caller is
* responsible for freeing this buffer.
*/
struct vb2_packed_key2 *vb2_convert_packed_key2(
const struct vb2_packed_key *key,
const char *desc, uint32_t *out_size);
#endif /* VBOOT_REFERENCE_VB2_CONVERT_STRUCTS_H_ */