sha passwords

This commit is contained in:
joonicks
2018-03-09 03:51:03 +01:00
parent f9d37e65a4
commit 00da630c45
14 changed files with 568 additions and 44 deletions

View File

@@ -1,7 +1,7 @@
/*
EnergyMech, IRC bot software
Copyright (c) 2001-2004 proton
Copyright (c) 2001-2018 proton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@
#include "mcmd.h"
#ifndef MD5CRYPT
#ifndef SHACRYPT
/*
* simple password encryption
@@ -114,7 +115,39 @@ int passmatch(char *plain, char *encoded)
return(!Strcmp(cipher(plain),encoded));
}
#else /* MD5CRYPT */
#endif /* not SHACRYPT */
#endif /* not MD5CRYPT */
#ifdef SHACRYPT
/*
* use SHA512 to hash passwords
*/
char *CRYPT_FUNC(const char *, const char *);
char *makepass(char *plain)
{
char salt[8];
sprintf(salt,"$6$%04x",(rand() >> 16));
return(CRYPT_FUNC(plain,salt));
}
int passmatch(char *plain, char *encoded)
{
char *enc;
if (matches("$6$????$*",encoded))
return(FALSE);
enc = CRYPT_FUNC(plain,encoded);
return(!Strcmp(enc,encoded));
}
#endif /* SHACRYPT */
#ifndef SHACRYPT
#ifdef MD5CRYPT
/*
* use MD5 to hash passwords
@@ -141,7 +174,7 @@ int passmatch(char *plain, char *encoded)
}
#endif /* MD5CRYPT */
#endif /* not SHACRYPT */
/*
*
*/