Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ crypt(S) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

crypt(C)

getpass(S)

login(M)

passwd(C)

passwd(FP)


 crypt(S)                       6 January 1993                       crypt(S)


 Name

    crypt - password and file encryption functions

 Syntax


    cc -x2.3 . . . -lcrypt            (OMF binaries)

    cc . . . /usr/lib/libcryptd.a    (domestic, COFF binaries)

    cc . . . /usr/lib/libcrypti.a    (international, COFF binaries)


    void setkey (key)
    char *key;

    char *crypt (key, salt)
    char *key, *salt;

    void encrypt (block, flag)
    char *block;
    int flag;

    char *des_crypt (key, salt)
    char *key, *salt;

    void des_encrypt (block, flag)
    char *block;
    int flag;

    void des_setkey (key)
    char *key;

    int cryptopen (p)
    int p[2];

    int run_setkey (p, key)
    int p[2];
    char *key;

    int run_crypt (offset, buffer, count, p)
    long offset;
    char *buffer;
    unsigned int count;
    int p[2];

    int crypt_close(p)
    int p[2];


 Description

    descrypt is the password encryption function.  It is based on a one-way
    hashing encryption algorithm with variations intended (among other
    things) to frustrate use of hardware implementations of a key search.

    key is a user's typed password.  salt is a two-character string chosen
    from the set [a-z,A-Z,0-9].  This string is used to perturb the hashing
    algorithm in one of 4096 different ways, after which the password is used
    as the key to encrypt repeatedly a constant string.  The returned value
    points to the encrypted password.  The first two characters are the salt
    itself.

    The dessetkey and desencrypt entries provide (rather primitive) access
    to the actual hashing algorithm.  The argument of dessetkey is a charac-
    ter array of length 64 containing only the characters with numerical
    value 0 and 1.  If this string is divided into groups of 8, the low-order
    bit in each group is ignored; this gives a 56-bit key which is set into
    the machine.  This is the key that is used with the hashing algorithm to
    encrypt the string block with the function desencrypt.

    The argument to the desencrypt entry is a character array of length 64
    containing only the characters with numerical value 0 and 1.  The argu-
    ment array is modified in place to a similar array representing the bits
    of the argument after having been subjected to the hashing algorithm
    using the key set by dessetkey.  If edflag is zero, the argument is
    encrypted; if non-zero, it is decrypted.

    Note that decryption is not provided in the international version of
    crypt(S).  If decryption is attempted with the international version of
    desencrypt, an error message is printed.

    crypt, setkey, and encrypt are front-end routines that invoke descrypt,
    dessetkey, and desencrypt respectively.

    The routines runsetkey and runcrypt are designed for use by applica-
    tions that need cryptographic capabilities (such as ed(C) and vi(C)) that
    must be compatible with the crypt(C) user-level utility.  runsetkey
    establishes a two-way pipe connection with crypt(C), using key as the
    password argument.

    cryptopen returns a pair of file descriptors for input and output streams
    connections to the /bin/crypt encryption utility.  runcrypt takes a
    block of characters and transforms the cleartext or ciphertext using
    crypt(C).  offset is the relative byte position from the beginning of the
    file that the block of text provided in buffer is coming from.  count is
    the number of characters in buffer, and p is an array containing file
    descriptor indices to a table of input and output file streams.  When
    encryption is finished, cryptclose is used to terminate the connection
    with crypt(C).

    runsetkey returns -1 if a connection with crypt(C) cannot be esta-
    blished.  This occurs on international versions of the Operating System
    where crypt(C) is not available.  If a null key is passed to runsetkey,
    0 is returned.  Otherwise, 1 is returned.  cryptopen returns 1 if suc-
    cessful and -1 on an error.  runcrypt returns -1 if it cannot write out-
    put or read input from the pipe attached to crypt.  Otherwise it returns
    0.

 Diagnostics

    In the international version of crypt(S), a flag argument of 1 to
    desencrypt is not accepted, and an error message is printed.

 Note

    The return value in crypt points to static data that is overwritten by
    each call.

 See also

    crypt(C), getpass(S), login(M), passwd(C), passwd(FP)

 Standards conformance

    crypt is conformant with:
    AT&T SVID Issue 2;
    and X/Open Portability Guide, Issue 3, 1989.


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026