]> jfr.im git - irc/quakenet/newserv.git/blob - chanserv/authcmds/challenge.c
TRUSTS: require sqlite
[irc/quakenet/newserv.git] / chanserv / authcmds / challenge.c
1 /*
2 * CMDNAME: challenge
3 * CMDLEVEL: QCMD_SECURE | QCMD_NOTAUTHED
4 * CMDARGS: 0
5 * CMDDESC: Returns a challenge for use in challengeauth.
6 * CMDFUNC: csa_dochallenge
7 * CMDPROTO: int csa_dochallenge(void *source, int cargc, char **cargv);
8 * CMDHELP: Usage: challenge
9 * CMDHELP: Supplies you with a challenge and a list of algorithms accepted
10 * CMDHELP: for challenge response authentication, see CHALLENGEAUTH help
11 * CMDHELP: for more details.
12 */
13
14 #include "../chanserv.h"
15 #include "../authlib.h"
16 #include "../../lib/irc_string.h"
17 #include <stdio.h>
18 #include <string.h>
19 #include <time.h>
20
21 int csa_dochallenge(void *source, int cargc, char **cargv) {
22 nick *sender=source;
23 activeuser* aup;
24 time_t t;
25
26 if (!(aup=getactiveuserfromnick(sender)))
27 return CMD_ERROR;
28
29 t = time(NULL);
30 if(t > aup->entropyttl) {
31 cs_getrandbytes(aup->entropy,ENTROPYLEN);
32 aup->entropyttl=t + 30;
33 }
34
35 chanservsendmessage(sender,"CHALLENGE %s %s",cs_calcchallenge(aup->entropy),cs_cralgorithmlist());
36 cs_log(sender,"CHALLENGE");
37
38 return CMD_OK;
39 }