2 Copyright 1989, 1998 The Open Group
4 Permission to use, copy, modify, distribute, and sell this software and its
5 documentation for any purpose is hereby granted without fee, provided that
6 the above copyright notice appear in all copies and that both that
7 copyright notice and this permission notice appear in supporting
10 The above copyright notice and this permission notice shall be included in
11 all copies or substantial portions of the Software.
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 Except as contained in this notice, the name of The Open Group shall not be
21 used in advertising or otherwise to promote the sale, use or other dealings
22 in this Software without prior written authorization from The Open Group.
24 * Author: Keith Packard, MIT X Consortium
33 #include <X11/Xdmcp.h>
38 * The following function exists only to demonstrate the
39 * desired functional interface for this routine. You will
40 * need to add the appropriate algorithm if you wish to
41 * use XDM-AUTHENTICATION-1/XDM-AUTHORIZATION-1.
43 * Examine the XDMCP specification for the correct algorithm
51 unsigned char *wrapper,
52 unsigned char *output,
58 unsigned char expand_wrapper[8];
59 auth_wrapper_schedule schedule;
61 _XdmcpWrapperToOddParity (wrapper, expand_wrapper);
62 _XdmcpAuthSetup (expand_wrapper, schedule);
63 for (j = 0; j < bytes; j += 8)
69 for (i = 0; i < len; i++)
74 tmp[i] = input[j + i] ^ output[j - 8 + i];
81 tmp[i] = 0 ^ output[j - 8 + i];
83 _XdmcpAuthDoIt (tmp, (output + j), schedule, 1);
88 * Given a 56 bit wrapper in XDMCP format, create a 56
89 * bit wrapper in 7-bits + odd parity format
93 OddParity (unsigned char c)
102 * Spread the 56 bit wrapper among 8 bytes, using the upper 7 bits
103 * of each byte, and storing an odd parity bit in the low bit
107 _XdmcpWrapperToOddParity (
117 for (i = 0; i < 7; i++)
119 c = ((in[i] << ashift) | (in[i+1] >> bshift)) & 0x7f;
120 out[i] = (c << 1) | OddParity (c);
125 out[i] = (c << 1) | OddParity(c);