Extended Library Functions ecbcrypt(3EXT)
NAME
ecbcrypt, cbccrypt, dessetparity, DESFAILED - fast DES
encryption
SYNOPSIS
#include
int ecbcrypt(char *key, char *data, unsigned datalen,
unsigned mode);
int cbccrypt(char *key, char *data, unsigned datalen,
unsigned mode, char *ivec);
void dessetparity(char *key);
int DESFAILED(int stat);
DESCRIPTION
ecbcrypt() and cbccrypt() implement the NBS DES (Data
Encryption Standard). These routines are faster and more
general purpose than crypt(3C). They also are able to util-
ize DES hardware if it is available. ecbcrypt() encrypts in
ECB (Electronic Code Book) mode, which encrypts blocks of
data independently. cbccrypt() encrypts in CBC (Cipher
Block Chaining) mode, which chains together successive
blocks. CBC mode protects against insertions, deletions, and
substitutions of blocks. Also, regularities in the clear
text will not appear in the cipher text.
The first parameter, key, is the 8-byte encryption key with
parity. To set the key's parity, which for DES is in the low
bit of each byte, use dessetparity(). The second parameter,
data, contains the data to be encrypted or decrypted. The
third parameter, datalen, is the length in bytes of data,
which must be a multiple of 8. The fourth parameter, mode,
is formed by OR'ing together the DESENCRYPT or DESDECRYPT
to specify the encryption direction and DESHW or DESW to
specify software or hardware encryption. If DESHW is speci-
fied, and there is no hardware, then the encryption is per-
formed in software and the routine returns
DESERNOHWDEVICE.
For cbccrypt(), the parameter ivec is the 8-byte initiali-
zation vector for the chaining. It is updated to the next
initialization vector upon successful return.
SunOS 5.11 Last change: 3 Mar 2008 1
Extended Library Functions ecbcrypt(3EXT)
RETURN VALUES
Given a result status stat, the macro DESFAILED is false
only for the first two statuses.
DESERNONE No error.
DESERNOHWDEVICE Encryption succeeded, but done in
software instead of the requested
hardware.
DESERHWEROR An error occurred in the hardware or
driver.
DESERBADPARAM Bad parameter to routine.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
MT-Level MT-Safe
SEE ALSO
crypt(3C), attributes(5)
NOTES
When compiling multi-thread applications, the RENTRANT
flag must be defined on the compile line. This flag should
only be used in multi-thread applications.
SunOS 5.11 Last change: 3 Mar 2008 2
|