diff --git a/README.md b/README.md index d26da8f..6ed74ad 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ Create a new hash instance. `digestLength` defaults to `32`. Update the hash with a new piece of data. `data` should be a buffer or uint8array. +The size of the data is limited to `65536000 - 64 - 216*n` bytes, where `n` is the number of Blake2b instances. + #### `var digest = hash.digest([enc])` Digest the hash. diff --git a/index.js b/index.js index 26ea867..6f50b64 100644 --- a/index.js +++ b/index.js @@ -79,6 +79,7 @@ Blake2b.prototype._realloc = function (size) { Blake2b.prototype.update = function (input) { assert(this.finalized === false, 'Hash instance finalized') assert(input instanceof Uint8Array, 'input must be Uint8Array or Buffer') + assert(input.length + head <= 65536000, 'input + head must be of size 65,536,000 or less') if (head + input.length > this._memory.length) this._realloc(head + input.length) this._memory.set(input, head)