aboutsummaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2014-11-20 11:27:38 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-27 06:35:01 +0000
commitfb9a216dd677d97f3d6963f668a9b84d349ef339 (patch)
treec4e10b1c96927f4a64c6f5a53844b80fc23baf5f /firmware
parent59c29202d2d67b97f587152b5457ed89f7430a77 (diff)
downloadvboot_reference-fb9a216dd677d97f3d6963f668a9b84d349ef339.tar.gz
vboot2: Add host lib support for bare hash keys
And use them in the other vboot2 unit tests. BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: I0c3590649a0acf792e41e295ca4279ccba17a41f Reviewed-on: https://chromium-review.googlesource.com/231345 Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/2lib/2packed_key2.c22
-rw-r--r--firmware/2lib/include/2return_codes.h9
2 files changed, 21 insertions, 10 deletions
diff --git a/firmware/2lib/2packed_key2.c b/firmware/2lib/2packed_key2.c
index 91000dfb..a67664bb 100644
--- a/firmware/2lib/2packed_key2.c
+++ b/firmware/2lib/2packed_key2.c
@@ -81,20 +81,22 @@ int vb2_unpack_key2(struct vb2_public_key *key,
return VB2_ERROR_UNPACK_KEY_STRUCT_VERSION;
/* Copy key algorithms */
- key->sig_alg = pkey->sig_alg;
- sig_size = vb2_rsa_sig_size(key->sig_alg);
- if (!sig_size)
- return VB2_ERROR_UNPACK_KEY_SIG_ALGORITHM;
-
key->hash_alg = pkey->hash_alg;
if (!vb2_digest_size(key->hash_alg))
return VB2_ERROR_UNPACK_KEY_HASH_ALGORITHM;
- rv = vb2_unpack_key2_data(key,
- (const uint8_t *)pkey + pkey->key_offset,
- pkey->key_size);
- if (rv)
- return rv;
+ key->sig_alg = pkey->sig_alg;
+ if (key->sig_alg != VB2_SIG_NONE) {
+ sig_size = vb2_rsa_sig_size(key->sig_alg);
+ if (!sig_size)
+ return VB2_ERROR_UNPACK_KEY_SIG_ALGORITHM;
+ rv = vb2_unpack_key2_data(
+ key,
+ (const uint8_t *)pkey + pkey->key_offset,
+ pkey->key_size);
+ if (rv)
+ return rv;
+ }
/* Key description */
if (pkey->c.desc_size)
diff --git a/firmware/2lib/include/2return_codes.h b/firmware/2lib/include/2return_codes.h
index deae9140..f12f2c12 100644
--- a/firmware/2lib/include/2return_codes.h
+++ b/firmware/2lib/include/2return_codes.h
@@ -510,6 +510,9 @@ enum vb2_return_code {
/* Unable to set description in vb2_private_key_unpack() */
VB2_ERROR_UNPACK_PRIVATE_KEY_DESC,
+ /* Bad bare hash key in vb2_private_key_unpack() */
+ VB2_ERROR_UNPACK_PRIVATE_KEY_HASH,
+
/* Unable to create RSA data in vb2_private_key_write() */
VB2_ERROR_PRIVATE_KEY_WRITE_RSA,
@@ -519,6 +522,9 @@ enum vb2_return_code {
/* Unable to write file in vb2_private_key_write() */
VB2_ERROR_PRIVATE_KEY_WRITE_FILE,
+ /* Bad algorithm in vb2_private_key_hash() */
+ VB2_ERROR_PRIVATE_KEY_HASH,
+
/* Unable to determine key size in vb2_public_key_alloc() */
VB2_ERROR_PUBLIC_KEY_ALLOC_SIZE,
@@ -549,6 +555,9 @@ enum vb2_return_code {
/* Unable to determine key size in vb2_public_key_pack() */
VB2_ERROR_PUBLIC_KEY_PACK_SIZE,
+ /* Bad hash algorithm in vb2_publc_key_hash() */
+ VB2_ERROR_PUBLIC_KEY_HASH,
+
/**********************************************************************
* Highest non-zero error generated inside vboot library. Note that
* error codes passed through vboot when it calls external APIs may