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

Don't parse EC parameters and point #58

Merged
merged 1 commit into from
Jul 3, 2017
Merged

Conversation

bbc2
Copy link
Member

@bbc2 bbc2 commented Jun 29, 2017

In particular, don't return CKA_CS_UNKNOWN if the parsing of EC parameters or point failed. The use of CKA_CS_UNKNOWN is reserved for codes unknown to the library.

@bbc2 bbc2 requested a review from emillon June 29, 2017 14:24
Copy link
Contributor

@emillon emillon left a comment

Choose a reason for hiding this comment

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

Thanks! Except for these minor points (mostly about testing) I think that this is a great change.

@@ -167,9 +162,9 @@ let to_json : type a . a t -> Yojson.Safe.json = fun attribute ->
| CKA_MODIFIABLE, param ->
p_bool "CKA_MODIFIABLE" param
| CKA_EC_PARAMS, param ->
p_ec_params "CKA_EC_PARAMS" param
p_data "CKA_EC_PARAMS" param
Copy link
Contributor

Choose a reason for hiding this comment

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

This is binary data. If I understand it correctly, this means that this will be serialized as hex? Can you add a couple unit tests for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

What should be tested exactly? The fact that it uses p_data or the fact the p_data serializes its second argument to hex?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking checking that of_yojson (Assoc [CKA_EC_PARAMS, String "0x4142}") is [pack CKA_EC_PARAMS "AB"], and similarly for to_yojson.

@@ -184,6 +184,12 @@ CK_RV C_GetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
get_single_attribute_value(pAttribute, &value, sizeof(value), &ret);
}
break;
case CKA_EC_PARAMS:
{
CK_BYTE value[] = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a valid value here? You can find some valid encodings here for example.

And also can you add a corresponding test in test_get_attribute_value in test_driver.ml?

let decode_ec_point cs =
let grammar = Key_parsers.Asn1.EC.point_grammar in
let codec = Asn.codec Asn.ber grammar in
match Asn.decode codec cs with
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand it correctly, this was the only use of Key_parsers. Can you remove it from _tags, opam, .merlin and META?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'll do that.

@emillon
Copy link
Contributor

emillon commented Jun 30, 2017

Two small remarks mostly to self:

@bbc2 bbc2 force-pushed the do-not-parse-ec-parameters branch 2 times, most recently from f606163 to 5d977fe Compare July 3, 2017 14:07
@bbc2
Copy link
Member Author

bbc2 commented Jul 3, 2017

Should be good now.

@emillon
Copy link
Contributor

emillon commented Jul 3, 2017

Looks good, thanks. If you rebase your branch onto master this should fix the build (I allowed failures on 4.02.3).

In particular, don't return CKA_CS_UNKNOWN if the parsing of EC
parameters or point failed.  The use of CKA_CS_UNKNOWN is reserved for
codes unknown to the library.

This removes the dependency on key-parsers.
@bbc2 bbc2 force-pushed the do-not-parse-ec-parameters branch from 5d977fe to f7eb214 Compare July 3, 2017 16:00
@bbc2
Copy link
Member Author

bbc2 commented Jul 3, 2017

I just did that.

@emillon
Copy link
Contributor

emillon commented Jul 3, 2017

Thanks! ✨

@emillon emillon merged commit b4fef18 into master Jul 3, 2017
@emillon emillon deleted the do-not-parse-ec-parameters branch December 14, 2017 11:56
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.

2 participants