Nuno Pestana
Nuno Pestana

Reputation: 37

Java AES/CBC/NoPadding equivalent in NodeJs

I have been assigned to decode tokens built in java using AES/CBC/NoPadding.

I am looking into node-forge and crypto for this. My problem is that I don't know what is the equivalent for the algorithm AES/CBC/NoPadding in NodeJs.

I'm using something like this:

var key = Array(xxx); // key.length = 16
var iv = new Buffer(16);
iv.fill(0);

var decipher = crypto.createDecipheriv("aes-128-ecb", key, iv);

As I searched, this createDecipheriv("aes-128-ecb" is equivalent to AES/CBC/PKCS5Padding. I though of decipher.setPadding(false) but I guess I'm in the wrong path).

Upvotes: 0

Views: 1943

Answers (1)

Nuno Pestana
Nuno Pestana

Reputation: 37

Using forge.cipher.createDecipher('AES-CBC', key); did the job...

Internally it uses padding, but I could overcome the issue adding some garbage before decryption and then taking care of the remaining garbage after internal padding.

Upvotes: 2

Related Questions