]>
Commit | Line | Data |
---|---|---|
800d775e UD |
1 | #if !defined(lint) && defined(SCCSIDS) |
2 | static char sccsid[] = "@(#)des_soft.c 2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI"; | |
3 | #endif | |
4 | /* | |
a7ab6ec8 UD |
5 | * Copyright (c) 2010, Oracle America, Inc. |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are | |
8 | * met: | |
c4563d2d | 9 | * |
a7ab6ec8 UD |
10 | * * Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | |
12 | * * Redistributions in binary form must reproduce the above | |
13 | * copyright notice, this list of conditions and the following | |
14 | * disclaimer in the documentation and/or other materials | |
15 | * provided with the distribution. | |
16 | * * Neither the name of the "Oracle America, Inc." nor the names of its | |
17 | * contributors may be used to endorse or promote products derived | |
18 | * from this software without specific prior written permission. | |
c4563d2d | 19 | * |
a7ab6ec8 UD |
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
24 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
25 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | |
27 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
800d775e | 32 | */ |
ed073f0e AJ |
33 | |
34 | #include <rpc/des_crypt.h> | |
7b57bfe5 | 35 | #include <abi-versions.h> |
800d775e UD |
36 | /* |
37 | * Table giving odd parity in the low bit for ASCII characters | |
38 | */ | |
c4563d2d | 39 | static const char partab[128] = |
800d775e UD |
40 | { |
41 | 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07, | |
42 | 0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e, | |
43 | 0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16, | |
44 | 0x19, 0x19, 0x1a, 0x1a, 0x1c, 0x1c, 0x1f, 0x1f, | |
45 | 0x20, 0x20, 0x23, 0x23, 0x25, 0x25, 0x26, 0x26, | |
46 | 0x29, 0x29, 0x2a, 0x2a, 0x2c, 0x2c, 0x2f, 0x2f, | |
47 | 0x31, 0x31, 0x32, 0x32, 0x34, 0x34, 0x37, 0x37, | |
48 | 0x38, 0x38, 0x3b, 0x3b, 0x3d, 0x3d, 0x3e, 0x3e, | |
49 | 0x40, 0x40, 0x43, 0x43, 0x45, 0x45, 0x46, 0x46, | |
50 | 0x49, 0x49, 0x4a, 0x4a, 0x4c, 0x4c, 0x4f, 0x4f, | |
51 | 0x51, 0x51, 0x52, 0x52, 0x54, 0x54, 0x57, 0x57, | |
52 | 0x58, 0x58, 0x5b, 0x5b, 0x5d, 0x5d, 0x5e, 0x5e, | |
53 | 0x61, 0x61, 0x62, 0x62, 0x64, 0x64, 0x67, 0x67, | |
54 | 0x68, 0x68, 0x6b, 0x6b, 0x6d, 0x6d, 0x6e, 0x6e, | |
55 | 0x70, 0x70, 0x73, 0x73, 0x75, 0x75, 0x76, 0x76, | |
56 | 0x79, 0x79, 0x7a, 0x7a, 0x7c, 0x7c, 0x7f, 0x7f, | |
57 | }; | |
58 | ||
59 | /* | |
60 | * Add odd parity to low bit of 8 byte key | |
61 | */ | |
62 | void | |
63 | des_setparity (char *p) | |
64 | { | |
65 | int i; | |
66 | ||
67 | for (i = 0; i < 8; i++) | |
68 | { | |
69 | *p = partab[*p & 0x7f]; | |
70 | p++; | |
71 | } | |
72 | } | |
021db4be | 73 | libc_hidden_nolink_sunrpc (des_setparity, GLIBC_2_1) |