aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIlias Apalodimas <ilias.apalodimas@linaro.org>2021-04-22 14:32:14 +0300
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2021-04-24 06:53:40 +0200
commit6fe8b4a39d0ddb6cf6de35ab3e1b522ec0824575 (patch)
treebe0078e375702347f3589ace93b464de6b337f7a /lib
parenta07ee3c198df216b3111c1dc8f79410e3b0bcc4b (diff)
downloadu-boot-6fe8b4a39d0ddb6cf6de35ab3e1b522ec0824575.zip
u-boot-6fe8b4a39d0ddb6cf6de35ab3e1b522ec0824575.tar.gz
u-boot-6fe8b4a39d0ddb6cf6de35ab3e1b522ec0824575.tar.bz2
efi_loader: simplify tcg2_create_digest()
Bumping the digest list count, for all supported algorithms, can be calculated outside of the individual switch statements. So let's do that for every loop iteration instead and simplify the code a bit. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_tcg2.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index d5eca68..94e8f22 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -535,30 +535,27 @@ static efi_status_t tcg2_create_digest(const u8 *input, u32 length,
sha1_starts(&ctx);
sha1_update(&ctx, input, length);
sha1_finish(&ctx, final);
- digest_list->count++;
break;
case TPM2_ALG_SHA256:
sha256_starts(&ctx_256);
sha256_update(&ctx_256, input, length);
sha256_finish(&ctx_256, final);
- digest_list->count++;
break;
case TPM2_ALG_SHA384:
sha384_starts(&ctx_512);
sha384_update(&ctx_512, input, length);
sha384_finish(&ctx_512, final);
- digest_list->count++;
break;
case TPM2_ALG_SHA512:
sha512_starts(&ctx_512);
sha512_update(&ctx_512, input, length);
sha512_finish(&ctx_512, final);
- digest_list->count++;
break;
default:
EFI_PRINT("Unsupported algorithm %x\n", hash_alg);
return EFI_INVALID_PARAMETER;
}
+ digest_list->count++;
digest_list->digests[i].hash_alg = hash_alg;
memcpy(&digest_list->digests[i].digest, final, (u32)alg_to_len(hash_alg));
}