home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / des / des_crypt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-15  |  3.0 KB  |  104 lines

  1. /*
  2.  * @(#)des_crypt.h    2.1 88/08/11 4.0 RPCSRC;    from 1.4 88/02/08 (C) 1986 SMI
  3.  *
  4.  * des_crypt.h, des library routine interface
  5.  * Copyright (C) 1986, Sun Microsystems, Inc.
  6.  */
  7. /*
  8.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  9.  * unrestricted use provided that this legend is included on all tape
  10.  * media and as a part of the software program in whole or part.  Users
  11.  * may copy or modify Sun RPC without charge, but are not authorized
  12.  * to license or distribute it to anyone else except as part of a product or
  13.  * program developed by the user.
  14.  * 
  15.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  16.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  17.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  18.  * 
  19.  * Sun RPC is provided with no support and without any obligation on the
  20.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  21.  * modification or enhancement.
  22.  * 
  23.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  24.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  25.  * OR ANY PART THEREOF.
  26.  * 
  27.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  28.  * or profits or other special, indirect and consequential damages, even if
  29.  * Sun has been advised of the possibility of such damages.
  30.  * 
  31.  * Sun Microsystems, Inc.
  32.  * 2550 Garcia Avenue
  33.  * Mountain View, California  94043
  34.  */
  35.  
  36. #ifndef _DES_CRYPT_H
  37. #define _DES_CRYPT_H
  38.  
  39. #include <features.h>
  40.  
  41. #define DES_MAXDATA 8192    /* max bytes encrypted in one call */
  42. #define DES_DIRMASK (1 << 0)
  43. #define DES_ENCRYPT (0*DES_DIRMASK)    /* Encrypt */
  44. #define DES_DECRYPT (1*DES_DIRMASK)    /* Decrypt */
  45.  
  46.  
  47. #define DES_DEVMASK (1 << 1)
  48. #define    DES_HW (0*DES_DEVMASK)    /* Use hardware device */ 
  49. #define DES_SW (1*DES_DEVMASK)    /* Use software device */
  50.  
  51.  
  52. #define DESERR_NONE 0    /* succeeded */
  53. #define DESERR_NOHWDEVICE 1    /* succeeded, but hw device not available */
  54. #define DESERR_HWERROR 2    /* failed, hardware/driver error */
  55. #define DESERR_BADPARAM 3    /* failed, bad parameter to call */
  56.  
  57. #define DES_FAILED(err) \
  58.     ((err) > DESERR_NOHWDEVICE)
  59.  
  60. /*
  61.  * cbc_crypt()
  62.  * ecb_crypt()
  63.  *
  64.  * Encrypt (or decrypt) len bytes of a buffer buf.
  65.  * The length must be a multiple of eight.
  66.  * The key should have odd parity in the low bit of each byte.
  67.  * ivec is the input vector, and is updated to the new one (cbc only).
  68.  * The mode is created by oring together the appropriate parameters.
  69.  * DESERR_NOHWDEVICE is returned if DES_HW was specified but
  70.  * there was no hardware to do it on (the data will still be
  71.  * encrypted though, in software).
  72.  */
  73.  
  74. __BEGIN_DECLS
  75.  
  76. /*
  77.  * Cipher Block Chaining mode
  78.  */
  79. int cbc_crypt __P ((char *__key, char *__buf, unsigned __len, 
  80.             unsigned __mode, char *__ivec));    
  81.  
  82.  
  83. /*
  84.  * Electronic Code Book mode
  85.  */
  86. int ecb_crypt __P ((char *__key, char *__buf, unsigned __len,
  87.            unsigned __mode));
  88.  
  89.  
  90.  
  91. #ifndef KERNEL
  92. /* 
  93.  * Set des parity for a key.
  94.  * DES parity is odd and in the low bit of each byte
  95.  */
  96. void
  97. des_setparity __P ((char *__key));    
  98.  
  99. #endif
  100.  
  101. __END_DECLS
  102.  
  103. #endif /* _DES_CRYPT_H */
  104.