]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/authcmds/challengeauth.c
1 /* Automatically generated by refactor.pl.
4 * CMDNAME: challengeauth
5 * CMDLEVEL: QCMD_SECURE | QCMD_NOTAUTHED
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);
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.
17 * CMDHELP: For example code see " CHALLENGEAUTHSITE ".
20 #include "../chanserv.h"
23 int csa_auth(void *source
, int cargc
, char **cargv
, CRAlgorithm alg
);
25 int csa_dochallengeauth(void *source
, int cargc
, char **cargv
) {
29 nick
*sender
=(nick
*)source
;
32 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "challengeauth");
36 if (!(aup
=getactiveuserfromnick(sender
)))
40 if(t
> aup
->entropyttl
) {
41 chanservstdmessage(sender
, QM_NOCHALLENGE
);
47 alg
= cs_cralgorithm(cargv
[2]);
49 chanservstdmessage(sender
, QM_CHALLENGEBADALGORITHM
);
53 if(!strcasecmp(cargv
[2], "legacy-md5"))
54 chanservstdmessage(sender
, QM_CHALLENGEDDEPRECATED
);
56 return csa_auth(sender
, cargc
, cargv
, alg
);