des_soft.c revision 136581
1238438Sdteske/*
2238438Sdteske * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
3238438Sdteske * unrestricted use provided that this legend is included on all tape
4238438Sdteske * media and as a part of the software program in whole or part.  Users
5238438Sdteske * may copy or modify Sun RPC without charge, but are not authorized
6238438Sdteske * to license or distribute it to anyone else except as part of a product or
7238438Sdteske * program developed by the user.
8238438Sdteske *
9238438Sdteske * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
10238438Sdteske * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
11238438Sdteske * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
12238438Sdteske *
13238438Sdteske * Sun RPC is provided with no support and without any obligation on the
14238438Sdteske * part of Sun Microsystems, Inc. to assist in its use, correction,
15238438Sdteske * modification or enhancement.
16238438Sdteske *
17238438Sdteske * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
18238438Sdteske * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
19238438Sdteske * OR ANY PART THEREOF.
20240797Sdteske *
21238438Sdteske * In no event will Sun Microsystems, Inc. be liable for any lost revenue
22238438Sdteske * or profits or other special, indirect and consequential damages, even if
23238438Sdteske * Sun has been advised of the possibility of such damages.
24238438Sdteske *
25238438Sdteske * Sun Microsystems, Inc.
26238438Sdteske * 2550 Garcia Avenue
27238438Sdteske * Mountain View, California  94043
28238438Sdteske */
29238438Sdteske
30238438Sdteske#if defined(LIBC_SCCS) && !defined(lint)
31240684Sdteskestatic char sccsid[] = "@(#)des_soft.c	2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI";
32240684Sdteske#endif
33240684Sdteske#include <sys/cdefs.h>
34238438Sdteske__FBSDID("$FreeBSD: head/lib/libc/rpc/des_soft.c 136581 2004-10-16 06:11:35Z obrien $");
35238438Sdteske
36238438Sdteske/*
37238438Sdteske * Table giving odd parity in the low bit for ASCII characters
38238438Sdteske */
39238438Sdteskestatic char partab[128] = {
40238438Sdteske	0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07,
41238438Sdteske	0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e,
42238438Sdteske	0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16,
43238438Sdteske	0x19, 0x19, 0x1a, 0x1a, 0x1c, 0x1c, 0x1f, 0x1f,
44238438Sdteske	0x20, 0x20, 0x23, 0x23, 0x25, 0x25, 0x26, 0x26,
45238438Sdteske	0x29, 0x29, 0x2a, 0x2a, 0x2c, 0x2c, 0x2f, 0x2f,
46238438Sdteske	0x31, 0x31, 0x32, 0x32, 0x34, 0x34, 0x37, 0x37,
47238438Sdteske	0x38, 0x38, 0x3b, 0x3b, 0x3d, 0x3d, 0x3e, 0x3e,
48238438Sdteske	0x40, 0x40, 0x43, 0x43, 0x45, 0x45, 0x46, 0x46,
49238438Sdteske	0x49, 0x49, 0x4a, 0x4a, 0x4c, 0x4c, 0x4f, 0x4f,
50238438Sdteske	0x51, 0x51, 0x52, 0x52, 0x54, 0x54, 0x57, 0x57,
51238438Sdteske	0x58, 0x58, 0x5b, 0x5b, 0x5d, 0x5d, 0x5e, 0x5e,
52238438Sdteske	0x61, 0x61, 0x62, 0x62, 0x64, 0x64, 0x67, 0x67,
53238438Sdteske	0x68, 0x68, 0x6b, 0x6b, 0x6d, 0x6d, 0x6e, 0x6e,
54238438Sdteske	0x70, 0x70, 0x73, 0x73, 0x75, 0x75, 0x76, 0x76,
55238438Sdteske	0x79, 0x79, 0x7a, 0x7a, 0x7c, 0x7c, 0x7f, 0x7f,
56238438Sdteske};
57238438Sdteske
58238438Sdteske/*
59238438Sdteske * Add odd parity to low bit of 8 byte key
60238438Sdteske */
61238438Sdteskevoid
62238438Sdteskedes_setparity(p)
63238438Sdteske	char *p;
64238438Sdteske{
65238438Sdteske	int i;
66238438Sdteske
67238438Sdteske	for (i = 0; i < 8; i++) {
68238438Sdteske		*p = partab[*p & 0x7f];
69238438Sdteske		p++;
70238438Sdteske	}
71238438Sdteske}
72238438Sdteske