mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-09 17:43:12 +02:00
.
This commit is contained in:
@@ -146,3 +146,59 @@ int dopacket(cptr, buffer, length)
|
||||
cptr->count = ch1 - cptr->buffer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CRYPTOIRCD
|
||||
char *ep_encrypt(aClient *cptr, char *string, int *len)
|
||||
{
|
||||
static unsigned char cryptobuffer[8192];
|
||||
char ivec[9];
|
||||
int length;
|
||||
char *c;
|
||||
int num;
|
||||
|
||||
if (!cptr->cryptinfo)
|
||||
return string;
|
||||
|
||||
bzero(cryptobuffer, sizeof(cryptobuffer));
|
||||
bzero(ivec, sizeof(ivec));
|
||||
num = 0;
|
||||
|
||||
if ((c = (char *)strchr(string, '\n')))
|
||||
*c = '\0';
|
||||
if ((c = (char *)strchr(string, '\r')))
|
||||
*c = '\0';
|
||||
|
||||
length = strlen(string) + 1;
|
||||
cryptobuffer[0] = (unsigned char) length / 256;
|
||||
cryptobuffer[1] = (unsigned char) length - (cryptobuffer[0] * 256);
|
||||
|
||||
if (cptr->cryptinfo->method == METHOD_BLOWFISH)
|
||||
{
|
||||
BF_cfb64_encrypt(string, &cryptobuffer[2], length, cptr->cryptinfo->key, ivec, &num, BF_ENCRYPT);
|
||||
*len = length + 2;
|
||||
return (cryptobuffer);
|
||||
}
|
||||
}
|
||||
|
||||
char *ep_decrypt(aClient *cptr, char *string)
|
||||
{
|
||||
static char decryptbuffer[8192];
|
||||
int num;
|
||||
char ivec[9];
|
||||
int length;
|
||||
|
||||
if (!cptr->cryptinfo)
|
||||
return string;
|
||||
|
||||
bzero(decryptbuffer, sizeof(decryptbuffer));
|
||||
bzero(ivec, sizeof(ivec));
|
||||
num = 0;
|
||||
length = (*(string) * 256) + (*(string + 1));
|
||||
|
||||
if (cptr->cryptinfo->method == METHOD_BLOWFISH)
|
||||
{
|
||||
BF_cfb64_encrypt(string + 2, decryptbuffer, length, cptr->cryptinfo->key, ivec, &num, BF_DECRYPT);
|
||||
return (decryptbuffer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+6
-4
@@ -1529,12 +1529,14 @@ int m_crypto(cptr, sptr, parc, parv)
|
||||
|
||||
if (method == METHOD_BLOWFISH)
|
||||
{
|
||||
cptr->cryptinfo = (aCryptInfo *) MyMalloc(sizeof(aCryptInfo));
|
||||
cptr->cryptinfo->method = method;
|
||||
cptr->cryptinfo->key = (void *) MyMalloc(sizeof(BF_KEY));
|
||||
BF_set_key(cptr->cryptinfo->key, strlen(parv[2]), parv[2]);
|
||||
sptr->cryptinfo = (aCryptInfo *) MyMalloc(sizeof(aCryptInfo));
|
||||
sptr->cryptinfo->method = method;
|
||||
sptr->cryptinfo->key = (void *) MyMalloc(sizeof(BF_KEY));
|
||||
BF_set_key(sptr->cryptinfo->key, strlen(parv[2]), parv[2]);
|
||||
sendto_one(sptr, "CRYPTO ON BLOWFISH");
|
||||
SetSecure(sptr);
|
||||
for (method = 1; method <= 30; method++)
|
||||
sendto_one(sptr, ":%s NOTICE %s :moooooooooooooooooooooooooooooooooooooooooooo %i", me.name, sptr->name, method);
|
||||
return 0;
|
||||
}
|
||||
sendto_one(sptr, "CRYPTO ERROR :No such method %s", parv[1]);
|
||||
|
||||
+11
-1
@@ -203,6 +203,8 @@ void vsendto_one(aClient *to, char *pattern, va_list vl)
|
||||
void sendbufto_one(aClient *to)
|
||||
{
|
||||
int len;
|
||||
char *s;
|
||||
int i;
|
||||
|
||||
Debug((DEBUG_ERROR, "Sending [%s] to %s", sendbuf, to->name));
|
||||
|
||||
@@ -241,7 +243,15 @@ void sendbufto_one(aClient *to)
|
||||
sendto_ops("Trying to send [%s] to myself!", tmp_sendbuf);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CRYPTOIRCD
|
||||
if (IsSecure(to))
|
||||
{
|
||||
s = (char *) ep_encrypt(to, sendbuf, &len);
|
||||
bcopy(s, sendbuf, len);
|
||||
for (i = 0; i<=len; i++)
|
||||
Debug((DEBUG_ERROR,"%hd", sendbuf[i]));
|
||||
}
|
||||
#endif
|
||||
if (DBufLength(&to->sendQ) > get_sendq(to))
|
||||
{
|
||||
if (IsServer(to))
|
||||
|
||||
Reference in New Issue
Block a user