1 .\" 2 .Dd October 6, 1987 3 .Dt DES_CRYPT 3 4 .Os 5 .Sh NAME 6 .Nm des_crypt , ecb_crypt , cbc_crypt , des_setparity 7 .Nd "fast DES encryption" 8 .Sh LIBRARY 9 .Lb libc 10 .Sh SYNOPSIS 11 .In rpc/des_crypt.h 12 .Ft int 13 .Fn ecb_crypt "char *key" "char *data" "unsigned datalen" "unsigned mode" 14 .Ft int 15 .Fn cbc_crypt "char *key" "char *data" "unsigned datalen" "unsigned mode" "char *ivec" 16 .Ft void 17 .Fn des_setparity "char *key" 18 .Sh DESCRIPTION 19 The 20 .Fn ecb_crypt 21 and 22 .Fn cbc_crypt 23 functions 24 implement the 25 .Tn NBS 26 .Tn DES 27 (Data Encryption Standard). 28 These routines are faster and more general purpose than 29 .Xr crypt 3 . 30 They also are able to utilize 31 .Tn DES 32 hardware if it is available. 33 The 34 .Fn ecb_crypt 35 function 36 encrypts in 37 .Tn ECB 38 (Electronic Code Book) 39 mode, which encrypts blocks of data independently. 40 The 41 .Fn cbc_crypt 42 function 43 encrypts in 44 .Tn CBC 45 (Cipher Block Chaining) 46 mode, which chains together 47 successive blocks. 48 .Tn CBC 49 mode protects against insertions, deletions and 50 substitutions of blocks. 51 Also, regularities in the clear text will 52 not appear in the cipher text. 53 .Pp 54 Here is how to use these routines. 55 The first argument, 56 .Fa key , 57 is the 8-byte encryption key with parity. 58 To set the key's parity, which for 59 .Tn DES 60 is in the low bit of each byte, use 61 .Fn des_setparity . 62 The second argument, 63 .Fa data , 64 contains the data to be encrypted or decrypted. 65 The 66 third argument, 67 .Fa datalen , 68 is the length in bytes of 69 .Fa data , 70 which must be a multiple of 8. 71 The fourth argument, 72 .Fa mode , 73 is formed by 74 .Em OR Ns 'ing 75 together some things. 76 For the encryption direction 77 .Em OR 78 in either 79 .Dv DES_ENCRYPT 80 or 81 .Dv DES_DECRYPT . 82 For software versus hardware 83 encryption, 84 .Em OR 85 in either 86 .Dv DES_HW 87 or 88 .Dv DES_SW . 89 If 90 .Dv DES_HW 91 is specified, and there is no hardware, then the encryption is performed 92 in software and the routine returns 93 .Er DESERR_NOHWDEVICE . 94 For 95 .Fn cbc_crypt , 96 the 97 .Fa ivec 98 argument 99 is the 8-byte initialization 100 vector for the chaining. 101 It is updated to the next initialization 102 vector upon return. 103 .Sh ERRORS 104 .Bl -tag -width [DESERR_NOHWDEVICE] -compact 105 .It Bq Er DESERR_NONE 106 No error. 107 .It Bq Er DESERR_NOHWDEVICE 108 Encryption succeeded, but done in software instead of the requested hardware. 109 .It Bq Er DESERR_HWERROR 110 An error occurred in the hardware or driver. 111 .It Bq Er DESERR_BADPARAM 112 Bad argument to routine. 113 .El 114 .Pp 115 Given a result status 116 .Va stat , 117 the macro 118 .Fn DES_FAILED stat 119 is false only for the first two statuses. 120 .Sh SEE ALSO 121 .\" .Xr des 1 , 122 .Xr crypt 3 123 .Sh RESTRICTIONS 124 These routines are not available in RPCSRC 4.0. 125 This information is provided to describe the 126 .Tn DES 127 interface expected by 128 Secure RPC. 129