126209Swpaul/* 226209Swpaul * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI 355206Speter * $FreeBSD$ 426209Swpaul * 526209Swpaul * des_crypt.h, des library routine interface 626209Swpaul * Copyright (C) 1986, Sun Microsystems, Inc. 726209Swpaul */ 8261046Smav/*- 9261046Smav * Copyright (c) 2009, Sun Microsystems, Inc. 10261046Smav * All rights reserved. 11261046Smav * 12261046Smav * Redistribution and use in source and binary forms, with or without 13261046Smav * modification, are permitted provided that the following conditions are met: 14261046Smav * - Redistributions of source code must retain the above copyright notice, 15261046Smav * this list of conditions and the following disclaimer. 16261046Smav * - Redistributions in binary form must reproduce the above copyright notice, 17261046Smav * this list of conditions and the following disclaimer in the documentation 18261046Smav * and/or other materials provided with the distribution. 19261046Smav * - Neither the name of Sun Microsystems, Inc. nor the names of its 20261046Smav * contributors may be used to endorse or promote products derived 21261046Smav * from this software without specific prior written permission. 22261046Smav * 23261046Smav * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24261046Smav * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25261046Smav * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26261046Smav * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 27261046Smav * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28261046Smav * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29261046Smav * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30261046Smav * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31261046Smav * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32261046Smav * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33261046Smav * POSSIBILITY OF SUCH DAMAGE. 3426209Swpaul */ 3574462Salfred/* 3674462Salfred * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. 3774462Salfred */ 3826209Swpaul 3974462Salfred/* 4074462Salfred * des_crypt.h, des library routine interface 4174462Salfred */ 4274462Salfred 4374462Salfred#ifndef _DES_DES_CRYPT_H 4474462Salfred#define _DES_DES_CRYPT_H 4574462Salfred 4626209Swpaul#include <sys/cdefs.h> 4726209Swpaul#include <rpc/rpc.h> 4826209Swpaul 4926209Swpaul#define DES_MAXDATA 8192 /* max bytes encrypted in one call */ 5026209Swpaul#define DES_DIRMASK (1 << 0) 5126209Swpaul#define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */ 5226209Swpaul#define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */ 5326209Swpaul 5426209Swpaul 5526209Swpaul#define DES_DEVMASK (1 << 1) 5626209Swpaul#define DES_HW (0*DES_DEVMASK) /* Use hardware device */ 5726209Swpaul#define DES_SW (1*DES_DEVMASK) /* Use software device */ 5826209Swpaul 5926209Swpaul 6026209Swpaul#define DESERR_NONE 0 /* succeeded */ 6126209Swpaul#define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */ 6226209Swpaul#define DESERR_HWERROR 2 /* failed, hardware/driver error */ 6326209Swpaul#define DESERR_BADPARAM 3 /* failed, bad parameter to call */ 6426209Swpaul 6526209Swpaul#define DES_FAILED(err) \ 6626209Swpaul ((err) > DESERR_NOHWDEVICE) 6726209Swpaul 6826209Swpaul/* 6926209Swpaul * cbc_crypt() 7026209Swpaul * ecb_crypt() 7126209Swpaul * 7226209Swpaul * Encrypt (or decrypt) len bytes of a buffer buf. 7326209Swpaul * The length must be a multiple of eight. 7426209Swpaul * The key should have odd parity in the low bit of each byte. 7526209Swpaul * ivec is the input vector, and is updated to the new one (cbc only). 7626209Swpaul * The mode is created by oring together the appropriate parameters. 7726209Swpaul * DESERR_NOHWDEVICE is returned if DES_HW was specified but 7826209Swpaul * there was no hardware to do it on (the data will still be 7926209Swpaul * encrypted though, in software). 8026209Swpaul */ 8126209Swpaul 8226209Swpaul 8326209Swpaul/* 8426209Swpaul * Cipher Block Chaining mode 8526209Swpaul */ 8626209Swpaul__BEGIN_DECLS 8793032Simpint cbc_crypt( char *, char *, unsigned int, unsigned int, char *); 8874462Salfred__END_DECLS 8926209Swpaul 9026209Swpaul/* 9126209Swpaul * Electronic Code Book mode 9226209Swpaul */ 9374462Salfred__BEGIN_DECLS 9493032Simpint ecb_crypt( char *, char *, unsigned int, unsigned int ); 9526209Swpaul__END_DECLS 9626209Swpaul 9726209Swpaul/* 9826209Swpaul * Set des parity for a key. 9926209Swpaul * DES parity is odd and in the low bit of each byte 10026209Swpaul */ 10126209Swpaul__BEGIN_DECLS 10293032Simpvoid des_setparity( char *); 10326209Swpaul__END_DECLS 10474462Salfred 10574462Salfred#endif /* _DES_DES_CRYPT_H */ 106