Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:25:05

0001 /*
0002  * @(#)des_crypt.h  2.1 88/08/11 4.0 RPCSRC;    from 1.4 88/02/08 (C) 1986 SMI
0003  * $FreeBSD: src/include/rpc/des_crypt.h,v 1.4 2002/03/23 17:24:55 imp Exp $
0004  *
0005  * des_crypt.h, des library routine interface
0006  * Copyright (C) 1986, Sun Microsystems, Inc.
0007  */
0008 /*
0009  * Copyright (c) 2009, Sun Microsystems, Inc.
0010  * All rights reserved.
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions are met:
0014  * - Redistributions of source code must retain the above copyright notice,
0015  *   this list of conditions and the following disclaimer.
0016  * - Redistributions in binary form must reproduce the above copyright notice,
0017  *   this list of conditions and the following disclaimer in the documentation
0018  *   and/or other materials provided with the distribution.
0019  * - Neither the name of Sun Microsystems, Inc. nor the names of its
0020  *   contributors may be used to endorse or promote products derived
0021  *   from this software without specific prior written permission.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 /*
0036  * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
0037  */
0038 
0039 /*
0040  * des_crypt.h, des library routine interface
0041  */
0042 
0043 #ifndef _DES_DES_CRYPT_H
0044 #define _DES_DES_CRYPT_H
0045 
0046 #include <rpc/rpc.h>
0047 
0048 #define DES_MAXDATA 8192    /* max bytes encrypted in one call */
0049 #define DES_DIRMASK (1 << 0)
0050 #define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */
0051 #define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */
0052 
0053 
0054 #define DES_DEVMASK (1 << 1)
0055 #define DES_HW (0*DES_DEVMASK)  /* Use hardware device */ 
0056 #define DES_SW (1*DES_DEVMASK)  /* Use software device */
0057 
0058 
0059 #define DESERR_NONE 0   /* succeeded */
0060 #define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */
0061 #define DESERR_HWERROR 2    /* failed, hardware/driver error */
0062 #define DESERR_BADPARAM 3   /* failed, bad parameter to call */
0063 
0064 #define DES_FAILED(err) \
0065     ((err) > DESERR_NOHWDEVICE)
0066 
0067 /*
0068  * cbc_crypt()
0069  * ecb_crypt()
0070  *
0071  * Encrypt (or decrypt) len bytes of a buffer buf.
0072  * The length must be a multiple of eight.
0073  * The key should have odd parity in the low bit of each byte.
0074  * ivec is the input vector, and is updated to the new one (cbc only).
0075  * The mode is created by oring together the appropriate parameters.
0076  * DESERR_NOHWDEVICE is returned if DES_HW was specified but
0077  * there was no hardware to do it on (the data will still be
0078  * encrypted though, in software).
0079  */
0080 
0081 
0082 /*
0083  * Cipher Block Chaining mode
0084  */
0085 #ifdef __cplusplus
0086 extern "C" {
0087 #endif
0088 int cbc_crypt( char *, char *, unsigned int, unsigned int, char *);
0089 #ifdef __cplusplus
0090 }
0091 #endif
0092 
0093 /*
0094  * Electronic Code Book mode
0095  */
0096 #ifdef __cplusplus
0097 extern "C" {
0098 #endif
0099 int ecb_crypt( char *, char *, unsigned int, unsigned int );
0100 #ifdef __cplusplus
0101 }
0102 #endif
0103 
0104 /* 
0105  * Set des parity for a key.
0106  * DES parity is odd and in the low bit of each byte
0107  */
0108 #ifdef __cplusplus
0109 extern "C" {
0110 #endif
0111 void des_setparity( char *);
0112 #ifdef __cplusplus
0113 }
0114 #endif
0115 
0116 #endif  /* _DES_DES_CRYPT_H */