Skip to content

lib: simplify attr_util - #3605

Open
AndreasFuchsTPM wants to merge 3 commits into
tpm2-software:masterfrom
AndreasFuchsTPM:simplify_attr_util
Open

AndreasFuchsTPM wants to merge 3 commits into
tpm2-software:masterfrom
AndreasFuchsTPM:simplify_attr_util

Conversation

@AndreasFuchsTPM

@AndreasFuchsTPM AndreasFuchsTPM commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

Instead of a table driven dispatch logic, use a simple linear switch case like approach.

So I did break API here.
Old output: "authread|authwrite|nt=0x2"
New output: "authread|authwrtie|extend"
Parsing still accepts all variants though...

I like this much more; oppinions?

Also question: Should the tools return a bunch of "<reserved(8)>" reports or should the library's to text rather fail here ?

Fixes: #1797
Implements: #1798
Superseeds: #3600

Comment thread lib/tpm2_attr_util.c Fixed
Comment thread lib/tpm2_attr_util.c Fixed
@moritzbuhl

Copy link
Copy Markdown
Member

The following things are still needed to match the old functionality:

reserved bits are no longer allowed, old code wrote <reserved(...)>:

#define dispatch_reserved(pos) \
    { .name = "<reserved("xstr(pos)")>", .callback=NULL, .width = 1 }

nt=0x... and formatting values other than the named ones from the enum.

boolean tokens accept an equals sign, e.g. authread=garbage

@AndreasFuchsTPM
AndreasFuchsTPM force-pushed the simplify_attr_util branch 3 times, most recently from 90b7090 to 80cd0a1 Compare September 11, 2026 13:09
Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
@AndreasFuchsTPM
AndreasFuchsTPM force-pushed the simplify_attr_util branch 2 times, most recently from c679b7d to f1a1259 Compare September 11, 2026 14:47
Comment thread lib/tpm2_attr_util.c
Comment thread lib/tpm2_attr_util.c Outdated
tpm_nt_ordinary = true;
}

while ((token = strtok_r((save)? NULL : str, "|", &save))) {

@moritzbuhl moritzbuhl Sep 11, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (token = strtok_r(str, "|", &save); token != NULL; token = strtok_r(NULL, "|", &save)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a table driven dispatch logic, use a simpler approach.

Also instead of the nt=0x? notation the tools will now output the
usable name, e.g. counter, extend, pinpass, etc
We do not output ordinary for backwards compatibility.

Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
This is an API change where instead of printing or allowing
the notion of "<reserved(20)>" for reserved bits in bitmasks
we return errors now.

Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nt decoding scheme broken

3 participants