PeculiarVentures / node-webcrypto-ossl

A WebCrypto Polyfill for Node in TypeScript built on OpenSSL.
MIT License
128 stars 40 forks source link

Support AES_CTR 256 #158

Closed witchent closed 4 years ago

witchent commented 4 years ago

As far as I can see the length for AES_CTR is capped at 128. Could you maybe add support for 256?

microshine commented 4 years ago

node-webcrypto-ossl has got tests for AES-CTR. It supports 128, 192, and 256 keys

image

See test logs

witchent commented 4 years ago

Thats weird, shouldn't this prevent it?:

    LOG_INFO("length");
    if (length < 1 || length > 128) {
        THROW_ERROR("Incorrect value 'length'. Must be between 1 and 128.");
    }

(From aes_ctr.cpp)

microshine commented 4 years ago

It's 'length' for encrypt and decrypt params AesCtrParams

witchent commented 4 years ago

Alright that makes sense. Sorry then, I just thought that this would be the case because signal complains about it and needs 256. But this seems to warrant another fork then. Thanks anyway :)

microshine commented 4 years ago

Chrome

image

witchent commented 4 years ago

Yep thats the one I think. Just changing 128 to 256 fixes it but I don't know if this would introduce more problems than help, so feel free to close this issue

rmhrisk commented 4 years ago

Not sure I understand. So signal is requiring something that the browser webcrypto does not support (256 bitlength)? And enabling this allows you to build signal desktop on this package?

witchent commented 4 years ago

Correct. But as I said in the other issue, while with this check changed to 256 it builds and runs fine, it still does not work (complaining about bad mac, which I actually think has nothing to do with the HMAC but rather with the curve crypto), so it wouldn't really help if you change it anyway.