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

Add ECDSA support (named curve only, requires OpenSSL 1.1.0) #11

Merged
merged 8 commits into from
Sep 4, 2016

Conversation

tatsuhiro-t
Copy link
Contributor

This commit adds ECDSA support. Currently, only named curve is
supported. OpenSSL 1.1.0, which is not released yet, added necessary
functions to support EC_KEY with custom engine, and prior versions
have no workaround over these missing functions, we have to depend on
OpenSSL 1.1.0. More specifically, we require OpenSSL 1.1.0 pre2.

This commit adds ECDSA support.  Currently, only named curve is
supported.  OpenSSL 1.1.0, which is not released yet, added necessary
functions to support EC_KEY with custom engine, and prior versions
have no workaround over these missing functions, we have to depend on
OpenSSL 1.1.0.  More specifically, we require OpenSSL 1.1.0 pre2.
@tatsuhiro-t
Copy link
Contributor Author

I've added new commit to compile with OpenSSL 1.1.0pre5. It contains massive changes, and it broke RSA code in neverbleed. 1.1.0 makes many OpenSSL object struct opaque, and all codes to access field directly break. This commit fixes this issue.

@tatsuhiro-t
Copy link
Contributor Author

Since OpenSSL 1.1.0 is around the corner (the OpenSSL dev said that they will release it in August 25, 2016), it is a good time for us to seriously consider to review this PR.

@tatsuhiro-t
Copy link
Contributor Author

Merged master branch, resolved conflict.

@tatsuhiro-t
Copy link
Contributor Author

Now we only consider openssl 1.1.0 final version. I also fixed compiler warnings.

break;
#endif
default:
if ((errstr = expbuf_shift_str(&buf)) == NULL) {
Copy link
Member

Choose a reason for hiding this comment

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

I assume we should just return an error to the peer without trying to parse arguments calling by expbuf_shift_xxx, considering the fact that we cannot determine the number and types of the arguments unless the type is TYPE_RSA or TYPE_ECDSA.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm ok with that. But we are sure that after key_index, error message string follows. Can we just use it to return the error message to the client?

@kazuho
Copy link
Member

kazuho commented Aug 29, 2016

Thank you for the updates. I like how the RSA-related APIs are backported? for 1.0.2.

LGTM aside from my comments i-line (including the issues I found when trying to compile the file using OpenSSL 1.0.2).

Reduce scope of some variables which are only used for RSA or ECDSA so
that they are defined where they are used.

Respond:
expbuf_dispose(buf);
expbuf_push_num(buf, rsa != NULL);
expbuf_push_num(buf, type != NEVERBLEED_TYPE_NONE);
expbuf_push_num(buf, type);
Copy link
Member

Choose a reason for hiding this comment

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

Would the code become more concise if NEVERBLEED_TYPE_NONE could be used as an indication of an error, instead of sending a boolean value indicating success and the type value?
(and if we are to use the none type as error indication it might make more sense to rename it the error type)

Copy link
Contributor Author

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, you are suggesting that remove boolean (type != NEVERBLEED_TYPE_NONE), and rename neverbleed_type as neverbleed_error_type. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps, renaming NEVERBLEED_TYPE_NONE as NEVERBLEED_TYPE_ERROR ?

Copy link
Member

Choose a reason for hiding this comment

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

Correct.

At the moment, the arguments used for load_key are: ret, type, key_index, …

However, considering the fact that ret is a boolean that just indicates either success or failure and that we have NEVERBLEED_TYPE_NONE, it seems to me that the argument should better be: type, key_index, ..., merging the type and ret into a single argument.

So to rephrase my suggestion is:

  • change NEVERBLEED_TYPE_NONE to NEVERBLEED_TYPE_ERROR
  • stop passing ret as the first value of load_key, but use type != NEVERBLEED_TYPE_ERROR to see if the call has succeeded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for clarification. Will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@kazuho
Copy link
Member

kazuho commented Sep 1, 2016

Thank you for the changes.

The code looks great, however I left a comment since we might be possible to make it even better.

We renamed NEVERBLEED_TYPE_NONE as NEVERBLEED_TYPE_ERROR, and instead
of returning boolean value to indicate success/failure, we use type
for its purpose.  Now boolean value was removed.
@kazuho kazuho merged commit b7393f1 into h2o:master Sep 4, 2016
kazuho added a commit that referenced this pull request Sep 4, 2016
Add ECDSA support (named curve only, requires OpenSSL 1.1.0)
@kazuho
Copy link
Member

kazuho commented Sep 4, 2016

Thank you for the update! Merged to master.

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