]> jfr.im git - irc/quakenet/newserv.git/blame - chanserv/authcmds/challengeauth.c
Merge chanserv-live into default.
[irc/quakenet/newserv.git] / chanserv / authcmds / challengeauth.c
CommitLineData
b7a95f03
CP
1/* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: challengeauth
bace4964 5 * CMDLEVEL: QCMD_SECURE | QCMD_NOTAUTHED
b7a95f03
CP
6 * CMDARGS: 3
7 * CMDDESC: Authenticates you on the bot using challenge response.
8 * CMDFUNC: csa_dochallengeauth
9 * CMDPROTO: int csa_dochallengeauth(void *source, int cargc, char **cargv);
c131e6ed
CP
10 * CMDHELP: Usage: challengeauth <username> <response> <hmac algorithm>
11 * CMDHELP: Authenticates using challenge response.
12 * CMDHELP: To generate the response from the challenge, calculate the following:
13 * CMDHELP: HMAC(challenge){k}
14 * CMDHELP: where HMAC is the hash message authentication code as described in
15 * CMDHELP: RFC 2104, k is HEXDIGEST(<lower case username>:HEXDIGEST(<password>))
16 * CMDHELP: and HEXDIGEST is the hash function used in the MAC construction.
594c05a3 17 * CMDHELP: For example code see " CHALLENGEAUTHSITE ".
b7a95f03
CP
18 */
19
20#include "../chanserv.h"
21#include <time.h>
22
23int csa_auth(void *source, int cargc, char **cargv, CRAlgorithm alg);
24
25int csa_dochallengeauth(void *source, int cargc, char **cargv) {
26 CRAlgorithm alg;
27 activeuser* aup;
28 time_t t;
29 nick *sender=(nick *)source;
30
31 if(cargc<3) {
32 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "challengeauth");
33 return CMD_ERROR;
34 }
35
36 if (!(aup=getactiveuserfromnick(sender)))
37 return CMD_ERROR;
38
39 t = time(NULL);
40 if(t > aup->entropyttl) {
41 chanservstdmessage(sender, QM_NOCHALLENGE);
42 return CMD_ERROR;
43 }
44
45 aup->entropyttl = 0;
46
47 alg = cs_cralgorithm(cargv[2]);
48 if(!alg) {
49 chanservstdmessage(sender, QM_CHALLENGEBADALGORITHM);
50 return CMD_ERROR;
51 }
52
3da2567a
CP
53 if(!strcasecmp(cargv[2], "legacy-md5"))
54 chanservstdmessage(sender, QM_CHALLENGEDDEPRECATED);
55
b7a95f03
CP
56 return csa_auth(sender, cargc, cargv, alg);
57}