Commit 5e2b6713 authored by Karel Slaný's avatar Karel Slaný Committed by Ondřej Surý

Fixed issue related to nonce value computation.

parent b0d1a920
......@@ -182,7 +182,7 @@ int kr_answer_write_cookie(const struct knot_sc_private *srvr_data,
return kr_error(EINVAL);
}
uint16_t nonce_len = NONCE_LEN;
uint16_t nonce_len = KR_NONCE_LEN;
uint16_t hash_len = alg->hash_size;
uint8_t *cookie = NULL;
......
......@@ -22,12 +22,12 @@
int kr_nonce_write_wire(uint8_t *buf, uint16_t *buf_len,
struct kr_nonce_input *input)
{
if (!buf || !buf_len || !input) {;
if (!buf || !buf_len || !input) {
return kr_error(EINVAL);
}
if (*buf_len < NONCE_LEN) {
kr_error(EINVAL);
if (*buf_len < KR_NONCE_LEN) {
return kr_error(EINVAL);
}
uint32_t aux = htonl(input->rand);
......@@ -35,7 +35,7 @@ int kr_nonce_write_wire(uint8_t *buf, uint16_t *buf_len,
aux = htonl(input->time);
memcpy(buf + sizeof(aux), &aux, sizeof(aux));
*buf_len = 2 * sizeof(aux);
assert(NONCE_LEN == *buf_len);
assert(KR_NONCE_LEN == *buf_len);
return kr_ok();
}
......@@ -22,7 +22,7 @@
* actual server cookie hash. */
/** Nonce value length. */
#define NONCE_LEN 8
#define KR_NONCE_LEN 8
/** Input data to generate nonce from. */
struct kr_nonce_input {
......
......@@ -435,7 +435,7 @@ static int cookie_answer(const void *clnt_sockaddr,
}
/* Check server cookie only with current settings. */
ret = knot_sc_check(NONCE_LEN, cookies, &srvr_data,
ret = knot_sc_check(KR_NONCE_LEN, cookies, &srvr_data,
kr_sc_algs[srvr_sett->current.alg_id]);
if (ret != KNOT_EOK) {
/* RFC7873 5.4 */
......
......@@ -411,7 +411,7 @@ int check_request(knot_layer_t *ctx, void *module_param)
/* Check server cookie obtained in request. */
ret = knot_sc_check(NONCE_LEN, &cookies, &srvr_data,
ret = knot_sc_check(KR_NONCE_LEN, &cookies, &srvr_data,
kr_sc_algs[srvr_sett->current.alg_id]);
if (ret == KNOT_EINVAL &&
srvr_sett->recent.secr && (srvr_sett->recent.alg_id >= 0)) {
......@@ -421,7 +421,7 @@ int check_request(knot_layer_t *ctx, void *module_param)
.secret_data = srvr_sett->recent.secr->data,
.secret_len = srvr_sett->recent.secr->size
};
ret = knot_sc_check(NONCE_LEN, &cookies, &recent_srvr_data,
ret = knot_sc_check(KR_NONCE_LEN, &cookies, &recent_srvr_data,
kr_sc_algs[srvr_sett->recent.alg_id]);
}
if (ret != KNOT_EOK) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment