Re: Solaris password format

[email protected] (zentara) Fri, 20 Sep 2002 09:03:35 -0400
Newsgroups perl.crypto
Message-ID <[email protected]>
On Fri, 20 Sep 2002 00:40:16 -0700 (PDT), [email protected] (Roger
Thomas) wrote:

>Dear all,
>i generated the Linux password with Crypt::PasswdMD5
>what is the equivalent to do this for Solaris 8.
>i noticed that the /etc/shadow passwd entries are much shorter.

Hi, I only have linux on an i686 but I think the problems may be the
same. If not, some real Solaris user may have more info for you.

There are 2 types of crypt, des (the short one) and md5 (the long one).
They are created differently depending on the salt value you give.
If your system was setup while the des crypt was the default, then
was later changed to use md5, the original passwords will still be
des crypt until the users make a password change. On the otherhand,
your system may not accept md5 passwords.  Your sysadmin should know.

Here is a little script which demonstrates the difference in salt
values, and the outputs.  Notice, you do not need Crypt::PasswdMD5.
On most linux systems, the builtin crypt function will generate md5
passwords if the salt is setup right.

#!/usr/bin/perl
use Crypt::PasswdMD5;

#The secret to getting crypt to work correctly is in providing 
#a salt starting with '$1$' and having 8 characters 
#(instead of the normal 2 used for DES-crypt). 
#There are similar conventions for using other crypt variants 
#(e.g. '$2$' for SHA-crypt).

#using md5crypt
$passwd = 'whoopdeedoo';
$salt = '$1$qwertyuz';
print "md5crypt salt= $salt \n";
print "-------------------------------------\n";
$crypted = unix_md5_crypt $passwd, $salt;
print "$crypted\n";

$crypted = crypt $passwd, $salt; #crypt works as well
print "$crypted\n";
print crypt ($passwd, $salt), "\n";

#using DES crypt
print "#################################################\n";
print "des crypt salt= xy \n";
$passwd = 'whoopdedoo';
$salt = 'xy';
print "-------------------------------------\n";
$crypted = crypt $passwd, $salt;
print "$crypted\n";
print crypt ($passwd, $salt), "\n";

#Note that the MD5-based crypt() is not the same as 
#obtaining the hash of your password with Digest::MD5 or similar. 
#The algorithm used internally by the MD5-based crypt() uses a 
#number of transformations in which the MD5 algorythm is used, 
#but is very different.

#Crypt::PasswdMD5 implements this algorithm in Perl, 
#allowing you to reproduce the result of said crypt() functions 
#in non-*nix systems or systems without a compatible crypt() 
#implementation.