WebCrypto: fix use after free of BufferSource arguments
Previously, the QuickJS WebCrypto methods took borrowed pointers to
the bytes of BufferSource arguments and algorithm members, and then
read further algorithm members. Getters and valueOf() of those
members could detach or resize the underlying ArrayBuffer, or drop the
last reference to a temporary buffer, so OpenSSL read freed memory.
This affected encrypt(), decrypt(), sign(), verify(), deriveBits(),
deriveKey(), importKey(), wrapKey() and unwrapKey().
Now all algorithm members are read before the bytes of the data
argument are taken, and no JavaScript code runs while the bytes are
in use, avoiding copies of inputs of up to 2 GiB. BufferSource
algorithm members (iv, counter, additionalData, salt, info) are
copied when read, and members are read in lexicographic order, as
WebIDL dictionary conversion does. Detached buffers are rejected
with TypeError, matching other njs modules.
The issue was introduced in
75ca26f8 (0.8.10).