diff --git a/deploy/encryption/src/constant/constant_model.h b/deploy/encryption/src/constant/constant_model.h index 8be7054082dd05cfa833a7c5486c9e6554ff5bc5..3e01e330587d64fa6b8eac279e1dabf3699fc075 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 15506b10a93a7cd0aa80f7f43d23cebd96a7a108..de8c24d337e3022b795d87be12f2cc1a1bb0d898 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);