summaryrefslogtreecommitdiff
path: root/nest
diff options
context:
space:
mode:
authorToke Høiland-Jørgensen <toke@toke.dk>2021-04-14 21:39:43 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2021-06-06 16:28:18 +0200
commit35f88b305ab6a0e27b5ff1b445f63f544986e14e (patch)
tree76051c919ed62297191e1b18eab1525429b43068 /nest
parentf1a824190c22f8159ad0f9378c2dd23e521eaf61 (diff)
Nest: Allow specifying security keys as hex bytes as well as strings
Add support for specifying a password in hexadecimal format, The result is the same whether a password is specified as a quoted string or a hex-encoded byte string, this just makes it more convenient to input high-entropy byte strings as MAC keys.
Diffstat (limited to 'nest')
-rw-r--r--nest/config.Y38
1 files changed, 21 insertions, 17 deletions
diff --git a/nest/config.Y b/nest/config.Y
index 98820646..8bd89de0 100644
--- a/nest/config.Y
+++ b/nest/config.Y
@@ -37,6 +37,25 @@ iface_patt_check(void)
cf_error("Interface name/mask expected, not IP prefix");
}
+static inline void
+init_password(const void *key, uint length, uint id)
+{
+ if (!this_p_list) {
+ this_p_list = cfg_allocz(sizeof(list));
+ init_list(this_p_list);
+ password_id = 1;
+ }
+ this_p_item = cfg_allocz(sizeof (struct password_item));
+ this_p_item->password = key;
+ this_p_item->length = length;
+ this_p_item->genfrom = 0;
+ this_p_item->gento = TIME_INFINITY;
+ this_p_item->accfrom = 0;
+ this_p_item->accto = TIME_INFINITY;
+ this_p_item->id = id;
+ this_p_item->alg = ALG_UNDEFINED;
+ add_tail(this_p_list, &this_p_item->n);
+}
static inline void
reset_passwords(void)
@@ -490,23 +509,8 @@ password_item:
;
password_item_begin:
- PASSWORD text {
- if (!this_p_list) {
- this_p_list = cfg_allocz(sizeof(list));
- init_list(this_p_list);
- password_id = 1;
- }
- this_p_item = cfg_allocz(sizeof(struct password_item));
- this_p_item->password = $2;
- this_p_item->length = strlen($2);
- this_p_item->genfrom = 0;
- this_p_item->gento = TIME_INFINITY;
- this_p_item->accfrom = 0;
- this_p_item->accto = TIME_INFINITY;
- this_p_item->id = password_id++;
- this_p_item->alg = ALG_UNDEFINED;
- add_tail(this_p_list, &this_p_item->n);
- }
+ PASSWORD text { init_password($2, strlen($2), password_id++); }
+ | PASSWORD BYTESTRING { init_password($2->data, $2->length, password_id++); }
;
password_item_params: