From b06558d32bc174e7d10238c8a1dcb52821775c75 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Wed, 4 Aug 2021 13:49:37 -0400 Subject: [PATCH] tpm2: Report supported Camellia keysizes in the JSON Signed-off-by: Stefan Berger --- src/tpm_tpm2_interface.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tpm_tpm2_interface.c b/src/tpm_tpm2_interface.c index 3c86aaa2..8d8117ee 100644 --- a/src/tpm_tpm2_interface.c +++ b/src/tpm_tpm2_interface.c @@ -368,13 +368,15 @@ static char *TPM2_GetInfo(enum TPMLIB_InfoFlags flags) "}"; const char *tpmfeatures_temp = "\"TPMFeatures\":{" - "\"RSAKeySizes\":[%s]" + "\"RSAKeySizes\":[%s]," + "\"CamelliaKeySizes\":[%s]" "}"; char *fmt = NULL, *buffer; bool printed = false; char *tpmattrs = NULL; char *tpmfeatures = NULL; char rsakeys[32]; + char camelliakeys[16]; size_t n; if (!(buffer = strdup("{%s%s%s}"))) @@ -410,7 +412,14 @@ static char *TPM2_GetInfo(enum TPMLIB_InfoFlags flags) RSA_4096 ? ",4096" : ""); if (n >= sizeof(rsakeys)) goto error; - if (asprintf(&tpmfeatures, tpmfeatures_temp, rsakeys) < 0) + n = snprintf(camelliakeys, sizeof(camelliakeys), "%s%s%s", + CAMELLIA_128 ? "128" : "", + CAMELLIA_192 ? ",192" : "", + CAMELLIA_256 ? ",256" : ""); + if (n >= sizeof(camelliakeys)) + goto error; + if (asprintf(&tpmfeatures, tpmfeatures_temp, + rsakeys, camelliakeys) < 0) goto error; if (asprintf(&buffer, fmt, printed ? "," : "", tpmfeatures, "%s%s%s") < 0)