1ecb_crypt(3EXT) Extended Library Functions ecb_crypt(3EXT)
2
3
4
6 ecb_crypt, cbc_crypt, des_setparity, DES_FAILED - fast DES encryption
7
9 #include <rpc/des_crypt.h>
10
11 int ecb_crypt(char *key, char *data, unsigned datalen,
12 unsigned mode);
13
14
15 int cbc_crypt(char *key, char *data, unsigned datalen,
16 unsigned mode, char *ivec);
17
18
19 void des_setparity(char *key);
20
21
22 int DES_FAILED(int stat);
23
24
26 ecb_crypt() and cbc_crypt() implement the NBS DES (Data Encryption
27 Standard). These routines are faster and more general purpose than
28 crypt(3C). They also are able to utilize DES hardware if it is avail‐
29 able. ecb_crypt() encrypts in ECB (Electronic Code Book) mode, which
30 encrypts blocks of data independently. cbc_crypt() encrypts in CBC
31 (Cipher Block Chaining) mode, which chains together successive blocks.
32 CBC mode protects against insertions, deletions, and substitutions of
33 blocks. Also, regularities in the clear text will not appear in the
34 cipher text.
35
36
37 The first parameter, key, is the 8-byte encryption key with parity. To
38 set the key's parity, which for DES is in the low bit of each byte, use
39 des_setparity(). The second parameter, data, contains the data to be
40 encrypted or decrypted. The third parameter, datalen, is the length in
41 bytes of data, which must be a multiple of 8. The fourth parameter,
42 mode, is formed by OR'ing together the DES_ENCRYPT or DES_DECRYPT to
43 specify the encryption direction and DES_HW or DES_SW to specify soft‐
44 ware or hardware encryption. If DES_HW is specified, and there is no
45 hardware, then the encryption is performed in software and the routine
46 returns DESERR_NOHWDEVICE.
47
48
49 For cbc_crypt(), the parameter ivec is the 8-byte initialization vector
50 for the chaining. It is updated to the next initialization vector upon
51 successful return.
52
54 Given a result status stat, the macro DES_FAILED is false only for the
55 first two statuses.
56
57 DESERR_NONE No error.
58
59
60 DESERR_NOHWDEVICE Encryption succeeded, but done in software instead
61 of the requested hardware.
62
63
64 DESERR_HWERROR An error occurred in the hardware or driver.
65
66
67 DESERR_BADPARAM Bad parameter to routine.
68
69
71 See attributes(5) for descriptions of the following attributes:
72
73
74
75
76 ┌─────────────────────────────┬─────────────────────────────┐
77 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
78 ├─────────────────────────────┼─────────────────────────────┤
79 │MT-Level │MT-Safe │
80 └─────────────────────────────┴─────────────────────────────┘
81
83 crypt(3C), attributes(5)
84
86 When compiling multi-thread applications, the _REENTRANT flag must be
87 defined on the compile line. This flag should only be used in multi-
88 thread applications.
89
90
91
92SunOS 5.11 3 Mar 2008 ecb_crypt(3EXT)