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