" * sha256\n"
" * sha384\n"
" * sha512\n"
+" * sm3_256\n"
" <on|off> is one of:\n"
" * on - Select all available PCRs associated with the specified\n"
" algorithm (bank)\n"
false,
#endif
},
+ {
+ "sm3_256",
+ TPM2_ALG_SM3_256,
+ TCG2_BOOT_HASH_ALG_SM3_256,
+ TPM2_SM3_256_DIGEST_SIZE,
+#if IS_ENABLED(CONFIG_SM3)
+ true,
+#else
+ false,
+#endif
+ },
+
};
/* NV index attributes */
case TPM2_ALG_SHA512:
hash_calculate("sha512", regs->reg, regs->num, hash);
break;
+ case TPM2_ALG_SM3_256:
+ hash_calculate("sm3_256", regs->reg, regs->num, hash);
+ break;
default:
continue;
}
pcrs->count = get_unaligned_be32(response);
/*
- * We only support 4 algorithms for now so check against that
+ * check against the supported algorithms in hash_algo_list,
* instead of TPM2_NUM_PCR_BANKS
*/
- if (pcrs->count > 4 || pcrs->count < 1) {
+ if (pcrs->count > ARRAY_SIZE(hash_algo_list) || pcrs->count < 1) {
printf("%s: too many pcrs: %u\n", __func__, pcrs->count);
return -EMSGSIZE;
}
#include <u-boot/sha1.h>
#include <u-boot/sha256.h>
#include <u-boot/sha512.h>
+#include <u-boot/sm3.h>
#include <version_string.h>
#include <asm/io.h>
#include <linux/bitops.h>
sha512_finish(&ctx_512, final);
len = TPM2_SHA512_DIGEST_SIZE;
break;
+#endif
+#if IS_ENABLED(CONFIG_SM3)
+ case TPM2_ALG_SM3_256:
+ sm3_hash(input, length, final);
+ len = TPM2_SM3_256_DIGEST_SIZE;
+ break;
#endif
default:
printf("%s: unsupported algorithm %x\n", __func__,
case TPM2_ALG_SHA256:
case TPM2_ALG_SHA384:
case TPM2_ALG_SHA512:
+ case TPM2_ALG_SM3_256:
len = tpm2_algorithm_to_len(algo);
break;
default:
case TPM2_ALG_SHA256:
case TPM2_ALG_SHA384:
case TPM2_ALG_SHA512:
+ case TPM2_ALG_SM3_256:
len = get_unaligned_le16(&event->digest_sizes[i].digest_size);
if (tpm2_algorithm_to_len(algo) != len) {
log_err("EventLog invalid algorithm length\n");