summaryrefslogtreecommitdiff
path: root/src/security/tpm
diff options
context:
space:
mode:
authorFrans Hendriks <fhendriks@eltan.com>2019-09-04 11:10:27 +0200
committerPatrick Georgi <pgeorgi@google.com>2019-09-06 15:32:10 +0000
commitaa771cb19f0ff1b02ac2e9732312b34bd2b2f0b3 (patch)
tree487dea60f9993d876532a451094ecac82f749658 /src/security/tpm
parentc162131d00c7f3b8827f9dd08754497c36884123 (diff)
downloadcoreboot-aa771cb19f0ff1b02ac2e9732312b34bd2b2f0b3.tar.xz
security/tpm/tss/tcg-2.0: Add support for algorithms
Function marshal_TPMT_HA() supports SHA-256 only. Add support for more algorithms. BUG=N/A TEST=Build binary and verified logging on Facebook FBG-1701 Change-Id: Ife8d44484c7a7cb717035e5ae0870bbee205661b Signed-off-by: Frans Hendriks <fhendriks@eltan.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/35276 Reviewed-by: Lance Zhao <lance.zhao@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/security/tpm')
-rw-r--r--src/security/tpm/tss/tcg-2.0/tss_marshaling.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/security/tpm/tss/tcg-2.0/tss_marshaling.c b/src/security/tpm/tss/tcg-2.0/tss_marshaling.c
index ec3cd8b4b2..1bf211a898 100644
--- a/src/security/tpm/tss/tcg-2.0/tss_marshaling.c
+++ b/src/security/tpm/tss/tcg-2.0/tss_marshaling.c
@@ -83,9 +83,30 @@ static int marshal_TPMT_HA(struct obuf *ob, TPMT_HA *tpmtha)
int rc = 0;
rc |= marshal_TPMI_ALG_HASH(ob, tpmtha->hashAlg);
- rc |= obuf_write(ob, tpmtha->digest.sha256,
+ switch (tpmtha->hashAlg) {
+ case TPM_ALG_SHA1:
+ rc |= obuf_write(ob, tpmtha->digest.sha1,
tlcl_get_hash_size_from_algo(tpmtha->hashAlg));
-
+ break;
+ case TPM_ALG_SHA256:
+ rc |= obuf_write(ob, tpmtha->digest.sha256,
+ tlcl_get_hash_size_from_algo(tpmtha->hashAlg));
+ break;
+ case TPM_ALG_SM3_256:
+ rc |= obuf_write(ob, tpmtha->digest.sm3_256,
+ tlcl_get_hash_size_from_algo(tpmtha->hashAlg));
+ break;
+ case TPM_ALG_SHA384:
+ rc |= obuf_write(ob, tpmtha->digest.sha384,
+ tlcl_get_hash_size_from_algo(tpmtha->hashAlg));
+ break;
+ case TPM_ALG_SHA512:
+ rc |= obuf_write(ob, tpmtha->digest.sha512,
+ tlcl_get_hash_size_from_algo(tpmtha->hashAlg));
+ break;
+ default:
+ rc = -1;
+ }
return rc;
}