Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: OSF/1 3.0 Prot. Password Encryption
Date: Wed, 5 Oct 94 16:55:07 BST	[thread overview]
Message-ID: <1994Oct5.165507.27227@inca.comlab.ox.ac.uk> (raw)
In-Reply-To: 36edl3$q02@chaos.dac.neu.edu

In article <36edl3$q02@chaos.dac.neu.edu>,
David Brady <dave@lynx.dac.neu.edu> wrote:
>Richard L Jackson Jr (rjackson@mason1.gmu.edu) wrote:
>
>: database appears to fail for passwords that are over 8 characters.  The
>: limited documentation in the man pages and /usr/include/*.h files
>: indicate the encrypted password is generated in segments.  WHAT IS THE
>: ACTUAL SCHEME DEC USES?
>
>  If you want to use the 24-character encryptions, use the crypt16() call.
>
>  Then, in the user's tcb entry, put in the field u_oldcrypt#1, so that
>  the password-checking routine will know what you're using a
>  24-character length encryption.
>
>  I know it's possible to get even longer encryptions, but I can't
>  remember how to do it.

There's a dreadful lack of documentation on all of this stuff. I've
managed to figure out most of it, though, from staring at include
files and trial and error. If what you're really after is how to
validate logins for daemons such as imap, pop, wu-ftpd and so on then
the "proper" interface is via set_auth_parameters, sia_ses_init,
sia_ses_authent (to check the password) and sia_ses_estab (to check
whether the user is allowed to log in--account locks, expiry and so on).
There's also sia_ses_launch which does the appropriate setting of
uid, gid and so on but that's usually less useful for daemons which
already have code to do that. I posted my patches to pop and imap
here yesterday and inspection of that may help. If DEC don't document
this stuff soon, I suppose I could put together something and post it
here when I have time.

Back to the actual question: DEC's algorithm for encrypting passwords.
The (undocumented) function which actually lets you do this directly
is called bigcrypt in libsecurity.so. Here's an example program:

#include <stdio.h>
#include <prot.h>

int main(int argc, char **argv)
{
    char *key;
    
    if (argc != 3)
    {
	fprintf(stderr, "Usage: bigcrypt salt key\n");
	exit(2);
    }
    key = argv[2];
    
    /* Don't want the audit log to include what we're crypting */
    argv[2] = 0;
    
    set_auth_parameters(2, argv);
    puts(bigcrypt(key, argv[1]));
    exit(0);
}

Compile this with
    cc -o bigcrypt bigcrypt.c -lsecurity

We discovered this sometime after a colleague, Paul Leyland (pcl@ox.ac.uk),
discovered what the actual algorithm was and rolled-his-own.
/usr/include/prot.h says:
    /*
     * The size of the ciphertext is the salt at the
     * beginning, a series of 11-character segments produced by
     * each call to crypt(), and the trailing end-of-string character.
     * Each 11-character segment uses the a newly computed salt based
     * on the previous encrypted value.
     */
The only thing missing is how it computes the salt for each successive
block of 8 characters. In fact, it's simple. It splits the text to
be bigcrypted into 8 character chunks. It takes the salt and the
first chunk of 8 bits and does crypt(salt, chunk1) using standard crypt.
(Notice that this means that passwords with 8 characters or fewer will
"work" with ordinary crypt, although not crypt16 which is different again).
The first 2 characters of crypt1 are just the salt that you fed in,
of course. The following two characters are taken to be the salt for the
next block of 8 plaintext characters and crypt is done again.
Let crypt'(salt, text) be what the usual crypt returns but omitting the
first two characters (which are just the original salt). Then the
plaintext is split up into 8 byte blocks, text1, text2, ... Taking the
salt required for the whole thing, we do
    crypt1 = crypt'(salt, text1);
    salt1 = first_two_chars(crypt1);
    crypt2 = crypt'(salt1, crypt1);
    salt2 = first_two_chars(crypt2);
    crypt3 = crypt'(salt2, crypt2);
and so on. The result of the whole process is the concatenaation of
salt, crypt1, crypt2, crypt3, ... A concrete example:
    sable% ./bigcrypt ab 12345678abcdefgh
(*) ab1iBa.N.U2C6JI06ws2gRbQ

An ordinary crypt of the first 8 bytes (which bigcrypt does identically):
    sable% ./bigcrypt ab 12345678
    ab1iBa.N.U2C6
    ^^ original salt
      ^^ used as salt to next round
(1)   ^^^^^^^^^^^ used as first 11 bytes of cipher text (ignoring salt)

    sable% ./bigcrypt 1i abcdefgh
    1iJI06ws2gRbQ
(2)   ^^^^^^^^^^^ used as next 11 bytes of cipher text

If you look at the result of bigcrypt above in (*) you'll see it's
the concatenation of the original salt (ab) then (1) and (2).

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk> (note new address)
Oxford University Computing Services
"Widget. It's got a widget. A lovely widget. A widget it has got." --Jack Dee


  reply	other threads:[~1994-10-05 15:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-09-28 13:56 OSF/1 3.0 Prot. Password Encryption Richard L Jackson Jr
1994-09-29 12:58 ` David Brady
1994-10-05 15:55   ` Malcolm Beattie [this message]
1994-10-05 18:42 ` Jeff Scarborough
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox