From: Kurt Zeilenga Date: Wed, 2 May 2001 19:49:44 +0000 (+0000) Subject: optional SHA1 X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1458 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9ed2b33e2b44667cc3261f9219bd2481993cd523;p=openldap optional SHA1 --- diff --git a/libraries/liblutil/authpasswd.c b/libraries/liblutil/authpasswd.c index b7dab5a25d..7bf0c0ae60 100644 --- a/libraries/liblutil/authpasswd.c +++ b/libraries/liblutil/authpasswd.c @@ -67,11 +67,13 @@ static int chk_md5( const struct berval *salt, const struct berval *cred ); +#ifdef LUTIL_SHA1_BYTES static int chk_sha1( const struct pw_scheme *scheme, const struct berval *passwd, const struct berval *salt, const struct berval *cred ); +#endif static int chk_crypt( const struct pw_scheme *scheme, @@ -95,7 +97,7 @@ static int chk_ext_unix( const struct berval *passwd, const struct berval *cred ); - +#ifdef LUTIL_SHA1_BYTES /* password hash routines */ static int *hash_sha1( const struct pw_scheme *scheme, @@ -103,6 +105,7 @@ static int *hash_sha1( const struct berval *salt, struct berval **passwd_out, struct berval **salt_out ); +#endif static int *hash_md5( const struct pw_scheme *scheme, @@ -128,7 +131,9 @@ struct pw_scheme { static const struct pw_scheme pw_schemes[] = { +#ifdef LUTIL_SHA1_BYTES { {sizeof("SHA1")-1, "SHA1"}, chk_sha1, 0 /* hash_sha1 */, 4 }, +#endif { {sizeof("MD5")-1, "MD5"}, chk_md5, 0 /* hash_md5 */, 4 }, #ifdef SLAPD_CRYPT @@ -364,6 +369,7 @@ static struct berval * base64( /* PASSWORD CHECK ROUTINES */ +#ifdef LUTIL_SHA1_BYTES static int chk_sha1( const struct pw_scheme *sc, const struct berval * passwd, @@ -431,6 +437,7 @@ done: ber_memfree(orig_salt); return rc; } +#endif static int chk_md5( const struct pw_scheme *sc, @@ -791,6 +798,7 @@ static int chk_unix( #ifdef SLAPD_GENERATE +#ifdef LUTIL_SHA1_BYTES static struct berval *hash_ssha1( const struct pw_scheme *scheme, const struct berval *passwd ) @@ -837,6 +845,7 @@ static struct berval *hash_sha1( return pw_string64( scheme, &digest, NULL); } +#endif static struct berval *hash_smd5( const struct pw_scheme *scheme, diff --git a/libraries/liblutil/passwd.c b/libraries/liblutil/passwd.c index 2d78acdbc4..4ba96e2da8 100644 --- a/libraries/liblutil/passwd.c +++ b/libraries/liblutil/passwd.c @@ -93,6 +93,7 @@ static int chk_smd5( const struct berval *passwd, const struct berval *cred ); +#ifdef LUTIL_SHA1_BYTES static int chk_ssha1( const struct pw_scheme *scheme, const struct berval *passwd, @@ -102,6 +103,7 @@ static int chk_sha1( const struct pw_scheme *scheme, const struct berval *passwd, const struct berval *cred ); +#endif #ifdef SLAPD_LMHASH static int chk_lanman( @@ -139,6 +141,7 @@ static int chk_unix( #endif +#ifdef LUTIL_SHA1_BYTES /* password hash routines */ static struct berval *hash_sha1( const struct pw_scheme *scheme, @@ -147,6 +150,7 @@ static struct berval *hash_sha1( static struct berval *hash_ssha1( const struct pw_scheme *scheme, const struct berval *passwd ); +#endif static struct berval *hash_smd5( const struct pw_scheme *scheme, @@ -171,8 +175,10 @@ static struct berval *hash_crypt( static const struct pw_scheme pw_schemes[] = { +#ifdef LUTIL_SHA1_BYTES { {sizeof("{SSHA}")-1, "{SSHA}"}, chk_ssha1, hash_ssha1 }, { {sizeof("{SHA}")-1, "{SHA}"}, chk_sha1, hash_sha1 }, +#endif { {sizeof("{SMD5}")-1, "{SMD5}"}, chk_smd5, hash_smd5 }, { {sizeof("{MD5}")-1, "{MD5}"}, chk_md5, hash_md5 }, @@ -448,6 +454,7 @@ static struct berval * pw_string64( /* PASSWORD CHECK ROUTINES */ +#ifdef LUTIL_SHA1_BYTES static int chk_ssha1( const struct pw_scheme *sc, const struct berval * passwd, @@ -520,6 +527,7 @@ static int chk_sha1( ber_memfree(orig_pass); return rc ? 1 : 0; } +#endif static int chk_smd5( const struct pw_scheme *sc, @@ -952,6 +960,7 @@ static int chk_unix( /* PASSWORD GENERATION ROUTINES */ +#ifdef LUTIL_SHA1_BYTES static struct berval *hash_ssha1( const struct pw_scheme *scheme, const struct berval *passwd ) @@ -998,6 +1007,7 @@ static struct berval *hash_sha1( return pw_string64( scheme, &digest, NULL); } +#endif static struct berval *hash_smd5( const struct pw_scheme *scheme, diff --git a/libraries/liblutil/sha1.c b/libraries/liblutil/sha1.c index 9d97ceb169..ad921db2f5 100644 --- a/libraries/liblutil/sha1.c +++ b/libraries/liblutil/sha1.c @@ -25,6 +25,7 @@ */ #include "portable.h" +#include #include /* include socket.h to get sys/types.h and/or winsock2.h */ @@ -34,6 +35,8 @@ #include "lutil_sha1.h" +#ifdef LUTIL_SHA1_BYTES + /* undefining this will cause pointer alignment errors */ #define SHA1HANDSOFF /* Copies data before messing with it. */ #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) @@ -275,3 +278,5 @@ lutil_SHA1Data( const unsigned char *data, size_t len, char *buf ) lutil_SHA1Update(&ctx, data, len); return(lutil_SHA1End(&ctx, buf)); } + +#endif