Skip to content

Allocation-free operations#349

Merged
hug-dev merged 1 commit into
parallaxsecond:mainfrom
bal-e:alloc-free-ops
Jun 15, 2026
Merged

Allocation-free operations#349
hug-dev merged 1 commit into
parallaxsecond:mainfrom
bal-e:alloc-free-ops

Conversation

@bal-e

@bal-e bal-e commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Starts addressing #346.

Question for the reviewers:

  • What do you think of the added documentation? Is it too much? Or should I add more to the related sign() functions for consistency?

  • I don't have a strict need to implement this for more operations, but I'm happy to do one or two sets more. Are there any in particular you'd like to see? I'm leaning towards key generation (which I need, but is not performance-sensitive) and encryption (which I guess more people would want to use).

  • Would you have any tips for adding these methods to the test suite? It'll have to be a bit algorithm-specific.

@bal-e bal-e force-pushed the alloc-free-ops branch 2 times, most recently from 3c1d3ff to bfba84a Compare January 26, 2026 07:25
@bal-e

bal-e commented Jan 26, 2026

Copy link
Copy Markdown
Contributor Author

I see working with c_ulong is a bit frustrating.

@hug-dev hug-dev left a comment

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.

Thank you!
Really like the added documentation, I think that's good! My only suggestion is to simplify and return the original error as is :)

For testing I think it's fine trying one or a few variants. You can for example use the same one which is done in the test currently for the sign operation!

Comment thread cryptoki/src/session/signing_macing.rs Outdated
Comment thread cryptoki/src/session/signing_macing.rs Outdated

@wiktor-k wiktor-k left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great, a couple of nitpicks/clarifications. Thanks for your contribution! 🙇

Comment thread cryptoki/src/error/mod.rs Outdated
Comment thread cryptoki/src/session/signing_macing.rs
Comment thread cryptoki/src/session/signing_macing.rs
Comment thread cryptoki/src/session/signing_macing.rs Outdated
Comment thread cryptoki/src/session/signing_macing.rs Outdated
Comment thread cryptoki/src/session/signing_macing.rs Outdated
@wiktor-k

Copy link
Copy Markdown
Collaborator

What do you think of the added documentation? Is it too much? Or should I add more to the related sign() functions for consistency?

I think it looks fine as it is 👌

I don't have a strict need to implement this for more operations, but I'm happy to do one or two sets more. Are there any in particular you'd like to see? I'm leaning towards key generation (which I need, but is not performance-sensitive) and encryption (which I guess more people would want to use).

No pressure to add more, this may grow organically as use-cases appear. If you feel like doing additional work I'm not stopping you though 😅

Would you have any tips for adding these methods to the test suite? It'll have to be a bit algorithm-specific.

Yep, ideally the tests should exercise all paths, including error ones and check if returned errors match what we expect. Choosing one algo for tests is sufficient. (Ideally it should be implemented by both softhsm and kryoptic but I don't think you'll use anything exotic).

Thanks! 👋

Comment thread cryptoki/src/session/signing_macing.rs Outdated
Comment thread cryptoki/src/session/signing_macing.rs Outdated
@bal-e

bal-e commented Feb 18, 2026

Copy link
Copy Markdown
Contributor Author

Added tests, resolved review comments, and switched to &self instead of &mut self.

Comment thread cryptoki/src/session/signing_macing.rs
Comment thread cryptoki/src/session/signing_macing.rs Outdated
@hug-dev

hug-dev commented Jun 11, 2026

Copy link
Copy Markdown
Member

It's been a long time @bal-e but if you have the time you could rebase the PR and then we should merge as is since we agreed on going forward with the assert!

hug-dev
hug-dev previously approved these changes Jun 11, 2026
@hug-dev hug-dev enabled auto-merge (rebase) June 11, 2026 08:03
Jakuje
Jakuje previously approved these changes Jun 11, 2026

@Jakuje Jakuje left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We need rebase, but otherwise I think we are good to merge this!

@bal-e

bal-e commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Awesome, on it!

These '_into()' variants can be used when the caller knows the expected
buffer size, and has allocated a buffer for the signature themselves.
It requires fewer calls into the underlying library and can save on
heap allocations.

Signed-off-by: arya dradjica <arya@nlnetlabs.nl>
auto-merge was automatically disabled June 15, 2026 06:10

Head branch was pushed to by a user without write access

@bal-e bal-e dismissed stale reviews from Jakuje and hug-dev via bba0336 June 15, 2026 06:10

@hug-dev hug-dev left a comment

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.

Thank you!

@hug-dev hug-dev enabled auto-merge (rebase) June 15, 2026 07:57

@wiktor-k wiktor-k left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍

@hug-dev hug-dev merged commit 0d9a380 into parallaxsecond:main Jun 15, 2026
44 checks passed
@bal-e bal-e deleted the alloc-free-ops branch June 15, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants