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

Bug: encrypting/decrypting large integers results in mismatched digits #5

Closed
psvet opened this issue Jul 11, 2016 · 4 comments
Closed
Labels

Comments

@psvet
Copy link

psvet commented Jul 11, 2016

Found when trying to store a Salesforce client secret.

Here's an example using a 19-digit integer (the length of the client secret):
screen shot 2016-07-11 at 2 32 42 pm

Notice the 400 ending the decrypted string, versus the 500 of the original. The same thing occurs using getsecret after storing the string in the config file.

Compare that with appending a letter to the integer, which works as expected:
screen shot 2016-07-11 at 2 39 54 pm

@psvet psvet added the bug label Jul 11, 2016
@TomFrost
Copy link
Owner

Replicated using the plaintext algorithm... this is wild:

╭─<tom@tom-ta>-<~/Projects/Cryptex>-<1bf19ad∙master∙▪>-<9:43PM>-◇
╰─➤ node src/cli.js encrypt 1234567890123400500
1234567890123400400

@TomFrost
Copy link
Owner

Looks like the issue is Javascript, rounding longs big-endian style.

> const int = 123456789012340045
undefined
> int
123456789012340050

@TomFrost
Copy link
Owner

The underlying issue is yargs parsing too-long numbers as a number instead of a string. Bug report logged here: yargs/yargs#550

In absence of any near-term motion on that ticket, I'll write a workaround that manually parses encrypt arguments from the original process.argv.

@TomFrost
Copy link
Owner

Fixed in v1.0.0. Thanks, yargs team!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants