Skip to content
12 changes: 12 additions & 0 deletions src/botcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,17 @@ static void bot_endlink(int idx, char *par)
dcc[idx].status &= ~STAT_LINKING;
}

static void bot_encryption2(int idx, char *par)
{
if (dcc[idx].status & STAT_AGGRESSIVE) {
module_entry *me = module_find("encryption2", 0, 0);
if (me && me->funcs[ENCRYTION2_RECV_SETTINGS])
((me->funcs)[ENCRYTION2_RECV_SETTINGS]) (par);
} else
putlog(LOG_BOTS, "*", "Received new encryption2 settings from %s, but she "
"is not agressive sharing with me, ignored.", dcc[idx].nick);
}

/* info? <from@bot> -> send priv
*/
static void bot_infoq(int idx, char *par)
Expand Down Expand Up @@ -1554,6 +1565,7 @@ botcmd_t C_bot[] =
{"ct", (IntFunc) bot_chat},
{"e", (IntFunc) bot_error},
{"el", (IntFunc) bot_endlink},
{"en", (IntFunc) bot_encryption2},
#ifndef NO_OLD_BOTNET
{"error", (IntFunc) bot_error},
#endif
Expand Down
18 changes: 9 additions & 9 deletions src/eggdrop.h
Original file line number Diff line number Diff line change
Expand Up @@ -504,15 +504,15 @@ struct dupwait_info {
#define STRIP_ALL 0x000FF /* remove every damn thing! */

/* For dcc bot links. */
#define STAT_PINGED 0x00001 /* waiting for ping to return */
#define STAT_SHARE 0x00002 /* sharing user data with the bot */
#define STAT_CALLED 0x00004 /* this bot called me */
#define STAT_OFFERED 0x00008 /* offered her the user file */
#define STAT_SENDING 0x00010 /* in the process of sending a user list */
#define STAT_GETTING 0x00020 /* in the process of getting a user list */
#define STAT_WARNED 0x00040 /* warned him about unleaflike behavior */
#define STAT_LEAF 0x00080 /* this bot is a leaf only */
#define STAT_LINKING 0x00100 /* the bot is currently going through
#define STAT_PINGED 0x00001 /* waiting for ping to return */
#define STAT_SHARE 0x00002 /* sharing user data with the bot */
#define STAT_CALLED 0x00004 /* this bot called me */
#define STAT_OFFERED 0x00008 /* offered her the user file */
#define STAT_SENDING 0x00010 /* in the process of sending a user list */
#define STAT_GETTING 0x00020 /* in the process of getting a user list */
#define STAT_WARNED 0x00040 /* warned him about unleaflike behavior */
#define STAT_LEAF 0x00080 /* this bot is a leaf only */
#define STAT_LINKING 0x00100 /* the bot is currently going through
* the linking stage */
#define STAT_AGGRESSIVE 0x00200 /* aggressively sharing with this bot */

Expand Down
3 changes: 3 additions & 0 deletions src/mod/modvals.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
#define NOTES_CMD_NOTE 4
/* Console */
#define CONSOLE_DOSTORE 4
/* Encryption2 */
#define ENCRYTION2_SEND_SETTINGS 6
#define ENCRYTION2_RECV_SETTINGS 7

#ifdef MOD_USE_SHL
# include <dl.h>
Expand Down
68 changes: 65 additions & 3 deletions src/mod/pbkdf2.mod/pbkdf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ static char *pbkdf2_close(void)
return "You cannot unload the " MODULE_NAME " module.";
}

static void pbkdf2_report(int idx, int details)
{
if (details)
dprintf(idx, " kdf: pbkdf2 method %s rounds %i re-encode %i\n",
pbkdf2_method, pbkdf2_rounds, pbkdf2_re_encode);
}

static void bufcount(char **buf, int *buflen, int bytes)
{
*buf += bytes;
Expand Down Expand Up @@ -223,6 +230,55 @@ static char *pbkdf2_verify(const char *pass, const char *encrypted)
return (char *) encrypted;
}

static void pbkdf2_send_settings(int idx) {
dprintf(idx, "en pbkdf2 %s %i\n", pbkdf2_method, pbkdf2_rounds);
}

static void pbkdf2_recv_settings(char *msg) {
char *s, *endptr;
const EVP_MD *digest;
unsigned long val;

s = newsplit(&msg);
if (strcmp(s, "pbkdf2"))
return;
s = newsplit(&msg);
if (strcasecmp(s, pbkdf2_method)) {
digest = EVP_get_digestbyname(s);
if (digest) {
putlog(LOG_MISC, "*", "PBKDF2: received new pbkdf2-method from share "
"master: %s -> %s. Consider setting it in your eggdrop config "
"file.", pbkdf2_method, s);
strlcpy(pbkdf2_method, s, sizeof pbkdf2_method);
} else
putlog(LOG_MISC, "*", "PBKDF2 error: received unknown pbkdf2-method from "
"share master. Keeping %s.", pbkdf2_method);
}
s = newsplit(&msg);
errno = 0;
val = strtoul(s, &endptr, 10);
if (s[0] != '\0' && *endptr == '\0' && errno != ERANGE && val > 0 &&
val <= INT_MAX) {
if (val != pbkdf2_rounds) {
putlog(LOG_MISC, "*", "PBKDF2: received new pbkdf2-rounds from share "
"master: %i -> %lu. Consider setting it in your eggdrop config "
"file.", pbkdf2_rounds, val);
pbkdf2_rounds = val;
}
} else
putlog(LOG_MISC, "*", "PBKDF2 error: received bugus pbkdf2-rounds from "
"share master. Keeping %i.", pbkdf2_rounds);
}

char *traced_pbkdf2(ClientData cd, Tcl_Interp *irp, EGG_CONST char *name1, EGG_CONST char *name2, int flags) {
int idx;

for (idx = 0; idx < dcc_total; idx++)
if ((dcc[idx].status & STAT_SHARE) && (dcc[idx].status & ~STAT_AGGRESSIVE))
pbkdf2_send_settings(idx);
return NULL;
}

static tcl_ints my_tcl_ints[] = {
{"pbkdf2-re-encode", &pbkdf2_re_encode, 0},
{"pbkdf2-rounds", &pbkdf2_rounds, 0},
Expand All @@ -237,12 +293,16 @@ static tcl_strings my_tcl_strings[] = {
EXPORT_SCOPE char *pbkdf2_start();

static Function pbkdf2_table[] = {
/* 0 - 3 */
(Function) pbkdf2_start,
(Function) pbkdf2_close,
NULL, /* expmem */
NULL, /* report */
(Function) pbkdf2_report,
/* 4 - 7 */
(Function) pbkdf2_encrypt,
(Function) pbkdf2_verify
(Function) pbkdf2_verify,
(Function) pbkdf2_send_settings,
(Function) pbkdf2_recv_settings
};

/* Initializes API with hash algorithm */
Expand Down Expand Up @@ -284,7 +344,7 @@ char *pbkdf2_start(Function *global_funcs)
global = global_funcs;
if (!module_rename("pbkdf2", MODULE_NAME))
return "Already loaded.";
module_register(MODULE_NAME, pbkdf2_table, 1, 0);
module_register(MODULE_NAME, pbkdf2_table, 1, 1);
if (!module_depend(MODULE_NAME, "eggdrop", 109, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.9.0 or later.";
Expand All @@ -293,6 +353,8 @@ char *pbkdf2_start(Function *global_funcs)
module_undepend(MODULE_NAME);
return "Initialization failure";
}
Tcl_TraceVar(interp, "pbkdf2-method", TCL_GLOBAL_ONLY | TCL_TRACE_WRITES, traced_pbkdf2, NULL);
Tcl_TraceVar(interp, "pbkdf2-rounds", TCL_GLOBAL_ONLY | TCL_TRACE_WRITES, traced_pbkdf2, NULL);
add_hook(HOOK_ENCRYPT_PASS2, (Function) pbkdf2_encrypt);
add_hook(HOOK_VERIFY_PASS2, (Function) pbkdf2_verify);
add_tcl_commands(my_tcl_cmds);
Expand Down
5 changes: 4 additions & 1 deletion src/mod/transfer.mod/transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ static void dcc_get(int idx, char *buf, int len)
if (me && me->funcs[SHARE_DUMP_RESYNC])
((me->funcs)[SHARE_DUMP_RESYNC]) (y);
xnick[0] = 0;
me = module_find("encryption2", 0, 0);
if (me && me->funcs[ENCRYTION2_SEND_SETTINGS])
((me->funcs)[ENCRYTION2_SEND_SETTINGS]) (y);
} else {
module_entry *fs = module_find("filesys", 0, 0);
struct userrec *u = get_user_by_handle(userlist, dcc[idx].u.xfer->from);
Expand Down Expand Up @@ -1213,7 +1216,7 @@ char *transfer_start(Function *global_funcs)
global = global_funcs;

fileq = NULL;
module_register(MODULE_NAME, transfer_table, 2, 4);
module_register(MODULE_NAME, transfer_table, 2, 5);
if (!module_depend(MODULE_NAME, "eggdrop", 108, 0)) {
module_undepend(MODULE_NAME);
return "This module requires Eggdrop 1.8.0 or later.";
Expand Down