hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sunrpc/rpc/des_crypt.h

Packit 6c4009
/*
Packit 6c4009
 * @(#)des_crypt.h	2.1 88/08/11 4.0 RPCSRC
Packit 6c4009
 *
Packit 6c4009
 * des_crypt.h, des library routine interface
Packit 6c4009
 * Copyright (c) 2010, Oracle America, Inc.
Packit 6c4009
 *
Packit 6c4009
 * Redistribution and use in source and binary forms, with or without
Packit 6c4009
 * modification, are permitted provided that the following conditions are
Packit 6c4009
 * met:
Packit 6c4009
 *
Packit 6c4009
 *     * Redistributions of source code must retain the above copyright
Packit 6c4009
 *       notice, this list of conditions and the following disclaimer.
Packit 6c4009
 *     * Redistributions in binary form must reproduce the above
Packit 6c4009
 *       copyright notice, this list of conditions and the following
Packit 6c4009
 *       disclaimer in the documentation and/or other materials
Packit 6c4009
 *       provided with the distribution.
Packit 6c4009
 *     * Neither the name of the "Oracle America, Inc." nor the names of its
Packit 6c4009
 *       contributors may be used to endorse or promote products derived
Packit 6c4009
 *       from this software without specific prior written permission.
Packit 6c4009
 *
Packit 6c4009
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 6c4009
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 6c4009
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
Packit 6c4009
 *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
Packit 6c4009
 *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
Packit 6c4009
 *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 6c4009
 *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
Packit 6c4009
 *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit 6c4009
 *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
Packit 6c4009
 *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Packit 6c4009
 *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 6c4009
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#ifndef __DES_CRYPT_H__
Packit 6c4009
#define __DES_CRYPT_H__ 1
Packit 6c4009
Packit 6c4009
#include <features.h>
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
#define DES_MAXDATA 8192	/* max bytes encrypted in one call */
Packit 6c4009
#define DES_DIRMASK (1 << 0)
Packit 6c4009
#define DES_ENCRYPT (0*DES_DIRMASK)	/* Encrypt */
Packit 6c4009
#define DES_DECRYPT (1*DES_DIRMASK)	/* Decrypt */
Packit 6c4009
Packit 6c4009
Packit 6c4009
#define DES_DEVMASK (1 << 1)
Packit 6c4009
#define	DES_HW (0*DES_DEVMASK)	/* Use hardware device */
Packit 6c4009
#define DES_SW (1*DES_DEVMASK)	/* Use software device */
Packit 6c4009
Packit 6c4009
Packit 6c4009
#define DESERR_NONE 0	/* succeeded */
Packit 6c4009
#define DESERR_NOHWDEVICE 1	/* succeeded, but hw device not available */
Packit 6c4009
#define DESERR_HWERROR 2	/* failed, hardware/driver error */
Packit 6c4009
#define DESERR_BADPARAM 3	/* failed, bad parameter to call */
Packit 6c4009
Packit 6c4009
#define DES_FAILED(err) \
Packit 6c4009
	((err) > DESERR_NOHWDEVICE)
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * cbc_crypt()
Packit 6c4009
 * ecb_crypt()
Packit 6c4009
 *
Packit 6c4009
 * Encrypt (or decrypt) len bytes of a buffer buf.
Packit 6c4009
 * The length must be a multiple of eight.
Packit 6c4009
 * The key should have odd parity in the low bit of each byte.
Packit 6c4009
 * ivec is the input vector, and is updated to the new one (cbc only).
Packit 6c4009
 * The mode is created by oring together the appropriate parameters.
Packit 6c4009
 * DESERR_NOHWDEVICE is returned if DES_HW was specified but
Packit 6c4009
 * there was no hardware to do it on (the data will still be
Packit 6c4009
 * encrypted though, in software).
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Cipher Block Chaining mode
Packit 6c4009
 */
Packit 6c4009
extern int cbc_crypt (char *__key, char *__buf, unsigned __len,
Packit 6c4009
		      unsigned __mode, char *__ivec) __THROW;
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Electronic Code Book mode
Packit 6c4009
 */
Packit 6c4009
extern int ecb_crypt (char *__key, char *__buf, unsigned __len,
Packit 6c4009
		      unsigned __mode) __THROW;
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Set des parity for a key.
Packit 6c4009
 * DES parity is odd and in the low bit of each byte
Packit 6c4009
 */
Packit 6c4009
extern void des_setparity (char *__key) __THROW;
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif