From 2b2ccae390411b30daacc860c0e4380dbf7b308b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sun, 15 Apr 2018 14:51:24 +0200 Subject: [PATCH] crypto: support authTagLength in GCM encryption The authTagLength option can now be used to produce GCM authentication tags with a specific length. Backport-PR-URL: https://github.com/nodejs/node/pull/20706 PR-URL: https://github.com/nodejs/node/pull/20235 Refs: https://github.com/nodejs/node/pull/20039 Reviewed-By: James M Snell Reviewed-By: Yihong Wang Reviewed-By: Ben Noordhuis --- doc/api/crypto.md | 17 +++++++++++-- src/node_crypto.cc | 7 +++--- test/parallel/test-crypto-authenticated.js | 29 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 173e9d55583e49..3fce0534d8c94b 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1316,6 +1316,11 @@ This property is deprecated. Please use `crypto.setFips()` and > 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.