diff options
Diffstat (limited to 'crypting.c')
| -rw-r--r-- | crypting.c | 52 | 
1 files changed, 12 insertions, 40 deletions
| @@ -45,17 +45,12 @@ typedef struct irc  	char *password;  } irc_t; -#define set_add( a, b, c, d ) -#define set_find( a, b ) NULL -  #include "md5.h"  #include "crypting.h"  #include <string.h>  #include <stdio.h>  #include <stdlib.h> -#define irc_usermsg -  #endif  /*\ @@ -64,28 +59,8 @@ typedef struct irc   * correctness.  \*/ -/* USE WITH CAUTION! -   Sets pass without checking */ -void setpassnc (irc_t *irc, char *pass) { -	if (!set_find (irc, "password")) -		set_add (irc, "password", NULL, passchange); -	 -	if (irc->password) g_free (irc->password); -	 -	if (pass) { -		irc->password = g_strdup (pass); -		irc_usermsg (irc, "Password successfully changed"); -	} else { -		irc->password = NULL; -	} -} - -char *passchange (irc_t *irc, void *set, char *value) { -	setpassnc (irc, value); -	return (NULL); -} - -int setpass (irc_t *irc, char *pass, char* md5sum) { +int checkpass (const char *pass, const char *md5sum) +{  	md5_state_t md5state;  	md5_byte_t digest[16];  	int i, j; @@ -102,13 +77,11 @@ int setpass (irc_t *irc, char *pass, char* md5sum) {  		if (digits[0] != md5sum[j]) return (-1);  		if (digits[1] != md5sum[j + 1]) return (-1);  	} -	 -	/* If pass is correct, we end up here and we set the pass */ -	setpassnc (irc, pass); -	 -	return (0); + +	return( 0 );  } +  char *hashpass (irc_t *irc) {  	md5_state_t md5state;  	md5_byte_t digest[16]; @@ -134,14 +107,14 @@ char *hashpass (irc_t *irc) {  	return (rv);  } -char *obfucrypt (irc_t *irc, char *line) { +char *obfucrypt (irc_t *irc, char *line)  +{  	int i, j;  	char *rv;  	if (irc->password == NULL) return (NULL); -	rv = (char *)g_malloc (strlen (line) + 1); -	memset (rv, '\0', strlen (line) + 1); +	rv = g_new0(char, strlen (line) + 1);  	i = j = 0;  	while (*line) { @@ -159,14 +132,14 @@ char *obfucrypt (irc_t *irc, char *line) {  	return (rv);  } -char *deobfucrypt (irc_t *irc, char *line) { +char *deobfucrypt (irc_t *irc, char *line)  +{  	int i, j;  	char *rv;  	if (irc->password == NULL) return (NULL); -	rv = (char *)g_malloc (strlen (line) + 1); -	memset (rv, '\0', strlen (line) + 1); +	rv = g_new0(char, strlen (line) + 1);  	i = j = 0;  	while (*line) { @@ -188,7 +161,7 @@ char *deobfucrypt (irc_t *irc, char *line) {  int main( int argc, char *argv[] )  { -	irc_t *irc = g_malloc( sizeof( irc_t ) ); +	irc_t *irc = g_new0( irc_t, 1 );  	char *hash, *action, line[256];  	char* (*func)( irc_t *, char * ); @@ -200,7 +173,6 @@ int main( int argc, char *argv[] )  		return( 1 );  	} -	memset( irc, 0, sizeof( irc_t ) );  	irc->password = g_strdup( argv[1] );  	hash = hashpass( irc ); | 
