crypto: throw in setAuthTag on invalid length by tniessen · Pull Request #20040 · nodejs/node

@nodejs-github-bot added c++

Issues and PRs that require attention from people who are familiar with C++.

crypto

Issues and PRs related to the crypto subsystem.

labels

Apr 15, 2018

richardlau

@mscdex mscdex added the wip

Issues and PRs that are still a work in progress.

label

May 8, 2018

@tniessen tniessen changed the title crypto: remove conditional assignment in setAuthTag crypto: throw in setAuthTag on invalid length

May 21, 2018

@tniessen

The current implementation performs limited checks only and silently
ignores superfluous bytes of the authentication tag. This change makes
setAuthTag throw when
- the user-specified authTagLength does not match the actual tag length,
  especially when the authentication tag is longer than 16 bytes, and
  when
- the mode is GCM, no authTagLength option has been specified and the
  tag length is not a valid GCM tag length.

This change makes the conditional assignment in SetAuthTag unnecessary,
which is replaced with a CHECK.

Refs: nodejs#17825

@tniessen tniessen added the semver-major

PRs that contain breaking changes and should be released in the next major version.

label

May 23, 2018

@tniessen tniessen removed the wip

Issues and PRs that are still a work in progress.

label

May 23, 2018

bnoordhuis

tniessen added a commit that referenced this pull request

Jun 1, 2018
The current implementation performs limited checks only and silently
ignores superfluous bytes of the authentication tag. This change makes
setAuthTag throw when
- the user-specified authTagLength does not match the actual tag length,
  especially when the authentication tag is longer than 16 bytes, and
  when
- the mode is GCM, no authTagLength option has been specified and the
  tag length is not a valid GCM tag length.

This change makes the conditional assignment in SetAuthTag unnecessary,
which is replaced with a CHECK.

Refs: #17825

PR-URL: #20040
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Yihong Wang <yh.wang@ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>