mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
vboot2: be consistent in use of sig_algorithm vs sig_alg in vboot2 structs
Previously, we had a mix of sig_algorithm and sig_alg member names, and it was hard to remember which struct used which variant. Prefer sig_alg because of the 80-column limit. Same with hash_alg vs. hash_algorithm BUG=chromium:423882 BRANCH=none TEST=VBOOT2=1 make runtests Change-Id: Ifbb60f3172549e29efc0fb1f7f693efa51eb7cc3 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226943 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
6b5b8f65d5
commit
6300a6439e
@@ -56,12 +56,12 @@ int vb2_unpack_key2(struct vb2_public_key *key,
|
||||
return VB2_ERROR_UNPACK_KEY_STRUCT_VERSION;
|
||||
|
||||
/* Copy key algorithms */
|
||||
key->sig_alg = pkey->sig_algorithm;
|
||||
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_algorithm;
|
||||
key->hash_alg = pkey->hash_alg;
|
||||
if (!vb2_digest_size(key->hash_alg))
|
||||
return VB2_ERROR_UNPACK_KEY_HASH_ALGORITHM;
|
||||
|
||||
|
||||
@@ -368,14 +368,14 @@ struct vb2_packed_key2 {
|
||||
uint32_t key_size;
|
||||
|
||||
/* Signature algorithm used by the key (enum vb2_signature_algorithm) */
|
||||
uint16_t sig_algorithm;
|
||||
uint16_t sig_alg;
|
||||
|
||||
/*
|
||||
* Hash digest algorithm used with the key (enum vb2_hash_algorithm).
|
||||
* This is explicitly specified as part of the key to prevent use of a
|
||||
* strong key with a weak hash.
|
||||
*/
|
||||
uint16_t hash_algorithm;
|
||||
uint16_t hash_alg;
|
||||
|
||||
/* Key version */
|
||||
uint32_t key_version;
|
||||
@@ -413,10 +413,10 @@ struct vb2_signature2 {
|
||||
uint32_t data_size;
|
||||
|
||||
/* Signature algorithm used (enum vb2_signature_algorithm) */
|
||||
uint16_t sig_algorithm;
|
||||
uint16_t sig_alg;
|
||||
|
||||
/* Hash digest algorithm used (enum vb2_hash_algorithm) */
|
||||
uint16_t hash_algorithm;
|
||||
uint16_t hash_alg;
|
||||
|
||||
/*
|
||||
* GUID of key used to generate this signature. This allows the
|
||||
@@ -538,7 +538,7 @@ struct vb2_fw_preamble2 {
|
||||
* Hash algorithm used (must be same for all entries) (enum
|
||||
* vb2_hash_algorithm).
|
||||
*/
|
||||
uint16_t hash_algorithm;
|
||||
uint16_t hash_alg;
|
||||
|
||||
/* Size of each hash entry, in bytes */
|
||||
uint16_t hash_entry_size;
|
||||
|
||||
@@ -147,14 +147,14 @@ static void test_unpack_key2(const VbPublicKey *orig_key)
|
||||
free(key2);
|
||||
|
||||
key2 = vb2_convert_packed_key2(key1, "Test key", &size);
|
||||
key2->sig_algorithm = VB2_SIG_INVALID;
|
||||
key2->sig_alg = VB2_SIG_INVALID;
|
||||
TEST_EQ(vb2_unpack_key2(&pubk, (uint8_t *)key2, size),
|
||||
VB2_ERROR_UNPACK_KEY_SIG_ALGORITHM,
|
||||
"vb2_unpack_key2() bad sig algorithm");
|
||||
free(key2);
|
||||
|
||||
key2 = vb2_convert_packed_key2(key1, "Test key", &size);
|
||||
key2->hash_algorithm = VB2_HASH_INVALID;
|
||||
key2->hash_alg = VB2_HASH_INVALID;
|
||||
TEST_EQ(vb2_unpack_key2(&pubk, (uint8_t *)key2, size),
|
||||
VB2_ERROR_UNPACK_KEY_HASH_ALGORITHM,
|
||||
"vb2_unpack_key2() bad hash algorithm");
|
||||
|
||||
@@ -33,8 +33,8 @@ struct vb2_packed_key2 *vb2_convert_packed_key2(
|
||||
|
||||
/* Copy/initialize fields */
|
||||
k2.key_version = key->key_version;
|
||||
k2.sig_algorithm = vb2_crypto_to_signature(key->algorithm);
|
||||
k2.hash_algorithm = vb2_crypto_to_hash(key->algorithm);
|
||||
k2.sig_alg = vb2_crypto_to_signature(key->algorithm);
|
||||
k2.hash_alg = vb2_crypto_to_hash(key->algorithm);
|
||||
/* TODO: fill in a non-zero GUID */
|
||||
|
||||
/* Allocate the new buffer */
|
||||
|
||||
Reference in New Issue
Block a user