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

Allow CryptTrait to accept a \Defuse\Crypto\Key as encryption key #812 #814

Merged
merged 5 commits into from
Feb 28, 2018
Merged

Conversation

SunMar
Copy link
Contributor

@SunMar SunMar commented Nov 16, 2017

See #812 for details. This allows a Key object to be used as encryption key over an alphanumeric string which improves performance of encryption and decryption.

@SunMar SunMar changed the title Allow CryptTrait to accept a \Defuse\Crypto\Key as encryption key #812 Allow CryptTrait to accept a \Defuse\Crypto\Key as encryption key Nov 16, 2017
@SunMar SunMar changed the title Allow CryptTrait to accept a \Defuse\Crypto\Key as encryption key Allow CryptTrait to accept a \Defuse\Crypto\Key as encryption key #812 Nov 16, 2017
Copy link
Member

@Sephster Sephster left a comment

Choose a reason for hiding this comment

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

Looks good to me. The only thing I spotted was that we should update the docblocks for the setEncryptionKey functions in GrantTypeInterface and ResponseTypeInterface. I think once this change is made this will be good to merge in unless anyone has any objections. Thanks for creating the PR

@SunMar
Copy link
Contributor Author

SunMar commented Nov 20, 2017

@Sephster Ah yes, sorry, forgot about those interfaces. Phpdoc updated for the interfaces too.

@SunMar
Copy link
Contributor Author

SunMar commented Nov 21, 2017

I also updated the PR to remove some code duplication in the CryptTraitTest.

Copy link

@simonhamp simonhamp left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

Is it possible for the if statements in CrypTrait to be factored out by following the example set in the tests? I.e by using setEncryptionKey And doEncrypt/doDecrypt methods instead of encrypt/decrypt/WithPassword.

@SunMar
Copy link
Contributor Author

SunMar commented Nov 23, 2017

@simonhamp setEncryptionKey() is called by AuthorizationServer and is basically a pass-through for whatever encryption key is passed when doing a new AuthorizationServer, which is done by whoever is implementing this package and is not done by the package itself.

So I'm not really sure how to get rid of the if, because the library doesn't have control over whether the encryption is a string or a Key. This way it stays backwards compatible, if you pass a string it does the current implementation of encryptWithPassword() and only if you pass a Key it uses encrypt().

Note that in the tests doEncrypt() and doDecrypt() are just pass-throughs in the stub to encrypt() and decrypt() because they are protected and can't be called directly. See CryptTraitStub.

Copy link

@simonhamp simonhamp left a comment

Choose a reason for hiding this comment

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

That’s fine. Nice clean PR good to go from my POV

@SunMar
Copy link
Contributor Author

SunMar commented Jan 4, 2018

@Sephster Is the PR ok for you too? I updated the change you requested.

@Sephster Sephster merged commit cc19da5 into thephpleague:master Feb 28, 2018
@Sephster
Copy link
Member

Sorry for the delay in getting this reviewed @SunMar. I've made some minor changes but all looks good so merging in. Thanks for your patience and your contribution

Sephster added a commit that referenced this pull request Apr 22, 2018
Add new option to use \Defuse\Crypto\Key as encryption key #812 #814
EricTendian added a commit to EricTendian/passport that referenced this pull request Sep 10, 2018
EricTendian added a commit to EricTendian/passport that referenced this pull request Sep 10, 2018
EricTendian added a commit to EricTendian/passport that referenced this pull request Sep 10, 2018
EricTendian added a commit to EricTendian/passport that referenced this pull request Sep 10, 2018
EricTendian added a commit to EricTendian/passport that referenced this pull request Sep 11, 2018
…ption/decryption, when combined with oauth2-server package patch from thephpleague/oauth2-server#814
EricTendian added a commit to EricTendian/passport that referenced this pull request Sep 11, 2018
…ption/decryption, when combined with oauth2-server package patch from thephpleague/oauth2-server#814
EricTendian added a commit to EricTendian/passport that referenced this pull request Sep 11, 2018
…ption/decryption, when combined with oauth2-server package patch from thephpleague/oauth2-server#814
EricTendian added a commit to EricTendian/passport that referenced this pull request Sep 11, 2018
…ption/decryption, when combined with oauth2-server package patch from thephpleague/oauth2-server#814
EricTendian added a commit to EricTendian/passport that referenced this pull request Sep 11, 2018
…ption/decryption, when combined with oauth2-server package patch from thephpleague/oauth2-server#814
EricTendian added a commit to EricTendian/passport that referenced this pull request Sep 11, 2018
…ption/decryption, when combined with oauth2-server package patch from thephpleague/oauth2-server#814
EricTendian added a commit to EricTendian/oauth2-server that referenced this pull request Sep 13, 2018
EricTendian added a commit to EricTendian/oauth2-server that referenced this pull request Sep 13, 2018
EricTendian added a commit to EricTendian/oauth2-server that referenced this pull request Sep 13, 2018
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.

3 participants