Posts
4874
Following
323
Followers
490
Linux kernel hacker and maintainer etc.

OpenPGP: 3AB05486C7752FE1

Jarkko Sakkinen

My favorite command-line parser for Rust:

https://github.com/blyxxyz/lexopt

I.e. it does not create command-line for you and you can fully control of the user experience.
1
0
0

Jarkko Sakkinen

still in progress but this will be a nice debugging feature:
1
0
0
and if done correctly it improves security properties of any tool as the input layer is always an attack vector.
0
0
0

Jarkko Sakkinen

Edited 2 months ago
I mean cli is a gui of one form and usuall guis are not sprayed to the source code

https://github.com/puavo-org/tpm2_library/commit/ddbce9387119c77b618988cd875dcbec812d7b96
1
0
0
In some cases this could be the early phase also for new kernel code given that you can quite easily make parts of the code context independent, and by being part of kselftest it would get some stress testing before it is part of the actual kernel code.
0
0
0

Jarkko Sakkinen

I wonder if it either is or could be allowed kselftest to be written in Rust assuming that it requires only rustc and has at most std dependencies? Not talking a cargo build here.
1
0
0

Jarkko Sakkinen

Procedural macros in Rust:

- How to use them with plain rustc?
- Why they need to be in a lib crate?
0
0
0

Jarkko Sakkinen

Edited 2 months ago
The most important setting in fish shell:

set -g fish_autosuggestion_enabled 0

Fucking worst default in a shell that anyone has ever put to any shell (unless you are going epileptic seizure)
0
0
0

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 2 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
Show older