Closed CluEleSsUK closed 1 year ago
Converting to a draft so nobody merges it until I'll I've done some perf testing
So I've successfully tested this with a payload of 2^28 chars. Theoretically V8 should be able to handle 2^29 - 24 chars, but when I try with this I get the error Error: Cannot create a string longer than 0x1fffffe8 characters
... which equates to 2^29 -24 haha. Tried a few lower just in case it's a funky bounds check, but to no avail.
Either way, I think this is a reasonable limitation for now.
If people have a use case for encrypting massive payloads they may have to resort to the go lib or do some fiddling themselves.
due to using a counter size of 32bits in the stream cipher, only up to 256TB may be encrypted before a nonce reuse would occur. This solution checks if the counter has reached the limit on every increment. This may add overhead or may be free on some engines and I haven't benchmarked it