Forge bug in Chrome Extension : decipher.start() - TypeError: e.length is not a function
h4n0sh1 opened this issue · comments
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 :
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 ?