From 9fbd87dcd8a0913a54fed36955b6fbee8eeb2b3e Mon Sep 17 00:00:00 2001 From: zjfsharp Date: Wed, 8 Jul 2020 12:38:40 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=AD=97=E7=AC=A6=E4=B8=B2=E9=81=87?= =?UTF-8?q?=E5=88=B00=E6=88=AA=E6=96=AD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/encryption/src/constant/constant_model.h | 2 ++ deploy/encryption/src/util/system_utils.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/deploy/encryption/src/constant/constant_model.h b/deploy/encryption/src/constant/constant_model.h index 8be7054..3e01e33 100644 --- a/deploy/encryption/src/constant/constant_model.h +++ b/deploy/encryption/src/constant/constant_model.h @@ -10,6 +10,8 @@ const static int MAGIC_NUMBER_LEN = 6; const static int VERSION_LEN = 1; const static int TAG_LEN = 128; +const static int CONSTANT_AES_GCM_KEY_LEN = 32; + } diff --git a/deploy/encryption/src/util/system_utils.cpp b/deploy/encryption/src/util/system_utils.cpp index 15506b1..de8c24d 100644 --- a/deploy/encryption/src/util/system_utils.cpp +++ b/deploy/encryption/src/util/system_utils.cpp @@ -34,7 +34,7 @@ std::string SystemUtils::random_str(int len) { } int SystemUtils::check_key_match(const char* key, const char* filepath) { - std::string aes_key_iv(key); + std::string aes_key_iv(key, key + constant::CONSTANT_AES_GCM_KEY_LEN); std::string sha256_aes_key_iv = util::crypto::SHA256Utils::sha256_string(aes_key_iv); unsigned char* data_pos = (unsigned char*) malloc(sizeof(unsigned char) * 64); -- GitLab