SHA1 passwords: initialize the context before salting
authorJeffrey Hutzelman <jhutz@cmu.edu>
Tue, 15 Jan 2008 03:34:08 +0000 (22:34 -0500)
committerH. Peter Anvin <hpa@zytor.com>
Tue, 15 Jan 2008 03:34:08 +0000 (22:34 -0500)
Need to initialize the SHA-1 context before we add the salt.

com32/modules/menumain.c

index 8c8b91e..fad49a2 100644 (file)
@@ -299,6 +299,8 @@ static int passwd_compare_sha1(const char *passwd, const char *entry)
   SHA1_CTX ctx;
   unsigned char sha1[20], pwdsha1[20];
 
+  SHA1Init(&ctx);
+
   if ( (p = strchr(passwd+3, '$')) ) {
     SHA1Update(&ctx, (void *)passwd+3, p-(passwd+3));
     p++;
@@ -306,8 +308,6 @@ static int passwd_compare_sha1(const char *passwd, const char *entry)
     p = passwd+3;              /* Assume no salt */
   }
 
-  SHA1Init(&ctx);
-
   SHA1Update(&ctx, (void *)entry, strlen(entry));
   SHA1Final(sha1, &ctx);