Commit 525ac6b7 authored by Karel Slaný's avatar Karel Slaný Committed by Ondřej Surý

Removed input/output parameter from kr_nonce_write_wire().

parent 718678de
......@@ -206,7 +206,7 @@ int kr_answer_write_cookie(const struct knot_sc_private *srvr_data,
memcpy(cookie, cc, cc_len);
if (nonce_len) {
kr_nonce_write_wire(cookie + cc_len, &nonce_len, nonce);
kr_nonce_write_wire(cookie + cc_len, nonce_len, nonce);
input.nonce = cookie + cc_len;
input.nonce_len = nonce_len;
......
......@@ -19,21 +19,17 @@
#include "contrib/wire.h"
#include "lib/cookies/nonce.h"
int kr_nonce_write_wire(uint8_t *buf, uint16_t *buf_len,
struct kr_nonce_input *input)
uint16_t kr_nonce_write_wire(uint8_t *buf, uint16_t buf_len,
struct kr_nonce_input *input)
{
if (!buf || !buf_len || !input) {
return kr_error(EINVAL);
}
if (*buf_len < KR_NONCE_LEN) {
return kr_error(EINVAL);
if (!buf || buf_len < KR_NONCE_LEN || !input) {
return 0;
}
wire_write_u32(buf, input->rand);
wire_write_u32(buf + sizeof(uint32_t), input->time);
*buf_len = 2 * sizeof(uint32_t);
assert(KR_NONCE_LEN == *buf_len);
buf_len = 2 * sizeof(uint32_t);
assert(KR_NONCE_LEN == buf_len);
return kr_ok();
return buf_len;
}
......@@ -34,11 +34,10 @@ struct kr_nonce_input {
* @brief Writes server cookie nonce value into given buffer.
*
* @param buf buffer to write nonce data in wire format into
* @param buf_len on input contains nonce buffer size, on output contains
* size of actual written data
* @param buf_len buffer size
* @param input data to generate wire data from
* @return kr_ok() on success, error code else
* @return non-zero size of written data on success, 0 on failure
*/
KR_EXPORT
int kr_nonce_write_wire(uint8_t *buf, uint16_t *buf_len,
struct kr_nonce_input *input);
uint16_t kr_nonce_write_wire(uint8_t *buf, uint16_t buf_len,
struct kr_nonce_input *input);
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