Rust for Linux List
 help / color / mirror / Atom feed
From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "Jarkko Sakkinen" <jarkko@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>
Cc: "Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com>,
	<rust-for-linux@vger.kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>
Subject: Re: ASN.1
Date: Wed, 22 May 2024 16:49:04 +0300	[thread overview]
Message-ID: <D1G7YTUR11EW.WIG4RQVBNCXU@kernel.org> (raw)
In-Reply-To: <D1G6UP4N7LP4.OUPA5JVLE1WO@kernel.org>

On Wed May 22, 2024 at 3:56 PM EEST, Jarkko Sakkinen wrote:
> On Wed May 22, 2024 at 3:04 PM EEST, Alex Gaynor wrote:
> > Hi Jarkko,
> >
> > I'm one of the maintainers of https://crates.io/crates/asn1/. Based on
> > that experience, if you want to implement a DER encoder in Rust, I
> > think it'd make more sense to write the type-code in Rust, and then
> > expose symbols to C like `encode_rsa_pub_key`. This should be simpler,
> > but also more efficient (fewer allocations).
> >
> > For what it's worth, rust-asn1 is _intended_ to be usable from the
> > kernel/embedded targets. It's no_std. It currently relies on alloc,
> > but I'd be happy to accept PRs to make it work with the kernel's
> > approach to fallible allocation (it currently does support fallible
> > allocation, but using the reserve APIs).
> >
> > Alex
>
> Right, I need to experiment with that just in user space first.
>
> It seemed like most "productized" crate from all that I found.
>
> Yeah, and it is true that also crate could be as rusty as hell,
> and then just make bridge shim that hides all that ;-) That is
> probably better way around.
>
> Thanks for the response!

If we want to considering getting your code to land to the kernel I
would start with the decoder as it already delivers, as an
*experimental* feature. Then when it is landed it would not be
as huge stretch to move forward with the encoder.

Basically how Rust ASN.1 could work out for kernel is pretty trivial to
describe:

1. Add a new Kconfig flag: e.g. CONFIG_ASN1_RUST. This flag could be a
   subflag of CONFIG_ASN1 and by default obviously disabled.
2. Import asn1 code to kernel and make it build as part of vmlinux.
3. Implement a shim for C with zero or at least minimal changes to the
   developer experience. I.e. you can drop your asn1 file to the subsystem
   directory and some small tweaks to Makefile and you are set.
4. Update MAINTAINERS. I think this should have own entry and probably
   you would be the best possible person to have M-entry. I could add
   myself R-entry (reviewer) because I'm the end customer :-)

If we would get this far and get this to also mainline then it would
be also a huge step towards encoding as then it would be just adding
another feature without infrastructural madness involved ;-)

BR, Jarkko

  reply	other threads:[~2024-05-22 13:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21  6:36 ASN.1 Jarkko Sakkinen
2024-05-21 14:52 ` ASN.1 Miguel Ojeda
2024-05-21 15:20   ` ASN.1 Jarkko Sakkinen
2024-05-21 18:01     ` ASN.1 Jarkko Sakkinen
2024-05-21 18:55       ` ASN.1 Jarkko Sakkinen
2024-05-22 12:04         ` ASN.1 Alex Gaynor
2024-05-22 12:56           ` ASN.1 Jarkko Sakkinen
2024-05-22 13:49             ` Jarkko Sakkinen [this message]
2024-05-23  7:00               ` ASN.1 Jarkko Sakkinen
2024-05-23  7:03                 ` ASN.1 Jarkko Sakkinen
2024-05-23 15:44                 ` ASN.1 Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D1G7YTUR11EW.WIG4RQVBNCXU@kernel.org \
    --to=jarkko@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=daniel.almeida@collabora.com \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox