master
  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 * SPDX-License-Identifier: BSD-3-Clause
  9 *
 10 * Copyright (c) 2009, Sun Microsystems, Inc.
 11 * All rights reserved.
 12 *
 13 * Redistribution and use in source and binary forms, with or without
 14 * modification, are permitted provided that the following conditions are met:
 15 * - Redistributions of source code must retain the above copyright notice,
 16 *   this list of conditions and the following disclaimer.
 17 * - Redistributions in binary form must reproduce the above copyright notice,
 18 *   this list of conditions and the following disclaimer in the documentation
 19 *   and/or other materials provided with the distribution.
 20 * - Neither the name of Sun Microsystems, Inc. nor the names of its
 21 *   contributors may be used to endorse or promote products derived
 22 *   from this software without specific prior written permission.
 23 *
 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 34 * POSSIBILITY OF SUCH DAMAGE.
 35 */
 36/*
 37 * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc.
 38 */
 39
 40/*
 41 * des_crypt.h, des library routine interface
 42 */
 43
 44#ifndef _DES_DES_CRYPT_H
 45#define _DES_DES_CRYPT_H
 46
 47#include <sys/cdefs.h>
 48#include <rpc/rpc.h>
 49
 50#define DES_MAXDATA 8192	/* max bytes encrypted in one call */
 51#define DES_DIRMASK (1 << 0)
 52#define DES_ENCRYPT (0*DES_DIRMASK)	/* Encrypt */
 53#define DES_DECRYPT (1*DES_DIRMASK)	/* Decrypt */
 54
 55
 56#define DES_DEVMASK (1 << 1)
 57#define	DES_HW (0*DES_DEVMASK)	/* Use hardware device */ 
 58#define DES_SW (1*DES_DEVMASK)	/* Use software device */
 59
 60
 61#define DESERR_NONE 0	/* succeeded */
 62#define DESERR_NOHWDEVICE 1	/* succeeded, but hw device not available */
 63#define DESERR_HWERROR 2	/* failed, hardware/driver error */
 64#define DESERR_BADPARAM 3	/* failed, bad parameter to call */
 65
 66#define DES_FAILED(err) \
 67	((err) > DESERR_NOHWDEVICE)
 68
 69/*
 70 * cbc_crypt()
 71 * ecb_crypt()
 72 *
 73 * Encrypt (or decrypt) len bytes of a buffer buf.
 74 * The length must be a multiple of eight.
 75 * The key should have odd parity in the low bit of each byte.
 76 * ivec is the input vector, and is updated to the new one (cbc only).
 77 * The mode is created by oring together the appropriate parameters.
 78 * DESERR_NOHWDEVICE is returned if DES_HW was specified but
 79 * there was no hardware to do it on (the data will still be
 80 * encrypted though, in software).
 81 */
 82
 83
 84/*
 85 * Cipher Block Chaining mode
 86 */
 87__BEGIN_DECLS
 88int cbc_crypt( char *, char *, unsigned int, unsigned int, char *);
 89__END_DECLS
 90
 91/*
 92 * Electronic Code Book mode
 93 */
 94__BEGIN_DECLS
 95int ecb_crypt( char *, char *, unsigned int, unsigned int );
 96__END_DECLS
 97
 98/* 
 99 * Set des parity for a key.
100 * DES parity is odd and in the low bit of each byte
101 */
102__BEGIN_DECLS
103void des_setparity( char *);
104__END_DECLS
105
106#endif  /* _DES_DES_CRYPT_H */