Skip to content

Commit

Permalink
Add input size check to update() method
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorColomb committed Jul 4, 2022
1 parent 7d8efa4 commit 0359a9b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0359a9b

Please sign in to comment.