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

Forge bug in Chrome Extension : decipher.start() - TypeError: e.length is not a function #1051

Open
h4n0sh1 opened this issue Oct 2, 2023 · 0 comments

Comments

@h4n0sh1
Copy link

h4n0sh1 commented Oct 2, 2023

Hi,

I am trying to leverage forge inside a chrome extension.

I was able to import forge.all.min.js through the content script section of the manifest, like so :

[{
  "name": "XXX",
  "description": "XXXX",
  "version": "0.0.0.13",
  "manifest_version": 3,
  "background": {
    "service_worker": "background.js"
  },
  ...
  "content_scripts": [{
    "matches": ["*://*/*"],
    "all_frames": true,
    "js": [
      "jquery.js", 
      "content.js",
      "crypto.js",
       .....
      "node_modules/sjcl/sjcl.js",
      "node_modules/node-forge/dist/forge.all.min.js"
    ]
  }],
  "web_accessible_resources": [{
     ...
  }]
}]

I made the following code to test it out, it seems like the util library works just fine and i am able to parse the base64 inputs into binary array, however the decipher.start() method bugs out.

{
function test_it(ct, key, iv){
    console.log("@@@@@ ---- Crypto segment ---- @@@@@@")
    console.log("Cipher text", ct, "Key", key, "IV", iv)
    var decipher = forge.cipher.createDecipher('3DES-CBC', forge.util.binary.base64.decode(key))
    x = forge.util.binary.base64.decode(ct)
    console.log("ct",x)
    console.log("Loading iv into decipher ...")
    y = forge.util.binary.base64.decode(iv)
    console.log("iv",y)
    decipher.start({iv: y})
    console.log("Deciphering ....")
    //decipher.update(x)
    console.log(decipher.output.toHex())
    console.log("@@@@@ ---- Crypto segment ---- @@@@@@")
}

This code gets called directly in the browser page and produces the following result :

forge

The blocking line is decipher.start({iv: y}), could you provide me with some ideas on where this may come from / what i'm missing ?

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

1 participant