xref: /freebsd/lib/libc/rpc/des_soft.c (revision e8636dfd57b1bc6a19328606214e847c0d9eb1aa)
1e8636dfdSBill Paul #if !defined(lint) && defined(SCCSIDS)
2e8636dfdSBill Paul static char sccsid[] = "@(#)des_soft.c	2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI";
3e8636dfdSBill Paul #endif
4e8636dfdSBill Paul /*
5e8636dfdSBill Paul  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
6e8636dfdSBill Paul  * unrestricted use provided that this legend is included on all tape
7e8636dfdSBill Paul  * media and as a part of the software program in whole or part.  Users
8e8636dfdSBill Paul  * may copy or modify Sun RPC without charge, but are not authorized
9e8636dfdSBill Paul  * to license or distribute it to anyone else except as part of a product or
10e8636dfdSBill Paul  * program developed by the user.
11e8636dfdSBill Paul  *
12e8636dfdSBill Paul  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
13e8636dfdSBill Paul  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
14e8636dfdSBill Paul  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
15e8636dfdSBill Paul  *
16e8636dfdSBill Paul  * Sun RPC is provided with no support and without any obligation on the
17e8636dfdSBill Paul  * part of Sun Microsystems, Inc. to assist in its use, correction,
18e8636dfdSBill Paul  * modification or enhancement.
19e8636dfdSBill Paul  *
20e8636dfdSBill Paul  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
21e8636dfdSBill Paul  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
22e8636dfdSBill Paul  * OR ANY PART THEREOF.
23e8636dfdSBill Paul  *
24e8636dfdSBill Paul  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
25e8636dfdSBill Paul  * or profits or other special, indirect and consequential damages, even if
26e8636dfdSBill Paul  * Sun has been advised of the possibility of such damages.
27e8636dfdSBill Paul  *
28e8636dfdSBill Paul  * Sun Microsystems, Inc.
29e8636dfdSBill Paul  * 2550 Garcia Avenue
30e8636dfdSBill Paul  * Mountain View, California  94043
31e8636dfdSBill Paul  */
32e8636dfdSBill Paul /*
33e8636dfdSBill Paul  * Table giving odd parity in the low bit for ASCII characters
34e8636dfdSBill Paul  */
35e8636dfdSBill Paul static char partab[128] = {
36e8636dfdSBill Paul 	0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07,
37e8636dfdSBill Paul 	0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e,
38e8636dfdSBill Paul 	0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16,
39e8636dfdSBill Paul 	0x19, 0x19, 0x1a, 0x1a, 0x1c, 0x1c, 0x1f, 0x1f,
40e8636dfdSBill Paul 	0x20, 0x20, 0x23, 0x23, 0x25, 0x25, 0x26, 0x26,
41e8636dfdSBill Paul 	0x29, 0x29, 0x2a, 0x2a, 0x2c, 0x2c, 0x2f, 0x2f,
42e8636dfdSBill Paul 	0x31, 0x31, 0x32, 0x32, 0x34, 0x34, 0x37, 0x37,
43e8636dfdSBill Paul 	0x38, 0x38, 0x3b, 0x3b, 0x3d, 0x3d, 0x3e, 0x3e,
44e8636dfdSBill Paul 	0x40, 0x40, 0x43, 0x43, 0x45, 0x45, 0x46, 0x46,
45e8636dfdSBill Paul 	0x49, 0x49, 0x4a, 0x4a, 0x4c, 0x4c, 0x4f, 0x4f,
46e8636dfdSBill Paul 	0x51, 0x51, 0x52, 0x52, 0x54, 0x54, 0x57, 0x57,
47e8636dfdSBill Paul 	0x58, 0x58, 0x5b, 0x5b, 0x5d, 0x5d, 0x5e, 0x5e,
48e8636dfdSBill Paul 	0x61, 0x61, 0x62, 0x62, 0x64, 0x64, 0x67, 0x67,
49e8636dfdSBill Paul 	0x68, 0x68, 0x6b, 0x6b, 0x6d, 0x6d, 0x6e, 0x6e,
50e8636dfdSBill Paul 	0x70, 0x70, 0x73, 0x73, 0x75, 0x75, 0x76, 0x76,
51e8636dfdSBill Paul 	0x79, 0x79, 0x7a, 0x7a, 0x7c, 0x7c, 0x7f, 0x7f,
52e8636dfdSBill Paul };
53e8636dfdSBill Paul 
54e8636dfdSBill Paul /*
55e8636dfdSBill Paul  * Add odd parity to low bit of 8 byte key
56e8636dfdSBill Paul  */
57e8636dfdSBill Paul void
58e8636dfdSBill Paul des_setparity(p)
59e8636dfdSBill Paul 	char *p;
60e8636dfdSBill Paul {
61e8636dfdSBill Paul 	int i;
62e8636dfdSBill Paul 
63e8636dfdSBill Paul 	for (i = 0; i < 8; i++) {
64e8636dfdSBill Paul 		*p = partab[*p & 0x7f];
65e8636dfdSBill Paul 		p++;
66e8636dfdSBill Paul 	}
67e8636dfdSBill Paul }
68