public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Weird behavior of crypt
@ 2016-01-29 12:03 Alexandre Garnier
  2016-01-29 12:09 ` Marco Atzeri
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Garnier @ 2016-01-29 12:03 UTC (permalink / raw)
  To: cygwin

Hello.
I'm trying to do SHA-512 password encryption, but the result is really
weird on Cygwin:

# On Cygwin(either 32 or 64) 2.4.1-1, latest updates with crypt 1.1-1,
libcrypt0 1.1-1, libcrypt-devel 1.1-1
$ crypt '$6$7dl4B0fKUimdnR$' test_value
$6wOs/zKP2jDM

$ python -c 'import crypt; print crypt.crypt("test_value",
"$6$7dl4B0fKUimdnR$")' # Python 2.7.10
$6wOs/zKP2jDM

$ perl -e 'print crypt("test_value", "\$6\$7dl4B0fKUimdnR\$")."\n"' #
Perl v5.22.1
$6wOs/zKP2jDM

Am I missing something?

On other system, I get a more expected result:

# On Ubuntu 15.04
$ mkpasswd --method=SHA-512 test_value 7dl4B0fKUimdnR
$6$7dl4B0fKUimdnR$f6gCu.3IfrxhsnJKFnusDH.UudC.lLOSB1G3D1bIboWxlixzBy2xO/3rCKHmzfwekCTvmQd11bPdcsJOaLkCJ.

$ python -c 'import crypt; print crypt.crypt("test_value",
"$6$7dl4B0fKUimdnR$")' # Python 2.7.10
$6$7dl4B0fKUimdnR$f6gCu.3IfrxhsnJKFnusDH.UudC.lLOSB1G3D1bIboWxlixzBy2xO/3rCKHmzfwekCTvmQd11bPdcsJOaLkCJ.

$ perl -e 'print crypt("test_value", "\$6\$7dl4B0fKUimdnR\$")."\n"' #
Perl v5.20.2
$6$7dl4B0fKUimdnR$f6gCu.3IfrxhsnJKFnusDH.UudC.lLOSB1G3D1bIboWxlixzBy2xO/3rCKHmzfwekCTvmQd11bPdcsJOaLkCJ.


# On RHEL 6.6
$ python -c 'import crypt; print crypt.crypt("test_value",
"$6$7dl4B0fKUimdnR$")' # Python 2.6.6
$6$7dl4B0fKUimdnR$f6gCu.3IfrxhsnJKFnusDH.UudC.lLOSB1G3D1bIboWxlixzBy2xO/3rCKHmzfwekCTvmQd11bPdcsJOaLkCJ.

$ perl -e 'print crypt("test_value", "\$6\$7dl4B0fKUimdnR\$")."\n"' #
Perl v5.10.1
$6$7dl4B0fKUimdnR$f6gCu.3IfrxhsnJKFnusDH.UudC.lLOSB1G3D1bIboWxlixzBy2xO/3rCKHmzfwekCTvmQd11bPdcsJOaLkCJ.

-- 
Alex

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Weird behavior of crypt
  2016-01-29 12:03 Weird behavior of crypt Alexandre Garnier
@ 2016-01-29 12:09 ` Marco Atzeri
  2016-01-29 14:00   ` Ismail Donmez
  2016-01-29 14:44   ` Corinna Vinschen
  0 siblings, 2 replies; 5+ messages in thread
From: Marco Atzeri @ 2016-01-29 12:09 UTC (permalink / raw)
  To: cygwin



