-
Notifications
You must be signed in to change notification settings - Fork 61
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
Vendored mechanisms #105
Comments
Hey! Thanks for raising this - yes, it's a hole in the API that we've not (yet) addressed. We are, however, happy to take PRs for it, so feel free to create one with your code, it looks pretty sensible to me. One thing to note is that currently your vendored mechanism implementation only allows you to override our defined mechanism types without being able to specify other vendor types. The spec (section 3.5) says:
I'd suggest making the fields of |
I've been working on an implementation for this and I think it would be worth discussing some design thoughts here before moving forward.
pub trait VendorMechanism {
const TYPE: MechanismType;
fn param_bytes(&self) -> &[u8];
}
...
enum Mechanism {
...
VendorDefined(Box<dyn VendorMechanism>)
} but the VendorMechanism wouldn't be object safe that wouldn't work.
|
Hello,
I am working with a PKCS11 interface requiring the use of vendored mechanisms. I did not find a way to do so with this crate and was wondering if this could be added. Beside this issue (#54) which focuses on errors, it seems to me the subject was not discussed, at least publicly.
Do you plan implementing this feature or would you accept a PR for it?
In case you are open to the idea, I already looked at the code and it seems to me this boils down to provide a mean to extend the
Mechanism
enum. Because the rust-cryptoki library cannot know in advance, I could not think of a simple way to ensure the library user constructs correct PKCS11 mechanisms.I think a simple solution would be to offer an additional
VendoredMechanism
in theMechanism
enum which would expose the inners of what makes aCK_MECHANISM
: aMechanismType
and some arbitrary bytes as parameters.In a working PoC, I implemented this:
Which can be used as so:
I know this code is not that great, it's just to start the discussion and suggest a simple way to go. I look forward for your input!
The text was updated successfully, but these errors were encountered: