From 2bfeb9dfb3dffb366eb0347fa24775e1bda88db1 Mon Sep 17 00:00:00 2001 From: Rajasekharan Vengalil Date: Thu, 11 Apr 2019 18:35:20 -0700 Subject: [PATCH] Load encryption key from file system before generating it --- edgelet/hsm-sys/azure-iot-hsm-c/src/edge_hsm_client_store.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/edgelet/hsm-sys/azure-iot-hsm-c/src/edge_hsm_client_store.c b/edgelet/hsm-sys/azure-iot-hsm-c/src/edge_hsm_client_store.c index 37c27f1f93b..feb42b53f09 100644 --- a/edgelet/hsm-sys/azure-iot-hsm-c/src/edge_hsm_client_store.c +++ b/edgelet/hsm-sys/azure-iot-hsm-c/src/edge_hsm_client_store.c @@ -2676,6 +2676,12 @@ static int edge_hsm_client_store_insert_encryption_key LOG_DEBUG("HSM store already has encryption key set %s", key_name); result = 0; } + else if ((load_encryption_key_from_file(g_crypto_store, key_name) == 0) && + key_exists((CRYPTO_STORE*)handle, HSM_KEY_ENCRYPTION, key_name)) + { + LOG_DEBUG("HSM store already has encryption key set %s", key_name); + result = 0; + } else { size_t key_size = 0;