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

RangeError in authCipher.js #58

Open
linkdesu opened this issue Dec 7, 2018 · 4 comments
Open

RangeError in authCipher.js #58

linkdesu opened this issue Dec 7, 2018 · 4 comments
Assignees

Comments

@linkdesu
Copy link

linkdesu commented Dec 7, 2018

Hi, thanks for provide this package for aes support. When I try aes encrypt this error comes out, but it seems I can not fix it from outside.

Error message:

RangeError [ERR_OUT_OF_RANGE]: The value of "byteLength" is out of range. It must be >= 1 and <= 6. Received 8
            at boundsError (internal/buffer.js:55:9)
            at Buffer.writeUIntBE (internal/buffer.js:588:3)
            at webpack:///node_modules/browserify-aes/authCipher.js:37 <- index.js:7:174349
            at new u (webpack:///node_modules/browserify-aes/authCipher.js:52 <- index.js:7:174434)
            at Object.l (webpack:///node_modules/browserify-aes/encrypter.js:99 <- index.js:7:256315)
            at f (webpack:///node_modules/browserify-cipher/browser.js:45 <- index.js:7:245646)
            at Function.encrypt (webpack:///src/util/Crypto.js:82:34 <- index.js:7:237811)
            at Context.it (webpack:///test/unit/specs/util/Crypto.spec.js:8:30 <- index.js:7:232580)

Error code:

  ghash.update(Buffer.alloc(8, 0))
  var ivBits = len * 8
  var tail = Buffer.alloc(8)
  tail.writeUIntBE(ivBits, 0, 8) // <- here
  ghash.update(tail)
@linkdesu linkdesu changed the title RangeError in code RangeError in authCipher.js Dec 7, 2018
@calvinmetcalf calvinmetcalf self-assigned this Dec 7, 2018
@calvinmetcalf
Copy link
Contributor

this is actually fixed in #57

@linkdesu
Copy link
Author

THX a lot!

@kapouer
Copy link

kapouer commented Jan 6, 2019

The actual fix is

-  tail.writeUIntBE(ivBits, 0, 8)
+  tail.writeUIntBE(ivBits, 2, 6)

NB: this change works with node 4.8 and node 10.15 (because i tested both)

@ghost
Copy link

ghost commented Aug 19, 2020

That change never merged? Still getting this error.

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