crypto: fix Hash and Cipher abort on end
Fix Hash
and Cipher
aborting when using end
with hex
and specific lengths of chunks. The issue was caused because there was missing validation on the written content from the end
method. Note that this actually affects quite a few things in Crypto. This affects decipher/cipher (both deprecated) but also decipheriv/cipheriv as well as Hash and Hmac.
I wasn't sure if this should throw in _transform
or create an error and provide it to the callback, but according to the stream docs providing an error to the callback is what's expected - so I would love to get some input on my fix, and if it makes sense.