172132Ssemenu/*-
272132Ssemenu * Copyright (c) 2009, Sun Microsystems, Inc.
372132Ssemenu * All rights reserved.
472132Ssemenu *
572132Ssemenu * Redistribution and use in source and binary forms, with or without
672132Ssemenu * modification, are permitted provided that the following conditions are met:
772132Ssemenu * - Redistributions of source code must retain the above copyright notice,
872132Ssemenu *   this list of conditions and the following disclaimer.
972132Ssemenu * - Redistributions in binary form must reproduce the above copyright notice,
1072132Ssemenu *   this list of conditions and the following disclaimer in the documentation
1172132Ssemenu *   and/or other materials provided with the distribution.
1272132Ssemenu * - Neither the name of Sun Microsystems, Inc. nor the names of its
1372132Ssemenu *   contributors may be used to endorse or promote products derived
1472132Ssemenu *   from this software without specific prior written permission.
1572132Ssemenu *
1672132Ssemenu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1772132Ssemenu * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1872132Ssemenu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1972132Ssemenu * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
2072132Ssemenu * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2172132Ssemenu * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2272132Ssemenu * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2372132Ssemenu * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2472132Ssemenu * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2572132Ssemenu * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2672132Ssemenu * POSSIBILITY OF SUCH DAMAGE.
2772132Ssemenu */
2872132Ssemenu
2972132Ssemenu#if defined(LIBC_SCCS) && !defined(lint)
3072132Ssemenustatic char sccsid[] = "@(#)des_soft.c	2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI";
3172132Ssemenu#endif
3272132Ssemenu#include <sys/cdefs.h>
3372132Ssemenu__FBSDID("$FreeBSD$");
34139749Simp
3572132Ssemenu/*
3672132Ssemenu * Table giving odd parity in the low bit for ASCII characters
3772132Ssemenu */
3872132Ssemenustatic char partab[128] = {
3972132Ssemenu	0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07,
4072132Ssemenu	0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e,
4172132Ssemenu	0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16,
4272132Ssemenu	0x19, 0x19, 0x1a, 0x1a, 0x1c, 0x1c, 0x1f, 0x1f,
4372132Ssemenu	0x20, 0x20, 0x23, 0x23, 0x25, 0x25, 0x26, 0x26,
4472132Ssemenu	0x29, 0x29, 0x2a, 0x2a, 0x2c, 0x2c, 0x2f, 0x2f,
4572132Ssemenu	0x31, 0x31, 0x32, 0x32, 0x34, 0x34, 0x37, 0x37,
4672132Ssemenu	0x38, 0x38, 0x3b, 0x3b, 0x3d, 0x3d, 0x3e, 0x3e,
4772132Ssemenu	0x40, 0x40, 0x43, 0x43, 0x45, 0x45, 0x46, 0x46,
4872132Ssemenu	0x49, 0x49, 0x4a, 0x4a, 0x4c, 0x4c, 0x4f, 0x4f,
4972132Ssemenu	0x51, 0x51, 0x52, 0x52, 0x54, 0x54, 0x57, 0x57,
5072132Ssemenu	0x58, 0x58, 0x5b, 0x5b, 0x5d, 0x5d, 0x5e, 0x5e,
5172132Ssemenu	0x61, 0x61, 0x62, 0x62, 0x64, 0x64, 0x67, 0x67,
5272132Ssemenu	0x68, 0x68, 0x6b, 0x6b, 0x6d, 0x6d, 0x6e, 0x6e,
5372132Ssemenu	0x70, 0x70, 0x73, 0x73, 0x75, 0x75, 0x76, 0x76,
5472132Ssemenu	0x79, 0x79, 0x7a, 0x7a, 0x7c, 0x7c, 0x7f, 0x7f,
5572132Ssemenu};
5672132Ssemenu
5772132Ssemenu/*
58129844Smarius * Add odd parity to low bit of 8 byte key
59129844Smarius */
60129844Smariusvoid
6172132Ssemenudes_setparity(p)
6272132Ssemenu	char *p;
6372132Ssemenu{
6472132Ssemenu	int i;
6572132Ssemenu
6672132Ssemenu	for (i = 0; i < 8; i++) {
6772132Ssemenu		*p = partab[*p & 0x7f];
6872132Ssemenu		p++;
6972132Ssemenu	}
7072132Ssemenu}
7172132Ssemenu