summaryrefslogtreecommitdiff
path: root/src/key_derivation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/key_derivation.c')
-rw-r--r--src/key_derivation.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/key_derivation.c b/src/key_derivation.c
index 6ceabb9..43277be 100644
--- a/src/key_derivation.c
+++ b/src/key_derivation.c
@@ -45,11 +45,12 @@
#include <stdlib.h>
#include <string.h>
-int key_derivation_init(key_derivation_t* kd, const char* type, int8_t ld_kdr, const char* passphrase, u_int8_t* key, u_int32_t key_len, u_int8_t* salt, u_int32_t salt_len)
+int key_derivation_init(key_derivation_t* kd, const char* type, int8_t ld_kdr, int8_t anytun02_compat, const char* passphrase, u_int8_t* key, u_int32_t key_len, u_int8_t* salt, u_int32_t salt_len)
{
if(!kd)
return -1;
+ kd->anytun02_compat_ = anytun02_compat;
kd->key_length_ = 0;
kd->type_ = kd_unknown;
@@ -391,8 +392,14 @@ int key_derivation_aesctr_calc_ctr(key_derivation_t* kd, key_store_dir_t dir, se
}
memcpy(params->ctr_.salt_.buf_, kd->master_salt_.buf_, KD_AESCTR_SALT_LENGTH);
params->ctr_.salt_.zero_ = 0;
- params->ctr_.params_.label_ ^= label;
- params->ctr_.params_.r_ ^= SEQ_NR_T_HTON(*r);
+ if(kd->anytun02_compat_) {
+ params->ctr_.params_compat_.label_ ^= label;
+ params->ctr_.params_compat_.r_ ^= SEQ_NR_T_HTON(*r);
+ }
+ else {
+ params->ctr_.params_.label_ ^= label;
+ params->ctr_.params_.r_ ^= SEQ_NR_T_HTON(*r);
+ }
return 1;
}