1261046Smav/*- 2261046Smav * Copyright (c) 2009, Sun Microsystems, Inc. 3261046Smav * All rights reserved. 4261046Smav * 5261046Smav * Redistribution and use in source and binary forms, with or without 6261046Smav * modification, are permitted provided that the following conditions are met: 7261046Smav * - Redistributions of source code must retain the above copyright notice, 8261046Smav * this list of conditions and the following disclaimer. 9261046Smav * - Redistributions in binary form must reproduce the above copyright notice, 10261046Smav * this list of conditions and the following disclaimer in the documentation 11261046Smav * and/or other materials provided with the distribution. 12261046Smav * - Neither the name of Sun Microsystems, Inc. nor the names of its 13261046Smav * contributors may be used to endorse or promote products derived 14261046Smav * from this software without specific prior written permission. 1526219Swpaul * 16261046Smav * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17261046Smav * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18261046Smav * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19261046Smav * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20261046Smav * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21261046Smav * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22261046Smav * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23261046Smav * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24261046Smav * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25261046Smav * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26261046Smav * POSSIBILITY OF SUCH DAMAGE. 2726219Swpaul */ 28136581Sobrien 29136581Sobrien#if defined(LIBC_SCCS) && !defined(lint) 30136581Sobrienstatic char sccsid[] = "@(#)des_soft.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI"; 31136581Sobrien#endif 32136581Sobrien#include <sys/cdefs.h> 33136581Sobrien__FBSDID("$FreeBSD$"); 34136581Sobrien 3526219Swpaul/* 3626219Swpaul * Table giving odd parity in the low bit for ASCII characters 3726219Swpaul */ 3826219Swpaulstatic char partab[128] = { 3926219Swpaul 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07, 4026219Swpaul 0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e, 4126219Swpaul 0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16, 4226219Swpaul 0x19, 0x19, 0x1a, 0x1a, 0x1c, 0x1c, 0x1f, 0x1f, 4326219Swpaul 0x20, 0x20, 0x23, 0x23, 0x25, 0x25, 0x26, 0x26, 4426219Swpaul 0x29, 0x29, 0x2a, 0x2a, 0x2c, 0x2c, 0x2f, 0x2f, 4526219Swpaul 0x31, 0x31, 0x32, 0x32, 0x34, 0x34, 0x37, 0x37, 4626219Swpaul 0x38, 0x38, 0x3b, 0x3b, 0x3d, 0x3d, 0x3e, 0x3e, 4726219Swpaul 0x40, 0x40, 0x43, 0x43, 0x45, 0x45, 0x46, 0x46, 4826219Swpaul 0x49, 0x49, 0x4a, 0x4a, 0x4c, 0x4c, 0x4f, 0x4f, 4926219Swpaul 0x51, 0x51, 0x52, 0x52, 0x54, 0x54, 0x57, 0x57, 5026219Swpaul 0x58, 0x58, 0x5b, 0x5b, 0x5d, 0x5d, 0x5e, 0x5e, 5126219Swpaul 0x61, 0x61, 0x62, 0x62, 0x64, 0x64, 0x67, 0x67, 5226219Swpaul 0x68, 0x68, 0x6b, 0x6b, 0x6d, 0x6d, 0x6e, 0x6e, 5326219Swpaul 0x70, 0x70, 0x73, 0x73, 0x75, 0x75, 0x76, 0x76, 5426219Swpaul 0x79, 0x79, 0x7a, 0x7a, 0x7c, 0x7c, 0x7f, 0x7f, 5526219Swpaul}; 5626219Swpaul 5726219Swpaul/* 5826219Swpaul * Add odd parity to low bit of 8 byte key 5926219Swpaul */ 6026219Swpaulvoid 6126219Swpauldes_setparity(p) 6226219Swpaul char *p; 6326219Swpaul{ 6426219Swpaul int i; 6526219Swpaul 6626219Swpaul for (i = 0; i < 8; i++) { 6726219Swpaul *p = partab[*p & 0x7f]; 6826219Swpaul p++; 6926219Swpaul } 7026219Swpaul} 71