Back to index

glibc  2.9
des_crypt.h
Go to the documentation of this file.
00001 /*
00002  * @(#)des_crypt.h   2.1 88/08/11 4.0 RPCSRC;    from 1.4 88/02/08 (C) 1986 SMI
00003  *
00004  * des_crypt.h, des library routine interface
00005  * Copyright (C) 1986, Sun Microsystems, Inc.
00006  */
00007 /*
00008  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
00009  * unrestricted use provided that this legend is included on all tape
00010  * media and as a part of the software program in whole or part.  Users
00011  * may copy or modify Sun RPC without charge, but are not authorized
00012  * to license or distribute it to anyone else except as part of a product or
00013  * program developed by the user.
00014  *
00015  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
00016  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
00017  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
00018  *
00019  * Sun RPC is provided with no support and without any obligation on the
00020  * part of Sun Microsystems, Inc. to assist in its use, correction,
00021  * modification or enhancement.
00022  *
00023  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
00024  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
00025  * OR ANY PART THEREOF.
00026  *
00027  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
00028  * or profits or other special, indirect and consequential damages, even if
00029  * Sun has been advised of the possibility of such damages.
00030  *
00031  * Sun Microsystems, Inc.
00032  * 2550 Garcia Avenue
00033  * Mountain View, California  94043
00034  */
00035 
00036 #ifndef __DES_CRYPT_H__
00037 #define __DES_CRYPT_H__ 1
00038 
00039 #include <features.h>
00040 
00041 __BEGIN_DECLS
00042 
00043 #define DES_MAXDATA 8192    /* max bytes encrypted in one call */
00044 #define DES_DIRMASK (1 << 0)
00045 #define DES_ENCRYPT (0*DES_DIRMASK)       /* Encrypt */
00046 #define DES_DECRYPT (1*DES_DIRMASK)       /* Decrypt */
00047 
00048 
00049 #define DES_DEVMASK (1 << 1)
00050 #define       DES_HW (0*DES_DEVMASK)      /* Use hardware device */
00051 #define DES_SW (1*DES_DEVMASK)     /* Use software device */
00052 
00053 
00054 #define DESERR_NONE 0       /* succeeded */
00055 #define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */
00056 #define DESERR_HWERROR 2    /* failed, hardware/driver error */
00057 #define DESERR_BADPARAM 3   /* failed, bad parameter to call */
00058 
00059 #define DES_FAILED(err) \
00060        ((err) > DESERR_NOHWDEVICE)
00061 
00062 /*
00063  * cbc_crypt()
00064  * ecb_crypt()
00065  *
00066  * Encrypt (or decrypt) len bytes of a buffer buf.
00067  * The length must be a multiple of eight.
00068  * The key should have odd parity in the low bit of each byte.
00069  * ivec is the input vector, and is updated to the new one (cbc only).
00070  * The mode is created by oring together the appropriate parameters.
00071  * DESERR_NOHWDEVICE is returned if DES_HW was specified but
00072  * there was no hardware to do it on (the data will still be
00073  * encrypted though, in software).
00074  */
00075 
00076 
00077 /*
00078  * Cipher Block Chaining mode
00079  */
00080 extern int cbc_crypt (char *__key, char *__buf, unsigned __len,
00081                     unsigned __mode, char *__ivec) __THROW;
00082 
00083 /*
00084  * Electronic Code Book mode
00085  */
00086 extern int ecb_crypt (char *__key, char *__buf, unsigned __len,
00087                     unsigned __mode) __THROW;
00088 
00089 /*
00090  * Set des parity for a key.
00091  * DES parity is odd and in the low bit of each byte
00092  */
00093 extern void des_setparity (char *__key) __THROW;
00094 
00095 __END_DECLS
00096 
00097 #endif