From 71fe0c48ea3a00048bbdd68f8e4a3b58793eda9c Mon Sep 17 00:00:00 2001 From: Seongsik Kim Date: Fri, 22 Jan 2021 13:43:06 +0900 Subject: [PATCH] [APR-6839]libcharon: Provide a property option for rekeying [JIRA]: SOC-130596 [Problem/Cause]: Depending on the carrier requirements, messages should be checked to confirm pass/fail in some test cases. [Solution]: Provide a property that shows the oriGin Session keys. Change-Id: Ic5d28edf9c3ed805a020fff68c3662f6cc978c6e Signed-off-by: Seongsik Kim --- src/libcharon/Android.mk | 2 -- src/libcharon/re_key/re_key.c | 22 ++++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/libcharon/Android.mk b/src/libcharon/Android.mk index 3edd594..59cde50 100755 --- a/src/libcharon/Android.mk +++ b/src/libcharon/Android.mk @@ -155,9 +155,7 @@ LOCAL_SRC_FILES := $(filter %.c,$(libcharon_la_SOURCES)) # adding the plugin source files LOCAL_SRC_FILES += $(call add_plugin, android-dns) -ifneq ($(call plugin_enabled, android-dns),) LOCAL_SHARED_LIBRARIES += libcutils -endif LOCAL_SRC_FILES += $(call add_plugin, android-log) ifneq ($(call plugin_enabled, android-log),) diff --git a/src/libcharon/re_key/re_key.c b/src/libcharon/re_key/re_key.c index a3f9ebb..63c4746 100644 --- a/src/libcharon/re_key/re_key.c +++ b/src/libcharon/re_key/re_key.c @@ -3,6 +3,7 @@ #include #include #include +#include #define REKEY_MAX_BYTE 256 #define HEX_STR_LEN 4 @@ -10,6 +11,8 @@ #define E_NUM 7 #define N_NUM 407 +#define SHOW_KEY_PROPERTY "vendor.charon.showkey" + /** * Computes a^b mod c */ @@ -29,13 +32,16 @@ int powmod(long long a, long long b, int c) { * Print Encrypt original secret codes */ void rekey_secret_code(chunk_t *ori_chunk, char *key_name) { - char rekey_str[REKEY_MAX_BYTE] = {0}; - char val[HEX_STR_LEN]; + if (property_get_bool(SHOW_KEY_PROPERTY, 0)) { + DBG1(DBG_IKE, "%s secret %B", key_name, ori_chunk); + } else { + char rekey_str[REKEY_MAX_BYTE] = {0}; + char temp_str[HEX_STR_LEN]; - for(int i = 0; i < ori_chunk->len ; i++) { - sprintf(val,"%03d", powmod(ori_chunk->ptr[i], E_NUM, N_NUM) ); - strncat(rekey_str, val, 3); + for(int i = 0; i < ori_chunk->len ; i++) { + sprintf(temp_str, "%03d", powmod(ori_chunk->ptr[i], E_NUM, N_NUM)); + strncat(rekey_str, temp_str, 3); + } + DBG1(DBG_IKE, "%s : %s", key_name, rekey_str); } - - DBG1(DBG_IKE, "%s : %s", key_name, rekey_str); -} \ No newline at end of file +} -- 2.20.1