On 29/01/2016 12:18, Alexandre Garnier wrote:
> Hello.
> I'm trying to do SHA-512 password encryption, but the result is really
> weird on Cygwin:
>
> # On Cygwin(either 32 or 64) 2.4.1-1, latest updates with crypt 1.1-1,
> libcrypt0 1.1-1, libcrypt-devel 1.1-1
> $ crypt '$6$7dl4B0fKUimdnR$' test_value
> $6wOs/zKP2jDM
>
> $ python -c 'import crypt; print crypt.crypt("test_value",
> "$6$7dl4B0fKUimdnR$")' # Python 2.7.10
> $6wOs/zKP2jDM
>
> $ perl -e 'print crypt("test_value", "\$6\$7dl4B0fKUimdnR\$")."\n"' #
> Perl v5.22.1
> $6wOs/zKP2jDM
>
> Am I missing something?
>
> On other system, I get a more expected result:
>
> # On Ubuntu 15.04
> $ mkpasswd --method=SHA-512 test_value 7dl4B0fKUimdnR
> $6$7dl4B0fKUimdnR$f6gCu.3IfrxhsnJKFnusDH.UudC.lLOSB1G3D1bIboWxlixzBy2xO/3rCKHmzfwekCTvmQd11bPdcsJOaLkCJ.
>

Not SHA-512, see
/usr/share/doc/crypt/crypt.README

This is the DES-crypt package Version 1.1

It provides a static library libcrypt.a as well as a shared library
cygcrypt-0.dll together with a link lib libcrypt.dll.a, which export
the functions

         crypt(3)
         encrypt(3)
         setkey(3)

The passwords created by crypt(3) are 56 bit DES encrypted and are
100% identical to those created by the Linux crypt().

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Weird behavior of crypt
  2016-01-29 12:09 ` Marco Atzeri
@ 2016-01-29 14:00   ` Ismail Donmez
  2016-01-29 14:44   ` Corinna Vinschen
  1 sibling, 0 replies; 5+ messages in thread
From: Ismail Donmez @ 2016-01-29 14:00 UTC (permalink / raw)
  To: cygwin

Hi,

On Fri, Jan 29, 2016 at 1:39 PM, Marco Atzeri <marco.atzeri@gmail.com> wrote:
> The passwords created by crypt(3) are 56 bit DES encrypted and are
> 100% identical to those created by the Linux crypt().

crypt(3) on Linux support SHA-256 & SHA-512, $6$ prefix means SHA-512
is requested.

Regards,
ismail

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Weird behavior of crypt
  2016-01-29 12:09 ` Marco Atzeri
  2016-01-29 14:00   ` Ismail Donmez
@ 2016-01-29 14:44   ` Corinna Vinschen
  2016-01-29 15:19     ` Alexandre Garnier
  1 sibling, 1 reply; 5+ messages in thread
From: Corinna Vinschen @ 2016-01-29 14:44 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1827 bytes --]

On Jan 29 12:39, Marco Atzeri wrote:
> 
> 
> On 29/01/2016 12:18, Alexandre Garnier wrote:
> >Hello.
> >I'm trying to do SHA-512 password encryption, but the result is really
> >weird on Cygwin:
> >
> ># On Cygwin(either 32 or 64) 2.4.1-1, latest updates with crypt 1.1-1,
> >libcrypt0 1.1-1, libcrypt-devel 1.1-1
> >$ crypt '$6$7dl4B0fKUimdnR$' test_value
> >$6wOs/zKP2jDM
> >
> >$ python -c 'import crypt; print crypt.crypt("test_value",
> >"$6$7dl4B0fKUimdnR$")' # Python 2.7.10
> >$6wOs/zKP2jDM
> >
> >$ perl -e 'print crypt("test_value", "\$6\$7dl4B0fKUimdnR\$")."\n"' #
> >Perl v5.22.1
> >$6wOs/zKP2jDM
> >
> >Am I missing something?
> >
> >On other system, I get a more expected result:
> >
> ># On Ubuntu 15.04
> >$ mkpasswd --method=SHA-512 test_value 7dl4B0fKUimdnR
> >$6$7dl4B0fKUimdnR$f6gCu.3IfrxhsnJKFnusDH.UudC.lLOSB1G3D1bIboWxlixzBy2xO/3rCKHmzfwekCTvmQd11bPdcsJOaLkCJ.
> >

You're aware that the password field in /etc/passwd is not used, right?
Passwords are checked against the Windows user DB.  In fact, /etc/passwd
is not necessary anymore.

> Not SHA-512, see
> /usr/share/doc/crypt/crypt.README
> 
> This is the DES-crypt package Version 1.1
> 
> It provides a static library libcrypt.a as well as a shared library
> cygcrypt-0.dll together with a link lib libcrypt.dll.a, which export
> the functions
> 
>         crypt(3)
>         encrypt(3)
>         setkey(3)
> 
> The passwords created by crypt(3) are 56 bit DES encrypted and are
> 100% identical to those created by the Linux crypt().

Right.  If you need the hashes for other purposes than /etc/passwd,
you can use `openssl sha512'


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Weird behavior of crypt
  2016-01-29 14:44   ` Corinna Vinschen
@ 2016-01-29 15:19     ` Alexandre Garnier
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Garnier @ 2016-01-29 15:19 UTC (permalink / raw)
  To: cygwin

