DragonFly On-Line Manual Pages
CIPHER(3) DragonFly Library Functions Manual CIPHER(3)
setkey, encrypt, des_setkey, des_cipher -- DES encryption
FreeSec Crypt Library (libcipher, -lcipher)
setkey(const char *key);
encrypt(char *block, int flag);
des_setkey(const char *key);
des_cipher(const char *in, char *out, long salt, int count);
The functions, encrypt(), setkey(), des_setkey() and des_cipher() provide
access to the DES algorithm. setkey() is passed a 64-byte array of
binary values (numeric 0 or 1). A 56-bit key is extracted from this
array by dividing the array into groups of 8, and ignoring the last bit
in each group. That bit is reserved for a byte parity check by DES, but
is ignored by these functions.
The block argument to encrypt() is also a 64-byte array of binary values.
If the value of flag is 0, block is encrypted otherwise it is decrypted.
The result is returned in the original array block after using the key
specified by setkey() to process it.
The argument to des_setkey() is a character array of length 8. The least
significant bit (the parity bit) in each character is ignored, and the
remaining bits are concatenated to form a 56-bit key. The function
des_cipher() encrypts (or decrypts if count is negative) the 64-bits
stored in the 8 characters at in using abs(3) of count iterations of DES
and stores the 64-bit result in the 8 characters at out (which may be the
same as in). The salt introduces disorder in the DES algorithm in one of
16777216 or 4096 possible ways (ie. with 24 or 12 bits: if bit i of the
salt is set, then bits i and i+24 are swapped in the DES E-box output).
The functions setkey(), encrypt(), des_setkey(), and des_cipher() return
0 on success and 1 on failure.
The setkey() and des_setkey() functions manipulate the same key space.
login(1), passwd(1), crypt(3), getpass(3), passwd(5)
This library (FreeSec 1.0) was developed outside the United States of
America as an unencumbered replacement for the U.S.-only NetBSD libcrypt
encryption library. Users should be aware that this code (and programs
staticly linked with it) may not be exported from the U.S., although it
apparently can be imported.
David Burren <email@example.com>
DragonFly 4.1 March 9, 1994 DragonFly 4.1