1DES_CRYPT(3)               Linux Programmer's Manual              DES_CRYPT(3)
2
3
4

NAME

6       des_crypt,  ecb_crypt,  cbc_crypt, des_setparity, DES_FAILED - fast DES
7       encryption
8

SYNOPSIS

10       #include <rpc/des_crypt.h>
11
12       int ecb_crypt(char *key, char *data, unsigned int datalen,
13                     unsigned int mode);
14       int cbc_crypt(char *key, char *data, unsigned int datalen,
15                     unsigned int mode, char *ivec);
16
17       void des_setparity(char *key);
18
19       int DES_FAILED(int status);
20

DESCRIPTION

22       ecb_crypt() and cbc_crypt() implement  the  NBS  DES  (Data  Encryption
23       Standard).   These  routines  are  faster and more general purpose than
24       crypt(3).  They also are able to utilize DES hardware if it  is  avail‐
25       able.   ecb_crypt()  encrypts in ECB (Electronic Code Book) mode, which
26       encrypts blocks of data independently.   cbc_crypt()  encrypts  in  CBC
27       (Cipher  Block Chaining) mode, which chains together successive blocks.
28       CBC mode protects against insertions, deletions, and  substitutions  of
29       blocks.   Also,  regularities  in the clear text will not appear in the
30       cipher text.
31
32       Here is how to use these routines.  The first  argument,  key,  is  the
33       8-byte  encryption key with parity.  To set the key's parity, which for
34       DES is in the low bit of each byte, use  des_setparity().   The  second
35       argument,  data,  contains  the data to be encrypted or decrypted.  The
36       third argument, datalen, is the length in bytes of data, which must  be
37       a  multiple  of  8.   The fourth argument, mode, is formed by ORing to‐
38       gether some things.  For the encryption direction OR in either  DES_EN‐
39       CRYPT  or  DES_DECRYPT.  For software versus hardware encryption, OR in
40       either DES_HW or DES_SW.  If DES_HW is specified, and there is no hard‐
41       ware,  then the encryption is performed in software and the routine re‐
42       turns DESERR_NOHWDEVICE.  For cbc_crypt(), the  argument  ivec  is  the
43       8-byte  initialization  vector  for the chaining.  It is updated to the
44       next initialization vector upon return.
45

RETURN VALUE

47       DESERR_NONE
48              No error.
49
50       DESERR_NOHWDEVICE
51              Encryption succeeded, but done in software instead  of  the  re‐
52              quested hardware.
53
54       DESERR_HWERROR
55              An error occurred in the hardware or driver.
56
57       DESERR_BADPARAM
58              Bad argument to routine.
59
60       Given  a  result  status stat, the macro DES_FAILED(stat) is false only
61       for the first two statuses.
62

VERSIONS

64       These functions were added to glibc in version 2.1.
65
66       Because they employ the DES block cipher, which is no longer considered
67       secure,  ecb_crypt(),  ecb_crypt(), crypt_r(), and des_setparity() were
68       removed in glibc 2.28.  Applications should switch to a modern cryptog‐
69       raphy library, such as libgcrypt.
70

ATTRIBUTES

72       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
73       tributes(7).
74
75       ┌────────────────────────────────────────────┬───────────────┬─────────┐
76Interface                                   Attribute     Value   
77       ├────────────────────────────────────────────┼───────────────┼─────────┤
78ecb_crypt(), cbc_crypt(), des_setparity()   │ Thread safety │ MT-Safe │
79       └────────────────────────────────────────────┴───────────────┴─────────┘
80

CONFORMING TO

82       4.3BSD.  Not in POSIX.1.
83

SEE ALSO

85       des(1), crypt(3), xcrypt(3)
86

COLOPHON

88       This page is part of release 5.13 of the Linux  man-pages  project.   A
89       description  of  the project, information about reporting bugs, and the
90       latest    version    of    this    page,    can     be     found     at
91       https://www.kernel.org/doc/man-pages/.
92
93
94
95                                  2021-03-22                      DES_CRYPT(3)
Impressum