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

ECDSA Alg improvements #276

Merged
merged 7 commits into from
Jan 27, 2019
Merged

ECDSA Alg improvements #276

merged 7 commits into from
Jan 27, 2019

Conversation

Spomky
Copy link
Contributor

@Spomky Spomky commented Nov 20, 2018

  • fgrosse/phpasn1 dependency removed
  • New Points Manipulator
  • Asn1 class removed
  • Add some tests from RFC6979 and RFC7520

Hi @lcobucci,

As discussed, here is a proposal to get ride of fgrosse/phpasn1 and fix trouble with that library.
This could be a first step to help with #259 by backporting this solution.

The class ECSignature may need to be improved as well.
Feel free to propose correction on that class if so.

@lcobucci
Copy link
Owner

lcobucci commented Nov 20, 2018

@Spomky thanks a lot for your contribution, it's quite nice to remove that dependency.

The only thing is that I'd prefer to keep the internal interface and the signature converter as an implementation of it. The main motivation is to isolate things and allow us to abstract that bit from the rest of the lib.

If you prefer, I can take it from here (I don't want to ask too much of you 😁)

@Spomky
Copy link
Contributor Author

Spomky commented Nov 21, 2018

I updated the PR and restored the PointsManipulator interface.
The class I added now implements that interface.

I will also take time to add more tests for these algorithms.

@lcobucci
Copy link
Owner

@Spomky thank you very much

@Spomky
Copy link
Contributor Author

Spomky commented Nov 21, 2018

Hi @lcobucci ,

I added some tests taken from the RFC6979.
The one from the RFC7520 cannot be added because the payload is not a JSON object and parsing exceptions are thrown (you may have an idea to integrate it).
Anyway it works fine now and the algorithms are slightly faster (approx. -25% of execution time). The only problem is that some mutations are not detected and I am not sure it will be easy to get ride of these.

Let me know if you have ideas to fix these metrics. I will modify my PR accordingly

Copy link
Owner

@lcobucci lcobucci left a comment

Choose a reason for hiding this comment

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

@Spomky I've rebased your branch and reorganised your commits a bit to make it easier to make modifications there.

These comments are minor things that I can adjust, if you agree and don't have time to do it 😄

We can adjust the MSI/Covered MSI for now and create the unit tests later on (specially for the exceptions raised in the new file) - don't worry too much about coverage.

I have a tiny question (please forgive my lack of knowledge regarding crypto): how can we test that the binary manipulation that we now have is not susceptible to vector/timing attacks? Since we were previously using a lib before I didn't bother much with that but now that we have the code here it feels like I'm responsible for providing a reliable solution.

Thanks a lot for this contribution 👍

composer.json Outdated Show resolved Hide resolved
src/Signer/Ecdsa/ECSignature.php Outdated Show resolved Hide resolved
src/Signer/Ecdsa/ECSignature.php Outdated Show resolved Hide resolved
src/Signer/Ecdsa/ECSignature.php Outdated Show resolved Hide resolved
src/Signer/Ecdsa/ECSignature.php Outdated Show resolved Hide resolved
src/Signer/Ecdsa/ECSignature.php Outdated Show resolved Hide resolved
src/Signer/Ecdsa/ECSignature.php Outdated Show resolved Hide resolved
src/Signer/Ecdsa/ECSignature.php Outdated Show resolved Hide resolved
test/functional/EcdsaTokenTest.php Outdated Show resolved Hide resolved
test/functional/EcdsaTokenTest.php Outdated Show resolved Hide resolved
@Spomky
Copy link
Contributor Author

Spomky commented Nov 30, 2018

Great. Thank you for the review.
I will take care of the modifications.

@Spomky Spomky changed the title ECDSA Alg improvements [WIP] ECDSA Alg improvements Dec 16, 2018
@Spomky
Copy link
Contributor Author

Spomky commented Dec 16, 2018

Hi @lcobucci,

I modified my PR few hours ago.
New deprecation notices from PHPUnit are catched now. Not sure it is important to fix these errors right now.
I am playing with my ECSignature class and trying to improve it a bit. Just let me few more days to get it working correctly.

@lcobucci
Copy link
Owner

@Spomky thanks a lot! I'm actually addressing those deprecations right now, so don't worry about them. Once I'm done you will be able to rebase your branch and sync it with master and things will be alright 👍

@Spomky
Copy link
Contributor Author

Spomky commented Jan 7, 2019

Hi @lcobucci

I hope everything is going well for you.
All the best for this new year 2019!

This PR looks good to me. I don't see any optimization at the moment.

@lcobucci
Copy link
Owner

lcobucci commented Jan 7, 2019

@Spomky alright I wasn't sure if you had finished. Thank you for your contribution, I'd take a look on it this week and get it merged in 👍

All the best for you too!

@Spomky Spomky changed the title [WIP] ECDSA Alg improvements ECDSA Alg improvements Jan 12, 2019
Spomky and others added 6 commits January 28, 2019 00:01
Detaching this library from any external package to perform ECDSA
signature creation and verification.
Making things clearer and easier to understand.
Since we're just converting things from/to hexadecimal, we can simply
rely on `bin2hex()/hex2bin()`. These are simpler and faster than
`pack()/unpack()`.
Refactoring the class a bit to reduce the amount of mutations and make
things a bit more understandable.
@lcobucci lcobucci self-assigned this Jan 27, 2019
@lcobucci lcobucci added this to the 4.0.0 milestone Jan 27, 2019
@lcobucci lcobucci merged commit a082133 into lcobucci:master Jan 27, 2019
@lcobucci lcobucci modified the milestones: 4.0.0, 4.0.0-alpha2 Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants