#include "hmac.h"
+#include <string.h>
void hmacsha256_init(hmacsha256 *c, unsigned char *key, int keylen) {
unsigned char realkey[64], outerkey[64], innerkey[64];
SHA256_Update(&c->inner, message, messagelen);
}
+void hmacsha256_final(hmacsha256 *c, unsigned char *digest) {
+ SHA256_Final(digest, &c->inner);
+ SHA256_Update(&c->outer, digest, 32);
+ SHA256_Final(digest, &c->outer);
+}
+
#include "../core/hooks.h"
#include "../irc/irc.h"
-#define WARN_CHANNEL "#fishcowcow"
+#define WARN_CHANNEL "#twilightzone"
MODULE_VERSION("");
return CMD_ERROR;
}
- if(cargc != 3)
+ if(cargc != 5)
return CMD_USAGE;
acc = cargv[0];
- expiry = atoi(cargv[1]) + 30;
+ expiry = atoi(cargv[1]);
id = atoi(cargv[2]);
acclen = strlen(acc);
junk = cargv[3];
return CMD_ERROR;
}
- if(time(NULL) > expiry) {
+ if(time(NULL) > expiry + 30) {
controlwall(NO_OPER, NL_MISC, "%s!%s@%s attempted to TICKETAUTH as %s (expired)", np->nick, np->ident, np->host->name->content, acc);
controlreply(np, "Ticket time is bad or has expired.");
return CMD_ERROR;
}
hmacsha256_init(&hmac, (unsigned char *)sharedsecret->content, sharedsecret->length);
- snprintf(buffer, sizeof(buffer), "%s %d %d %s", acc, id, expiry, junk);
+ snprintf(buffer, sizeof(buffer), "%s %d %d %s", acc, expiry, id, junk);
hmacsha256_update(&hmac, (unsigned char *)buffer, strlen(buffer));
hmacsha256_final(&hmac, digest);
return;
}
- registercontrolhelpcmd("ticketauth", NO_OPERED, 3, ta_ticketauth, "Usage: ticketauth <ticket>");
+ registercontrolhelpcmd("ticketauth", NO_OPERED, 5, ta_ticketauth, "Usage: ticketauth <ticket>");
}
void _fini() {