summaryrefslogtreecommitdiff
path: root/src/node_crypto.h
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2018-09-22 00:56:16 +0200
committerDaniel Bevenius <daniel.bevenius@gmail.com>2018-09-26 05:27:02 +0200
commitb7bdde013a8abd09b6b486a9e452177a015db1a9 (patch)
treef1fec08b484e97a56671ed305eb73a70537f2718 /src/node_crypto.h
parent9b292272ff3d71a0ebabe46d040346dbd34585db (diff)
downloadandroid-node-v8-b7bdde013a8abd09b6b486a9e452177a015db1a9.tar.gz
android-node-v8-b7bdde013a8abd09b6b486a9e452177a015db1a9.tar.bz2
android-node-v8-b7bdde013a8abd09b6b486a9e452177a015db1a9.zip
crypto: deduplicate cipher initialization code
CipherBase::Init and CipherBase::InitIv contain a lot of duplicate code, this commit moves that into a separate function. PR-URL: https://github.com/nodejs/node/pull/23011 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Diffstat (limited to 'src/node_crypto.h')
-rw-r--r--src/node_crypto.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/node_crypto.h b/src/node_crypto.h
index 1a93ae7a47..714afd0d3b 100644
--- a/src/node_crypto.h
+++ b/src/node_crypto.h
@@ -370,14 +370,21 @@ class CipherBase : public BaseObject {
};
static const unsigned kNoAuthTagLength = static_cast<unsigned>(-1);
+ void CommonInit(const char* cipher_type,
+ const EVP_CIPHER* cipher,
+ const unsigned char* key,
+ int key_len,
+ const unsigned char* iv,
+ int iv_len,
+ unsigned int auth_tag_len);
void Init(const char* cipher_type,
const char* key_buf,
int key_buf_len,
unsigned int auth_tag_len);
void InitIv(const char* cipher_type,
- const char* key,
+ const unsigned char* key,
int key_len,
- const char* iv,
+ const unsigned char* iv,
int iv_len,
unsigned int auth_tag_len);
bool InitAuthenticated(const char* cipher_type, int iv_len,