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