[BACK]Return to pwd_gensalt.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / passwd

Diff for /src/usr.bin/passwd/Attic/pwd_gensalt.c between version 1.5 and 1.6

version 1.5, 1997/03/27 00:36:32 version 1.6, 1997/03/27 23:02:58
Line 37 
Line 37 
 #include <util.h>  #include <util.h>
 #include <time.h>  #include <time.h>
   
 void to64( char *, long, int n);  void to64 __P((char *, int32_t, int n));
   
 int  int
 pwd_gensalt(salt, max, pwd, type)  pwd_gensalt(salt, max, pwd, type)
Line 64 
Line 64 
         next = option;          next = option;
         now = strsep(&next, ",");          now = strsep(&next, ",");
         if (!strcmp(now, "old")) {          if (!strcmp(now, "old")) {
                 if( max < 3 )                  if (max < 3)
                         return 0;                          return 0;
                 to64(&salt[0], arc4random(), 2);                  to64(&salt[0], arc4random(), 2);
                 salt[2] = '\0';                  salt[2] = '\0';
         } else if (!strcmp(now, "newsalt")) {          } else if (!strcmp(now, "newsalt")) {
                 if( max < 10 )                  if (max < 10)
                         return 0;                          return 0;
                 salt[0] = _PASSWORD_EFMT1;                  salt[0] = _PASSWORD_EFMT1;
                 to64(&salt[1], (long) (29 * 25), 4);                  to64(&salt[1], (int32_t) (29 * 25), 4);
                 to64(&salt[5], arc4random(), 4);                  to64(&salt[5], arc4random(), 4);
                 salt[9] = '\0';                  salt[9] = '\0';
         } else if (!strcmp(now, "md5")) {          } else if (!strcmp(now, "md5")) {
                 if( max < 13 )  /* $1$8salt$\0 */                  if (max < 13)  /* $1$8salt$\0 */
                         return 0;                          return 0;
                 strcpy(salt, "$1$");                  strcpy(salt, "$1$");
                 to64(&salt[3], arc4random(), 4);                  to64(&salt[3], arc4random(), 4);
Line 95 
Line 95 
         return 1;          return 1;
 }  }
   
 static unsigned char itoa64[] =         /* 0 ... 63 => ascii - 64 */  static unsigned char itoa64[] =  /* 0 ... 63 => ascii - 64 */
         "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";          "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
   
 void to64(s, v, n)  void
         register char *s;  to64(s, v, n)
         register long v;          register char *s;
         register int n;          register int32_t v;
           register int n;
 {  {
         while (--n >= 0) {          while (--n >= 0) {
                 *s++ = itoa64[v&0x3f];                  *s++ = itoa64[v&0x3f];
                 v >>= 6;                  v >>= 6;
         }          }
 }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6