bitwiseshiftleft / sjcl

Stanford Javascript Crypto Library
http://bitwiseshiftleft.github.com/sjcl/
Other
7.18k stars 987 forks source link

Assigning the variable u breaks sjcl.encrypt #378

Open chausies opened 5 years ago

chausies commented 5 years ago

It's a problem that's easy to produce. If you open up the javascript console, run the code at bitwiseshiftleft.github.io/sjcl/sjcl.js (by pasting it in, for example), and then run

u = 10; // assign anything to u
e = sjcl.encrypt("pass", "mess");

You get the error TypeError: u is not a function. It seems that sjcl tries to use a global function called u. I don't think that this should be the case, and sjcl should be self-contained, allowing anyone to assign anything to u in their code.

sulfo commented 5 years ago

I have the same issue as you.

sjcl.min.js:1 Uncaught TypeError: u is not a function
    at sjcl.hash.sha256.finalize (sjcl.min.js:1)
    at sjcl.prng.randomWords (sjcl.min.js:1)
    at Object.ja (sjcl.min.js:1)
    at Object.encrypt (sjcl.min.js:1)
gabbifish commented 5 years ago

Same for variable t:

TypeError: t is not a function
    at sjcl.cipher.aes.encrypt (evalmachine.<anonymous>:4:55)
    at z (evalmachine.<anonymous>:48:471)
    at sjcl.prng.randomWords (evalmachine.<anonymous>:40:197)
    at Object.ja (evalmachine.<anonymous>:52:157)
    at Object.encrypt (evalmachine.<anonymous>:54:174)
    at sjcl.test.TestCase.doRun (evalmachine.<anonymous>:22:12)
    at evalmachine.<anonymous>:84:12
    at sjcl.test.TestCase.pauseAndThen (evalmachine.<anonymous>:4:33)
    at sjcl.test.TestCase.run (evalmachine.<anonymous>:83:10)
    at evalmachine.<anonymous>:106:29
gabbifish commented 5 years ago

Submitted a fix PR: https://github.com/bitwiseshiftleft/sjcl/pull/381