Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function name as part of errors #135

Closed
ellerh opened this issue Mar 16, 2023 · 4 comments
Closed

Function name as part of errors #135

ellerh opened this issue Mar 16, 2023 · 4 comments

Comments

@ellerh
Copy link
Contributor

ellerh commented Mar 16, 2023

What would people think about including (the name of) the called function in error values?

E.g. most error values could include a field of type cryptoki::context::Function. The error message could then look like Function::Login failed: RvError::PinIncorrect: The specified PIN is ....

Without the function name, error messages are less useful and callers of the library can't simply propagate errors. Instead they will likely create their own error types that include the function name in some way or another.

@ionut-arm
Copy link
Member

ionut-arm commented Apr 22, 2023

Hey,

Sorry for the awful delay in replying. Yes, that sounds quite useful, though I'm not sure I fully understand what you'd like tracked. The issue is mostly that the native API of cryptoki does not necessarily correspond 1-to-1 to PKCS11 operations, so we wouldn't be able to assign a Function::... to every public operation in cryptoki (and we sometimes have multiple methods calling the same PKCS11 operation, which would also confuse things). But what we could do is for every failure coming from the actual PKCS11 backend, we could also pass along the Function::... which generated it (and add that to the Display of Error). Would that be enough to cover your use-cases?

The Pkcs11 variant of the Error enum would thus look like Pkcs11(RvError, Function),.

@ionut-arm
Copy link
Member

Hmm, looking through the variants, I think Function would also make sense on NullFunctionPointer - the other seem to be fairly operation-agnostic.

@ellerh
Copy link
Contributor Author

ellerh commented Apr 25, 2023

The Pkcs11 variant of the Error enum would thus look like Pkcs11(RvError, Function)

Yes, that would be perfect.

@hug-dev
Copy link
Member

hug-dev commented Dec 26, 2024

Done in #147 as requested. Thanks @ionut-arm , you're the best!

@hug-dev hug-dev closed this as completed Dec 26, 2024
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

No branches or pull requests

3 participants