Mailing List Archive

crypt, crypt16, and bigcrypt - worth changing?
There was some discussion of this on the list about a year ago, but I
don't think anything came of it. Recently I was sent more information.
I'm looking for people's views as to what, if anything, should be done.
The issue is the handling of password encryption using the
${crypteq{...}{...}} expansion condition.

The second argument is an encrypted password. Originally, it was assumed
encrypted with crypt(). Later, the ability to specify the encryption by
a leading {name} was added. Currently we have {crypt}, {crypt16}, {md5},
and {sha1}. The issue is with {crypt16}.

The default for when no {name} is given is defined by DEFAULT_CRYPT at
compile time. This defaults to "crypt"; it's suggested in EDITME that
you can change it to "crypt16", but in fact you can define it as any
function you like that takes two char* arguments and has the
specification of crypt().

When {crypt} is given, crypt() is called. When {crypt16} is given,
crypt16() is called. If HAVE_CRYPT16 is defined at compile time, the
operating system is assumed to have a function called crypt16().
Otherwise, an inbuilt Exim function is used.

The issue is that it appears that "crypt16" is ambiguous, and the
inbuild Exim function may be different to OS versions of crypt16().

I have been told that:

(1) Ultrix and Tru64 have a function called "crypt16", which encrypts up
to 16 characters of password in a particular way.

(2) HP-UX, Digital Unix, and OSF/1 have a function called "bigcrypt"
which encrypts some number of characters (may be up to 40 or more) in a
subtly different way. [.Despite this, the OS-specific Makefile for OSF/1
in Exim is the only one that has HAVE_CRYPT16 as a default. I don't have
access to an OSF/1 system to see if it has both crypt16() and bigcrypt()
and whether they are the same or different.]

(3) Exim's inbuilt crypt16() function is actually an implementation of
"bigcrypt", limited to 16 characters. It is compatible with "bigcrypt"
if the password is no longer than 16 characters.

To some extent I am confused, because I thought that OSF/1, Digital
Unix, and Tru64 were basically the same thing under different names. But
it is certainly somewhat of a mess.

However, the first question is: should any change be made? I don't
recall anybody reporting problems, and I suspect that the world is
moving on to other encryption methods such as {sha1} these days.

It was suggested that {crypt16} be deprecated in Exim, and replaced by
new names that more correctly indicate what encryption function is being
used. I am wondering if it really is worth the effort of doing this. An
alternative is just to update the documentation to make (1), (2), and
(3) above very clear.

If new names are to be used, we need names for

(1) Call the OS function crypt16().
(2) Call the OS function bigcrypt().
(3) Call Exim's built-in function, which is a sort of bigcrypt(), but
may give different results to an OS function for passwords longer than
16 characters.

Views?

--
Philip Hazel University of Cambridge Computing Service
Get the Exim 4 book: http://www.uit.co.uk/exim-book

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
Re: crypt, crypt16, and bigcrypt - worth changing? [ In reply to ]
On Tue, 12 Sep 2006, Philip Hazel wrote:

> (1) Ultrix and Tru64 have a function called "crypt16", which encrypts up
> to 16 characters of password in a particular way.
>
> (2) HP-UX, Digital Unix, and OSF/1 have a function called "bigcrypt"

digital unix 4.0b does not have it, but has crypt16, quoting manual:

"The crypt16 subroutine is identical to the crypt function except that
it will accept a password up to sixteen characters in length."

it does not go into details as to how exactly is this achieved.

hp-ux (10.20 and/or b.11.00) does have it, with the manual saying

"bigcrypt() acts like crypt(3C), but handles much larger strings.
bigcrypt takes the segments of cleartext and encrypts them
individually, at first using the salt passed in, and then using the
first two characters of the previous encrypted segment as the salt for
the next segment."

this is afair the same as the crypt16 implementation i dug up for
exim, with the difference of crypt16 only doing up to 16 characters,
and bigcrypt up to 40-something (iirc?).

