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

16 bytes of leading zeros #112

Closed
hcombination opened this issue Apr 4, 2017 · 2 comments
Closed

16 bytes of leading zeros #112

hcombination opened this issue Apr 4, 2017 · 2 comments

Comments

@hcombination
Copy link

Hi im moving a program from python to node and im getting leading zeros in my cipher text with node-sodium. Some test data is shown below. Anyone else see the same thing?

pk e7 17 e6 9b 87 a3 ec da c7 09 b0 88 77 f7 5b 94 57 3d b6 92 bd 1e c3 e2 fc b4 2b a7 d7 b6 0d 4b
sk f9 b1 5a 4d de 90 44 93 31 f4 c9 eb b8 ee f3 1d 69 03 23 a9 eb 26 61 28 e3 b6 08 da c1 c0 d7 85
nonce 35 38 64 63 31 66 64 30 63 39 32 66 0 0 0 0 0 0 0 0 0 0 0 0
shared b2 f6 63 de 3d 98 58 8e 91 e7 b3 e5 8c c7 c7 d2 5f cf 06 4f df 7f ad ea 3a da 4e 3f c8 db 3b d8

PlainText
12 34 01 00 00 01 00 00 00 00
00 01 03 77 77 77 03 62 62 63
02 63 6f 02 75 6b 00 00 01 00
01 00 00 29 04 e4 00 00 00 00
00 00 80`

Expected
ae 67 0b 3d c0 78 a3 e5 aa 7b
90 de f7 f5 46 45 a3 4d 27 96
69 11 c7 91 74 44 e5 48 69 2a
f4 38 e2 8c c4 c5 8f 1f f9 e0
5e 8c b0 c0 be 8b 72 ea cd 8c
71 7a cf 66 53 96 fc 98 3c

Got
00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 ae 67 0b 3d
c0 78 a3 e5 aa 7b 90 de f7 f5
46 45 a3 4d 27 96 69 11 c7 91
74 44 e5 48 69 2a f4 38 e2 8c ...

Tried both
sodiumApi.crypto_box(plainText, nonce, this.cert.pk, this.sk);
sodiumApi.crypto_box_afternm(plainText, nonce, this.shared)

Windows x64 Node v6.10.1

@rflaperuta
Copy link

rflaperuta commented Apr 5, 2017

Leading or Trailing?
Looks like it is related to #101 isn't it?

@paixaop
Copy link
Owner

paixaop commented Nov 16, 2018

Box pads the output with zeros this is what the Sodium library it self returns. Maybe the developer of the python version stripped the zeros.

@paixaop paixaop closed this as completed Nov 16, 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

No branches or pull requests

3 participants