Skip to content

Expose vendor defined error code#300

Merged
hug-dev merged 3 commits into
parallaxsecond:mainfrom
thgoebel:vendor-error-codes
Jul 23, 2025
Merged

Expose vendor defined error code#300
hug-dev merged 3 commits into
parallaxsecond:mainfrom
thgoebel:vendor-error-codes

Conversation

@thgoebel
Copy link
Copy Markdown
Contributor

Fixes #299

Tested with:

This contribution is in personal capacity.

@thgoebel thgoebel force-pushed the vendor-error-codes branch 3 times, most recently from 74a094b to 14aa761 Compare July 19, 2025 18:32
hug-dev
hug-dev previously approved these changes Jul 22, 2025
Copy link
Copy Markdown
Member

@hug-dev hug-dev left a comment

Choose a reason for hiding this comment

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

Thank you!

Comment thread cryptoki/src/error/rv.rs
Comment thread cryptoki/src/object.rs Outdated
wiktor-k
wiktor-k previously approved these changes Jul 22, 2025
Copy link
Copy Markdown
Collaborator

@wiktor-k wiktor-k left a comment

Choose a reason for hiding this comment

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

LGTM 👍 thanks!

@thgoebel thgoebel dismissed stale reviews from wiktor-k and hug-dev via ad31c96 July 22, 2025 15:34
@thgoebel thgoebel force-pushed the vendor-error-codes branch from 14aa761 to ad31c96 Compare July 22, 2025 15:34
@thgoebel
Copy link
Copy Markdown
Contributor Author

On second thought, I additionally added (in a separate commit) an additional enum value for unknown error codes. This way, when the error code is neither standardised nor from the vendor-reserved area, at least the error code gets bubbled up to the calling application. Mapping it to CKR_GENERAL_ERROR is akin to mapping it to 0x00000005UL, which is misleading.

Let me know what you think, I can amend or drop this.

@thgoebel thgoebel force-pushed the vendor-error-codes branch from ad31c96 to 7a78363 Compare July 22, 2025 15:47
Comment thread cryptoki/src/lib.rs Outdated
hug-dev
hug-dev previously approved these changes Jul 22, 2025
Copy link
Copy Markdown
Member

@hug-dev hug-dev left a comment

Choose a reason for hiding this comment

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

Nice addition!

thgoebel added 3 commits July 22, 2025 22:15
CK_ULONG is a type alias for std::os::raw::c_ulong.
c_ulong is always either u32 or u64:

- https://doc.rust-lang.org/std/os/raw/type.c_ulong.html
- https://github.com/rust-lang/rust/blob/master/library/core/src/ffi/primitives.rs

And in the end, it will do the same thing anyway:
https://github.com/rust-lang/rust/blob/0162cc5/library/core/src/num/uint_macros.rs#L45

Signed-off-by: Thore Goebel <git@thore.io>
Fixes parallaxsecond#299

Signed-off-by: Thore Goebel <git@thore.io>
This makes debugging easier, since the error code is readily available.

Signed-off-by: Thore Goebel <git@thore.io>
Copy link
Copy Markdown
Collaborator

@Jakuje Jakuje left a comment

Choose a reason for hiding this comment

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

thank you! Looks good!

@hug-dev hug-dev merged commit a3b5e75 into parallaxsecond:main Jul 23, 2025
43 checks passed
@thgoebel thgoebel deleted the vendor-error-codes branch July 23, 2025 08:35
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.

Support vendor defined error codes

4 participants