diff --git a/src/cookies.c b/src/cookies.c index e59fc7af..e9d5fcc5 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -79,8 +79,8 @@ cleanup: return ret; } -int encrypt_cookie(main_server_st * s, uint8_t* cookie, unsigned cookie_size, - const struct stored_cookie_st* sc) +int encrypt_cookie(main_server_st * s, const struct stored_cookie_st* sc, + uint8_t* cookie, unsigned cookie_size) { uint8_t _iv[COOKIE_IV_SIZE]; gnutls_cipher_hd_t h; diff --git a/src/cookies.h b/src/cookies.h index 8c80a6e5..7f4d72ab 100644 --- a/src/cookies.h +++ b/src/cookies.h @@ -15,8 +15,8 @@ struct __attribute__ ((__packed__)) stored_cookie_st { #define COOKIE_MAC_SIZE 12 /* 96-bits of AES-GCM */ #define COOKIE_SIZE (COOKIE_IV_SIZE + sizeof(struct stored_cookie_st) + COOKIE_MAC_SIZE) -int encrypt_cookie(struct main_server_st * s, uint8_t* cookie, unsigned cookie_size, - const struct stored_cookie_st* sc); +int encrypt_cookie(struct main_server_st * s, const struct stored_cookie_st* sc, + uint8_t* cookie, unsigned cookie_size); int decrypt_cookie(struct main_server_st * s, const uint8_t* cookie, unsigned cookie_size, struct stored_cookie_st* sc); diff --git a/src/main-auth.c b/src/main-auth.c index de29a9ec..1b53cd5a 100644 --- a/src/main-auth.c +++ b/src/main-auth.c @@ -190,7 +190,7 @@ time_t now = time(0); return 0; } -int generate_and_store_vals(main_server_st *s, struct proc_st* proc) +int generate_cookie(main_server_st *s, struct proc_st* proc) { int ret; struct stored_cookie_st sc; @@ -208,7 +208,7 @@ struct stored_cookie_st sc; sc.expiration = time(0) + s->config->cookie_validity; - ret = encrypt_cookie(s, proc->cookie, sizeof(proc->cookie), &sc); + ret = encrypt_cookie(s, &sc, proc->cookie, sizeof(proc->cookie)); if (ret < 0) return -1; diff --git a/src/main-misc.c b/src/main-misc.c index 44e16bd3..72b67d0b 100644 --- a/src/main-misc.c +++ b/src/main-misc.c @@ -173,8 +173,8 @@ const char* group; group = proc->groupname; if (cmd == AUTH_REQ || cmd == AUTH_INIT) { - /* generate and store cookie */ - ret = generate_and_store_vals(s, proc); + /* generate cookie */ + ret = generate_cookie(s, proc); if (ret < 0) { return ERR_BAD_COMMAND; } diff --git a/src/main.h b/src/main.h index 1548e067..71310a81 100644 --- a/src/main.h +++ b/src/main.h @@ -158,7 +158,7 @@ int send_auth_reply(main_server_st* s, struct proc_st* proc, cmd_auth_reply_t r); int handle_auth_cookie_req(main_server_st* s, struct proc_st* proc, const struct cmd_auth_cookie_req_st * req); -int generate_and_store_vals(main_server_st *s, struct proc_st* proc); +int generate_cookie(main_server_st *s, struct proc_st* proc); int handle_auth_init(main_server_st *s, struct proc_st* proc, const struct cmd_auth_init_st * req); int handle_auth_req(main_server_st *s, struct proc_st* proc,