-
Notifications
You must be signed in to change notification settings - Fork 68
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
Provide attribute type in return from get_attribute_info
#42
Comments
Hey! Back from holidays 🌴 I thought that because the Something like this could be possible, having
Good point! In the current implementation we make no difference if the attribute is unavailable because sensitive/unextractable or because invalid. We could add one more variant to the |
Welcome back! Sorry for the delay in the response. Been busy with life and work and such, but I appreciate the response.
That is a fair point. My thinking behind this is if you have a long list of attributes you want the information of, it would feel a little "kludgy" to figure out the index into the vector of attributes and corresponding that to the index location of the
Maybe we could pass in a mutable reference to a
Unfortunately, you don't know which attribute is "sensitive" from the return of For example, if you attempt to get the value of However, in my experience, a lot of applications that use the spec tend to call I think it may make sense to return a tuple on the success end that contains the return code? |
I tried and one could use the following to create a let attribute_types = [
AttributeType::Token,
AttributeType::Private,
AttributeType::Modulus,
AttributeType::KeyType,
AttributeType::Verify,
];
let attribute_info = session.get_attribute_info(object, &attribute_types)?;
let hash = attribute_types
.iter()
.zip(attribute_info.iter())
.collect::<HashMap<_, _>>(); otherwise I am fine to just return the Thanks for the explanation on the second problem, I see what you mean now. So, if I'm correct, currently you get
Could work but does not seem ideal to add something that can only be useful in some particular cases (when calling the function with just one attribute type) 😕. What I can propose as well is to add one more method only taking one single attribute type and returning all possible error messages? That way people can use that to check attribute by attribute. We should also add the limitation in the original method. |
Maybe we can add in two functions. A And I can put in a comment to |
This is probably over-kill. I'll just make a comment similar to what you wrote out above. Thanks for the input (and reminding me about |
…pdates-from-parallaxsecond#42' into latest
I don't mind about adding a wrapper which return the |
Updates for getting attribute info - #42
Currently
get_attribute_info
takes in a slice ofAttributeType
's and returns aVec<AttributeInfo>
,however other than indexing into the slice and assuming the corresponding attribute information occupies the same index , the returned data does not correlate the attribute length to said attribute.I can think of two solutions (but my limited Rust experience tells me there's probably better ways of doing this):
AttributeInfo
to contain theAttributeType
by modifying the enum variants to be either:or
Furthermore,
get_attribute_info
does not return whether or notC_GetAttributeValue
returnsCKR_ATTRIBUTE_SENSITIVE
orCKR_ATTRIBUTE_INVALID
. Operationally, these may not be the most helpful returns (frankly the spec forC_GetAttributeValue
leaves a lot to be desired when it comes to determining why an attribute is not returned) but I believe the wrapper library should not be masking away that information.This part of the issue may warrant a separate ticket/discussion, but one possibility would be returning the CKR as part of a tuple (along with the attribute information) in the successful part of the Result enum.
The text was updated successfully, but these errors were encountered: