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

Update curve25519.rb #153

Closed
wants to merge 4 commits into from

Conversation

paragonie-scott
Copy link
Contributor

See #152

@tarcieri
Copy link
Contributor

That's not quite valid Ruby syntax, although the build appears broken on 2.3+ for other reasons

@paragonie-scott
Copy link
Contributor Author

Hah, my Ruby kung-fu is weak.

I think that'll do the trick?

self.class.scalarmult_curve25519(result, integer, @point)
ret = self.class.scalarmult_curve25519(result, integer, @point)
if ret != 0
raise "Invalid curve25519 result"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably raise CryptoError

@tarcieri
Copy link
Contributor

I think the logic is inverted. This is causing several tests to fail?

@paragonie-scott
Copy link
Contributor Author

I thought it returned 0 upon success, and -1 on error?

@@ -61,7 +61,9 @@ def mult(integer)
Util.check_length(integer, SCALARBYTES, "integer")

result = Util.zeros(SCALARBYTES)
self.class.scalarmult_curve25519(result, integer, @point)
if self.class.scalarmult_curve25519(result, integer, @point) != 0
raise CryptoError "Invalid curve25519 result"
Copy link
Contributor

@tarcieri tarcieri Jan 27, 2017

Choose a reason for hiding this comment

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

Missing a comma here (should be raise CryptoError, "Invalid... go go wacky Ruby syntax), but the test failures seem to indicate this path is being taken in tests that are expected to pass.

This could probably use a test that triggers the offending behavior to ensure the error is raised as expected.

Copy link
Contributor

Choose a reason for hiding this comment

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

This wants to be written as unless self.class.scalarmult_curve25519(result, integer, @point)

The sodium_function wrapper that exposes the C API to ruby converts 0 returns from libsodium into true and all others into false.

Agreed on the need for a test to test this condition fails as expected though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. Thanks for the feedback! I'll get another commit pushed. :)

@tarcieri
Copy link
Contributor

tarcieri commented Mar 3, 2017

Well, the tests are passing again but it's failing on a style check (RuboCop, which you can run locally with rubocop -a to auto-correct errors)

Other than that, I think this just needs a test for the degenerate key case and it should be good to go.

tarcieri added a commit that referenced this pull request Mar 13, 2017
This fixes the RuboCop errors from @paragonie-scott's #153 PR, adds a test, and
adopts a belt-and-suspenders approach by trying to detect degenerate keys
eagerly (still also handling errors surfaced from libsodium itself)
tarcieri added a commit that referenced this pull request Mar 13, 2017
This fixes the RuboCop errors from @paragonie-scott's #153 PR, adds a test, and
adopts a belt-and-suspenders approach by trying to detect degenerate keys
eagerly (still also handling errors surfaced from libsodium itself)
@tarcieri
Copy link
Contributor

Merged as 8b3acc1

@tarcieri tarcieri closed this Mar 13, 2017
@paragonie-scott paragonie-scott deleted the patch-1 branch June 12, 2017 04:45
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