Posts
4941
Following
327
Followers
492
Linux kernel hacker and maintainer etc.

OpenPGP: 3AB05486C7752FE1

Jarkko Sakkinen

My tpm2_protocol crate could be useful also for e.g. some scenarios where you to format your crypto proofs in TPM2 structures wi/o having TPM.
0
0
0

Jarkko Sakkinen

Great, I've used before external crate for this:
https://doc.rust-lang.org/beta/std/io/trait.IsTerminal.html

Apparently std has had this for over two years already.
0
0
0
i.e. you do a little to generate a lot
0
0
0
@pinkforest I noticed that more i bake the implementation into syntax tree macros, the more i actually appreciate super static text editor like (plain) vim. Anything that auto-completes gets in the way as you sort of define how things complete automatically with a manual script :-)
1
0
0
i.e.

1. better coverage
2. time saved from writing tests
3. less dependecies
0
0
0

Jarkko Sakkinen

the next thing i do for tpm2_protocol is render out "rstest" and "hex" from cargo test and make my macro auto-generate roundtrip tests.

i'll also add a Makefile to the root with "make test" target. It will build the test binary with rustc and run the tests. Finally this will be added to the CI.
1
0
0

@mupuf I wrote the code so that i don’t end up dust-for-linux :D

I also learned that “macros_rules!” is the thing that you would want to learn first in Rust so that it would make any sense if you knew beforehand that it is the thing that you most want to learn :-) Without it super unproductive language and IMHO does not really pay the cost despite what ever “memory safety”. With “macro_rules!” you can consolidate those few dozen trait implementations into one single place :-) Then it is suddenly more productive language than C.

I drive the spec interpration and building with ~600 lines of trial and error fine-tune syntax tree macros :-) https://github.com/puavo-org/tpm2_library/blob/main/protocol/src/macro.rs

And then I can implement the spec like I was writing the spec:

tpm_struct!(
    #[derive(Debug, Default, PartialEq, Eq, Clone)]
    TpmStartAuthSessionCommand,
    TpmCc::StartAuthSession,
    true,
    true,
    2,
    {
        pub nonce_caller: Tpm2b,
        pub encrypted_salt: Tpm2b,
        pub session_type: TpmSe,
        pub symmetric: TpmtSymDefObject,
        pub auth_hash: TpmAlgId,
    }
);

And all the bidirectional marshalling and unmarshallinf magic will appear :-) Things like “async” are more like fixed structure threading framework type of stuff but does not convince at all what makes sense in the core language (neither does borrow checker at least not as “driving feature”), I mean we already have Java :-) ).

0
0
1

Jarkko Sakkinen

typoed rust-for-linux to my annoucement by accident as ust-for-linux ****
1
0
0

Jarkko Sakkinen

Edited 3 months ago
You can literally build identity function with this now :-) And yeah, I can say this with 100% confidence: nothing exactly like this in production usable form pre-exist. It's first of its kind.
0
0
0

Jarkko Sakkinen

This was nasty one to fix and took many days (and nights tbh) but now finally command parsing is fixed and all my tests pass:

https://github.com/puavo-org/tpm2_library/commit/7b0fc824bd341fb21c90a06b945f01feb1c20f5e

There's MS TPM 2.0 emulator and swtpm, and that's like all of command parsing and response synthesis I'm aware of. I.e. by practical means there was no useful existing work to take example of :-) I'm pretty happy and a bit proud too that I've reach unipolarity by writing Rust macros reflecting TCG specifications.

I don't have now known bugs in the protocol crate. I'm sure there's a bunch but still feels nice after 1.5 weeks of sleepless nights and 7K SLOC of code (protocol + cli).

#linux #kernel #rust #tpm
1
0
1

Jarkko Sakkinen

Edited 3 months ago
It's immature as hell but I think i've made correct base decisions (which you can only do at this point). Right now I'm fixing some macros because i did "final polishments before putting this out" and did some awful mistakes :-) This always happens. Yesterday morning things were better but then I started to tweak ...

I think, considering rust-linux, one interesting feature could be swtpms, which becomes realistic goal if you make right conclusions of what you're observing. I don't actually know could you create endosement infrastructure where swtpm instances have their endorsement keys certified by the TPM chip (which is endorsed by the manufacturer).

In the previous TPM stack implementations i think that core mistake that has been repeatedly made is thinking that you have a client and chip or emulator, which is not from technical perspective correct assesment.

QEMU is an emulator. TPM2 is a protocol. That is stating the obvious but for some reason that is the exact blind spot.
0
0
0
@lkundrak ya basically want to make sure that whoever intends to do that gets it done smoothly and such and so forth (if that ever happens even) :-) that is the positive angle i guess... and now it is done
0
0
0
@lkundrak ya i mean i don't want to end up in a situation where i see a rust patch set and i try to say that the code is just plain bad and it is interpreted me being toxic person :-) and all reported in the usual news outlets... i can relate to the pain and suffering some maintainers have had tbh.
1
0
0
@lkundrak it's also for the reasons that now i have my rust insurance :-) now i don't have to think about the topic further can focus on side quests
1
0
1

Jarkko Sakkinen

This makes me happy:

tpm_struct!(
    #[derive(Debug, PartialEq, Eq, Clone)]
    TpmPcrEventCommand,
    TpmCc::PcrEvent,
    TpmSt::Sessions,
    1,
    {
        pub event_data: Tpm2b,
    }
);

tpm_response!(
    #[derive(Debug, Default, PartialEq, Eq, Clone)]
    TpmPcrEventResponse,
    TpmCc::PcrEvent,
    TpmSt::Sessions,
    {
        pub digests: TpmlDigestValues,
    }
);

Also the types inside use the same system (in fact tpm_struct is shared macro with data types and commands). This will generate full parsing and building for both commands and responses - all without heap involved.

1
0
0
Here's another 3D print project: a mounting bracket for W1GHZ dual-band microwave feed horns (10 GHz + 24 GHz).

https://github.com/xjamesmorris/dual-band-10-24-ghz-feed-mount

#amateurradio #hamradio #3dprinting #rf #microwave
0
3
7
Licensing is used as security measure. I.e. crate itself is Apache/MIT but cli is strict GPL3. It's exactly because then you know that a binary is "accountable". It's a trick I've learned how Signal creates security layers via licensing (they show how AGPL can be commercially appealing pick).
0
0
0
I.e. want to write your own TPM emulator in one day? Now it is possible
1
0
0
Show older