1
0
mirror of https://gitlab.labs.nic.cz/labs/bird.git synced 2024-05-11 16:54:54 +00:00

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.
This commit is contained in:
Toke Høiland-Jørgensen
2021-04-14 21:39:43 +02:00
committed by Ondrej Zajicek (work)
parent f1a824190c
commit 35f88b305a
7 changed files with 93 additions and 18 deletions

View File

@ -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: