free_mem:
PQclear(res);
- return 0;
+ return r;
}
static int handle_request(void * UNUSED(data),
/* Validate OTP */
/* Find public uid, if possible */
split_otp(otp, &uid, &otp_token);
- get_data_for_uid(uid, &stats);
-
+ if (get_data_for_uid(uid, &stats) < 0) {
+ status = "BAD_OTP";
+ signature = sign_request(shared_secret, shared_secret_len,
+ NULL, status, timestamp);
+ send_response(conn, signature, status, NULL, timestamp);
+ goto free_mem;
+ }
/* Argh, yubikey_parse takes in one modhex-ed token (but
* requires us to strip the public id first, and an unencoded aes key*/
yubikey_parse((uint8_t*)(otp_token), (const uint8_t *)stats.secret_key, &token);