[dovecot-cvs] dovecot/src/auth password-scheme.c,1.31,1.32

tss at dovecot.org tss at dovecot.org
Sun May 13 13:09:58 EEST 2007


Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv7183

Modified Files:
	password-scheme.c 
Log Message:
cleanup



Index: password-scheme.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/password-scheme.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- password-scheme.c	13 May 2007 08:24:06 -0000	1.31
+++ password-scheme.c	13 May 2007 10:09:56 -0000	1.32
@@ -213,16 +213,17 @@
 static const char *ssha_generate(const char *plaintext,
 				 const char *user __attr_unused__)
 {
-	unsigned char ssha_digest[SHA1_RESULTLEN+4];
+#define SSHA_SALT_LEN 4
+	unsigned char ssha_digest[SHA1_RESULTLEN + SSHA_SALT_LEN];
 	unsigned char *salt = &ssha_digest[SHA1_RESULTLEN];
 	struct sha1_ctxt ctx;
 	string_t *str;
 
-	random_fill(salt, 4);
+	random_fill(salt, SSHA_SALT_LEN);
 
 	sha1_init(&ctx);
 	sha1_loop(&ctx, plaintext, strlen(plaintext));
-	sha1_loop(&ctx, salt, 4);
+	sha1_loop(&ctx, salt, SSHA_SALT_LEN);
 	sha1_result(&ctx, ssha_digest);
 
 	str = t_str_new(MAX_BASE64_ENCODED_SIZE(sizeof(ssha_digest))+1);
@@ -265,16 +266,17 @@
 static const char *smd5_generate(const char *plaintext,
 				 const char *user __attr_unused__)
 {
-	unsigned char smd5_digest[20];
+#define SMD5_SALT_LEN 4
+	unsigned char smd5_digest[MD5_RESULTLEN + SMD5_SALT_LEN];
 	unsigned char *salt = &smd5_digest[MD5_RESULTLEN];
 	struct md5_context ctx;
 	string_t *str;
 
-	random_fill(salt, 4);
+	random_fill(salt, SMD5_SALT_LEN);
 
 	md5_init(&ctx);
 	md5_update(&ctx, plaintext, strlen(plaintext));
-	md5_update(&ctx, salt, 4);
+	md5_update(&ctx, salt, SMD5_SALT_LEN);
 	md5_final(&ctx, smd5_digest);
 
 	str = t_str_new(MAX_BASE64_ENCODED_SIZE(sizeof(smd5_digest))+1);



More information about the dovecot-cvs mailing list