From 40c014f6ec9056fe32bfe13874dadf0690d45570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Fri, 13 Apr 2018 18:02:46 +0200 Subject: [PATCH 01/12] crypto: allow to restrict valid GCM tag length This change allows users to restrict accepted GCM authentication tag lengths to a single value. PR-URL: https://github.com/nodejs/node/pull/20039 Fixes: https://github.com/nodejs/node/issues/17523 Reviewed-By: James M Snell Reviewed-By: Yihong Wang Reviewed-By: Ben Noordhuis --- doc/api/crypto.md | 8 ++++- src/node_crypto.cc | 38 +++++++++++++++++--- src/node_crypto.h | 3 +- test/parallel/test-crypto-authenticated.js | 40 ++++++++++++++++++++++ 4 files changed, 82 insertions(+), 7 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index b98693466a8efd..173e9d55583e49 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1454,6 +1454,10 @@ to create the `Decipher` object. > Stability: 0 - Deprecated: Use [`crypto.createCipheriv()`][] instead. @@ -1331,7 +1336,9 @@ Creates and returns a `Cipher` object that uses the given `algorithm` and The `options` argument controls stream behavior and is optional except when a cipher in CCM mode is used (e.g. `'aes-128-ccm'`). In that case, the `authTagLength` option is required and specifies the length of the -authentication tag in bytes, see [CCM mode][]. +authentication tag in bytes, see [CCM mode][]. In GCM mode, the `authTagLength` +option is not required but can be used to set the length of the authentication +tag that will be returned by `getAuthTag()` and defaults to 16 bytes. The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On recent OpenSSL releases, `openssl list -cipher-algorithms` @@ -1362,6 +1369,10 @@ Adversaries][] for details.