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>
36 getbits (long data, unsigned char *dst)
38 dst[0] = (data ) & 0xff;
39 dst[1] = (data >> 8) & 0xff;
40 dst[2] = (data >> 16) & 0xff;
41 dst[3] = (data >> 24) & 0xff;
48 #if defined(HAVE_LRAND48) && defined(HAVE_SRAND48)
49 #define srandom srand48
50 #define random lrand48
56 #define getpid(x) _getpid(x)
60 XdmcpGenerateKey (XdmAuthKeyPtr key)
62 long lowbits, highbits;
64 srandom ((int)getpid() ^ time((Time_t *)0));
67 getbits (lowbits, key->data);
68 getbits (highbits, key->data + 4);
72 XdmcpCompareKeys (const XdmAuthKeyPtr a, const XdmAuthKeyPtr b)
76 for (i = 0; i < 8; i++)
77 if (a->data[i] != b->data[i])
83 XdmcpIncrementKey (XdmAuthKeyPtr key)
88 while (++key->data[i] == 0)
94 XdmcpDecrementKey (XdmAuthKeyPtr key)
99 while (key->data[i]-- == 0)