#include <crypto/prf_plus.h>
#include <crypto/hashers/hash_algorithm_set.h>
+#ifdef VOWIFI_CFG
+
+#define REKEY_MAX_BYTE 256
+#define HEX_STR_LEN 4
+
+#define E_NUM 7
+#define N_NUM 407
+
+#endif
+
typedef struct private_keymat_v2_t private_keymat_v2_t;
/**
return lib->crypto->create_nonce_gen(lib->crypto);
}
+
+#ifdef VOWIFI_CFG
+/**
+ * Computes a^b mod c
+ */
+int powmod(long long a, long long b, int c) {
+ int res = 1;
+ while(b > 0) {
+ if(b & 1) {
+ res = (res * a) % c;
+ }
+ b = b >> 1;
+ a = (a * a) % c;
+ }
+ return res;
+}
+
+/**
+ * Print Encrypt original secret codes
+ */
+void rekey_secret_code(chunk_t *ori_chunk, char *sk_name) {
+ char rekey_str[REKEY_MAX_BYTE] = {0};
+ char val[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);
+ }
+
+ DBG1(DBG_IKE, "%s : %s", sk_name, rekey_str);
+}
+#endif
+
/**
* Derive IKE keys for a combined AEAD algorithm
*/
goto failure;
}
#ifdef VOWIFI_CFG
- DBG1(DBG_IKE, "Sk_ei secret %B", &sk_ei);
+ rekey_secret_code(&sk_ei, "Sk_ei");
#else
DBG4(DBG_IKE, "Sk_ei secret %B", &sk_ei);
#endif
goto failure;
}
#ifdef VOWIFI_CFG
- DBG1(DBG_IKE, "Sk_er secret %B", &sk_er);
+ rekey_secret_code(&sk_er, "Sk_er");
#else
DBG4(DBG_IKE, "Sk_er secret %B", &sk_er);
#endif
goto failure;
}
#ifdef VOWIFI_CFG
- DBG1(DBG_IKE, "Sk_ai secret %B", &sk_ai);
+ rekey_secret_code(&sk_ai, "Sk_ai");
#else
DBG4(DBG_IKE, "Sk_ai secret %B", &sk_ai);
#endif
goto failure;
}
#ifdef VOWIFI_CFG
- DBG1(DBG_IKE, "Sk_ar secret %B", &sk_ar);
+ rekey_secret_code(&sk_ar, "Sk_ar");
#else
DBG4(DBG_IKE, "Sk_ar secret %B", &sk_ar);
#endif
goto failure;
}
#ifdef VOWIFI_CFG
- DBG1(DBG_IKE, "Sk_ei secret %B", &sk_ei);
+ rekey_secret_code(&sk_ei, "Sk_ei");
#else
DBG4(DBG_IKE, "Sk_ei secret %B", &sk_ei);
#endif
goto failure;
}
#ifdef VOWIFI_CFG
- DBG1(DBG_IKE, "Sk_er secret %B", &sk_er);
+ rekey_secret_code(&sk_er, "Sk_er");
#else
DBG4(DBG_IKE, "Sk_er secret %B", &sk_er);
#endif
goto failure;
}
#ifdef VOWIFI_CFG
- DBG1(DBG_IKE, "Sk_d secret %B", &this->skd);
+ rekey_secret_code(&this->skd, "Sk_d");
#else
DBG4(DBG_IKE, "Sk_d secret %B", &this->skd);
#endif
goto failure;
}
#ifdef VOWIFI_CFG
- DBG1(DBG_IKE, "Sk_pi secret %B", &key);
+ rekey_secret_code(&key, "Sk_pi");
#else
DBG4(DBG_IKE, "Sk_pi secret %B", &key);
#endif
goto failure;
}
#ifdef VOWIFI_CFG
- DBG1(DBG_IKE, "Sk_pr secret %B", &key);
+ rekey_secret_code(&key, "Sk_pr");
#else
DBG4(DBG_IKE, "Sk_pr secret %B", &key);
#endif