Specification Date: Mon 2023-01-09
Manufacturer: STM
Vendor String: ST33KTPM2XSPI
- Firmware Version: 9.258</programlisting>
+ Firmware Version: 9.258
+ Modalias String: fi2.0:lv0:rv1.59:sy2023:sd9:mfSTM:vsST33KTPM2XSPI:ty0:fw9.258.0:</programlisting>
</example>
<xi:include href="version-info.xml" xpointer="v260"/>
if (r < 0)
return table_log_add_error(r);
+ _cleanup_free_ char *m = NULL;
+ if (tpm2_vendor_info_to_modalias(&info, &m) < 0)
+ return log_oom();
+
+ r = table_add_many(
+ table,
+ TABLE_FIELD, "Modalias String",
+ TABLE_STRING, m);
+ if (r < 0)
+ return table_log_add_error(r);
+
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, /* show_header= */ false);
if (r < 0)
return r;
return more == TPM2_YES;
}
+int tpm2_vendor_info_to_modalias(const Tpm2VendorInfo *info, char **ret) {
+ _cleanup_free_ char *m = NULL;
+
+ assert(info);
+ assert(ret);
+
+ /* Closely inspired by kernel modalias strings, this distills information from the TPM vendor data
+ * into a string suitable for matching hwdb */
+
+ if (asprintf(&m,
+ "fi%s:"
+ "lv%" PRIu32 ":"
+ "rv%" PRIu32 ".%" PRIu32 ":"
+ "sy%" PRIu32 ":"
+ "sd%" PRIu32 ":"
+ "mf%s:"
+ "vs%s:"
+ "ty%" PRIx32 ":"
+ "fw%" PRIu16 ".%" PRIu16 ".%" PRIu32 ":",
+ info->family_indicator,
+ info->level,
+ info->revision_major,
+ info->revision_minor,
+ info->year,
+ info->day_of_year,
+ info->manufacturer,
+ info->vendor_string,
+ info->vendor_tpm_type,
+ info->firmware_version_major,
+ info->firmware_version_minor,
+ info->firmware_version2) < 0)
+ return -ENOMEM;
+
+ *ret = TAKE_PTR(m);
+ return 0;
+}
+
static char *mangle_vendor_chars(char *c, size_t n) {
char *end = c;
assert(c || n == 0);
char vendor_string[4*4+1];
} Tpm2VendorInfo;
+int tpm2_vendor_info_to_modalias(const Tpm2VendorInfo *info, char **ret);
int tpm2_get_vendor_info(Tpm2Context *c, Tpm2VendorInfo *ret);
void tpm2_log_debug_tpml_pcr_selection(const TPML_PCR_SELECTION *l, const char *msg);