2016-01-29 13:09 GMT+01:00 Corinna Vinschen <corinna-cygwin@cygwin.com>:
> On Jan 29 12:39, Marco Atzeri wrote:
>>
>>
>> On 29/01/2016 12:18, Alexandre Garnier wrote:
>> >Hello.
>> >I'm trying to do SHA-512 password encryption, but the result is really
>> >weird on Cygwin:
>> >
>> ># On Cygwin(either 32 or 64) 2.4.1-1, latest updates with crypt 1.1-1,
>> >libcrypt0 1.1-1, libcrypt-devel 1.1-1
>> >$ crypt '$6$7dl4B0fKUimdnR$' test_value
>> >$6wOs/zKP2jDM
>> >
>> >$ python -c 'import crypt; print crypt.crypt("test_value",
>> >"$6$7dl4B0fKUimdnR$")' # Python 2.7.10
>> >$6wOs/zKP2jDM
>> >
>> >$ perl -e 'print crypt("test_value", "\$6\$7dl4B0fKUimdnR\$")."\n"' #
>> >Perl v5.22.1
>> >$6wOs/zKP2jDM
>> >
>> >Am I missing something?
>> >
>> >On other system, I get a more expected result:
>> >
>> ># On Ubuntu 15.04
>> >$ mkpasswd --method=SHA-512 test_value 7dl4B0fKUimdnR
>> >$6$7dl4B0fKUimdnR$f6gCu.3IfrxhsnJKFnusDH.UudC.lLOSB1G3D1bIboWxlixzBy2xO/3rCKHmzfwekCTvmQd11bPdcsJOaLkCJ.
>> >
>
> You're aware that the password field in /etc/passwd is not used, right?
> Passwords are checked against the Windows user DB.  In fact, /etc/passwd
> is not necessary anymore.
>
>> Not SHA-512, see
>> /usr/share/doc/crypt/crypt.README
>>
>> This is the DES-crypt package Version 1.1
>>
>> It provides a static library libcrypt.a as well as a shared library
>> cygcrypt-0.dll together with a link lib libcrypt.dll.a, which export
>> the functions
>>
>>         crypt(3)
>>         encrypt(3)
>>         setkey(3)
>>
>> The passwords created by crypt(3) are 56 bit DES encrypted and are
>> 100% identical to those created by the Linux crypt().
>
> Right.  If you need the hashes for other purposes than /etc/passwd,
> you can use `openssl sha512'

My use case is to generate encrypted password for use later on unix
system (using Python crypt library).
OK for crypt(1) providing only 56 bit DES.
But, could be nice for libcrypt (cygcrypt or crypt(3)) to provide
other algorithms so other libraries working with it (like Python or
Perl crypt libraries) could use those. Or at least raise an error when
not supported prefixes are used (like '$6$').

-- 
Alex

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-01-29 12:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-29 12:03 Weird behavior of crypt Alexandre Garnier
2016-01-29 12:09 ` Marco Atzeri
2016-01-29 14:00   ` Ismail Donmez
2016-01-29 14:44   ` Corinna Vinschen
2016-01-29 15:19     ` Alexandre Garnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).