> which encrypts some number of characters (may be up to 40 or more) in a
> subtly different way. [Despite this, the OS-specific Makefile for OSF/1

from what i can gather, it's exactly the same method, with crypt16()
being limited to 16 characters of input, and bigcrypt() to something a
bit bigger. ideally the exim-builtin crypt16 could be extended to
emulate bigcrypt. about a year ago someone asked about this, then i
got a bunch of test data from that chap (he was on hp-ux, i reckon),
which i can dig up if needed. i also have some test data which was
compiled on a tru64 or a digital unix (these were used to check the
current exim implementation).

technically, i think, this whole shebang can be pretty well automated
(from exim's point of view), with a bigcrypt implementation that
follows the way quoted above from the hpux manaual (that is, no need
to have {crypt} {crypt16} {bigcrypt} stuff, but {builtincrypt},
depending on the length of the input, could decide how many "passes"
to apply.

is this of any help?

--
[-]

mkdir /nonexistent

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
Re: crypt, crypt16, and bigcrypt - worth changing? [ In reply to ]
On Tue, 12 Sep 2006, Tamas TEVESZ wrote:

> from what i can gather, it's exactly the same method, with crypt16()
> being limited to 16 characters of input, and bigcrypt() to something a
> bit bigger.

I have been sent this comment:

There is an algorithm named "crypt16" in Ultrix and Tru64. It crypts
the first 8 characters of the password using a 20-round version of crypt
(standard crypt does 25 rounds). It then crypts the next 8 characters,
or an empty block if the password is less than 9 characters, using a
20-round version of crypt and the same salt as was used for the first
block. Charaters after the first 16 are ignored. It always generates
a 16-byte hash, which is expressed together with the salt as a string
of 24 base 64 digits. Here are some links to peruse:

http://cvs.pld.org.pl/pam/pamcrypt/crypt16.c?rev=1.2
http://seclists.org/bugtraq/1999/Mar/0076.html

There's a different algorithm named "bigcrypt" in HP-UX, Digital Unix,
and OSF/1. This is the same as the standard crypt if given a password
of 8 characters or less. If given more, it first does the same as crypt
using the first 8 characters, then crypts the next 8 (the 9th to 16th)
using as salt the first two base 64 digits from the first hash block.
If the password is more than 16 characters then it crypts the 17th to 24th
characters using as salt the first two base 64 digits from the second hash
block. And so on: I've seen references to it cutting off the password at
40 characters (5 blocks), 80 (10 blocks), or 128 (16 blocks). Some links:

http://cvs.pld.org.pl/pam/pamcrypt/bigcrypt.c?rev=1.2
http://seclists.org/bugtraq/1999/Mar/0109.html
http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-Q0R2D-
http:TET1_html/sec.c222.html#no_id_208

This suggests that there *is* a difference between the crypt16() and
bigcrypt() algorithms. That's what made me ask my question.

> ideally the exim-builtin crypt16 could be extended to
> emulate bigcrypt. about a year ago someone asked about this, then i
> got a bunch of test data from that chap (he was on hp-ux, i reckon),
> which i can dig up if needed. i also have some test data which was
> compiled on a tru64 or a digital unix (these were used to check the
> current exim implementation).

If current operating systems contain suitable functions, I don't see the
need for having one built into Exim any more.

> technically, i think, this whole shebang can be pretty well automated
> (from exim's point of view), with a bigcrypt implementation that
> follows the way quoted above from the hpux manaual (that is, no need
> to have {crypt} {crypt16} {bigcrypt} stuff, but {builtincrypt},
> depending on the length of the input, could decide how many "passes"
> to apply.

Possible, I suppose. As I said, nobody has to my knowledge had problems
recently, so I do wonder how much effort it is worth expending on this.



--
Philip Hazel University of Cambridge Computing Service
Get the Exim 4 book: http://www.uit.co.uk/exim-book

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
Re: crypt, crypt16, and bigcrypt - worth changing? [ In reply to ]
On Tue, 2006-09-12 at 14:37 +0100, Philip Hazel wrote:
> However, the first question is: should any change be made? I don't
> recall anybody reporting problems, and I suspect that the world is
> moving on to other encryption methods such as {sha1} these days.

I think it's more common to stick to {crypt}, but crypt(3c) is more
clever these days and is extensible in itself. from /etc/shadow on a
typical Linux system:

$1$Bn7P0ASN$baWgRvs/4RPe1q8Ba12Ky0

as you can see, it's longer than the traditional crypt strings, and it's
separated into fields with dollar signs. $1 means use the algorithm
"salted MD5", the salt comes next, and finally the crypted password.
*BSD and Solaris supports this scheme, too. (I think it actually
originated on FreeBSD, but don't shoot me if that's the wrong
attribution.)

I don't think you should worry too much about bigcrypt and other weird
extensions. just make sure you pass along the _whole_ password to
crypt(3c), not just the first 8 characters. crypt(3c) will chop off
excess characters itself if need be.

--
Kjetil T.



--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
Re: crypt, crypt16, and bigcrypt - worth changing? [ In reply to ]
On Tue, 12 Sep 2006, Kjetil Torgrim Homme wrote:

> I think it's more common to stick to {crypt}, but crypt(3c) is more
> clever these days and is extensible in itself.

That's a good point. Perhaps that's why there haven't been any
complaints. :-)

> I don't think you should worry too much about bigcrypt and other weird
> extensions. just make sure you pass along the _whole_ password to
> crypt(3c), not just the first 8 characters.

Exim has always done that.


--
Philip Hazel University of Cambridge Computing Service
Get the Exim 4 book: http://www.uit.co.uk/exim-book

--
## List details at http://www.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##