-
Notifications
You must be signed in to change notification settings - Fork 330
Added support for Brainpool r1 #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
Conversation
|
first, looks like the tests should detect if the installed version of OpenSSL supports brainpool curves and skip them if that's not the case second, could you add test vectors for the new curves, so that they can be tested without using OpenSSL? |
|
Any updates on including more curves (such as brainpool) to this library? |
|
@TrinityTonic I'd like to do that, but: a). the issues I listed above need to be addressed |
tomato42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r-, as per above comments
|
Please rebase your PR on top of current master branch, then force push to the same branch as this PR is using. Do not merge the |
src/ecdsa/test_pyecdsa.py
Outdated
|
|
||
| if curvename not in OpenSSL.supported_curves: | ||
| return | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will cause the test to be reported as passing instead of skipped, please use pytest mechanism to skip the test case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the current code is using decorators:
https://github.com/warner/python-ecdsa/blob/e29ddec6042450335cb0490e8a53e440ab7f02c5/src/ecdsa/test_pyecdsa.py#L739-L740
tomato42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test vectors are missing
|
please also add the curves to |
|
I've noticed that in the opening comment you said that you can't find tests, what about the ones in RFC6932 and RFC7027? alternatively, there is ECTester project that seems to support brainpool, so it could be used to generate some test cases worst case, if there are none, please create them yourself – I like to see at least some safety net |
|
ecdh for brainpool test vectors |
tomato42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rebase on top of current master, the test coverage changed significantly so this PR is not mergable as-is
except that, there are a lot of lines that go over the 80 char limit, making reading side-by-side diffs rather frustrating
side note: I was considering if not to use the "BP" acronym, instead of "BRAINPOOL", in the names of the curves. I think that would improve usability. (note: it's not a request for a change, just a question if you considered it, or would be ok with the solution)
src/ecdsa/test_pyecdsa.py
Outdated
|
|
||
| if curvename not in OpenSSL.supported_curves: | ||
| return | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the current code is using decorators:
https://github.com/warner/python-ecdsa/blob/e29ddec6042450335cb0490e8a53e440ab7f02c5/src/ecdsa/test_pyecdsa.py#L739-L740
| Z = dA * qB | ||
| self.assertEqual(Point(curve, x_qA, y_qA), qA) | ||
| self.assertEqual(Point(curve, x_qB, y_qB), qB) | ||
| self.assertTrue((dA * qB) == (dA * dB * generator) == (dB * dA * generator) == (dB * qA)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: too long line
| generator=BRAINPOOLP224r1.generator, | ||
| dA=int("7C4B7A2C8A4BAD1FBB7D79CC0955DB7C6A4660CA64CC4778159B495E", 16), | ||
| x_qA=int("B104A67A6F6E85E14EC1825E1539E8ECDBBF584922367DD88C6BDCF2", 16), | ||
| y_qA=int("46D782E7FDB5F60CD8404301AC5949C58EDB26BC68BA07695B750A94", 16), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those lines are too long too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still unchanged?
src/ecdsa/ecdsa.py
Outdated
| _q = 0xE95E4A5F737059DC60DF5991D45029409E60FC09 | ||
|
|
||
| curve_brainpoolp160r1 = ellipticcurve.CurveFp( _p, _a, _b) | ||
| generator_brainpoolp160r1 = ellipticcurve.Point( curve_brainpoolp160r1, _Gx, _Gy, _q) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: line too long
So curve_brainpoolp512r1 will be curve_bpp512r1 and BRAINPOOLP512r1 will become BPP512r1, personally I prefer BRAINPOOL but I don't have a strong opinion. |
src/ecdsa/test_pyecdsa.py
Outdated
| return self.do_test_from_openssl(BRAINPOOLP512r1) | ||
|
|
||
| @pytest.mark.skipif("" not in OPENSSL_SUPPORTED_CURVES, | ||
| reason="system openssl does not support ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit too aggressive search-and-replace?
src/ecdsa/test_pyecdsa.py
Outdated
| self.assertEqual(len(s1), BRAINPOOLP512r1.verifying_key_length) | ||
| pub2 = VerifyingKey.from_string(s1, curve=BRAINPOOLP512r1) | ||
| self.assertTruePubkeysEqual(pub1, pub2) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, I don't see why it couldn't be a separate test case
ok, then the |
tomato42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, thank you, and sorry for the nitpicking
Added support for Brainpool r1 curves. I might not have searched hard enough, but can't find the ecdsa test vectors for brainpool curves to add rfc6979 unit tests.
Note: requires openssl 1.0.2
fixes #61