|
rpm-build |
34167a |
/*
|
|
rpm-build |
34167a |
Copyright 1989, 1998 The Open Group
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
Permission to use, copy, modify, distribute, and sell this software and its
|
|
rpm-build |
34167a |
documentation for any purpose is hereby granted without fee, provided that
|
|
rpm-build |
34167a |
the above copyright notice appear in all copies and that both that
|
|
rpm-build |
34167a |
copyright notice and this permission notice appear in supporting
|
|
rpm-build |
34167a |
documentation.
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
The above copyright notice and this permission notice shall be included in
|
|
rpm-build |
34167a |
all copies or substantial portions of the Software.
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
rpm-build |
34167a |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
rpm-build |
34167a |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
rpm-build |
34167a |
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
rpm-build |
34167a |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
rpm-build |
34167a |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
Except as contained in this notice, the name of The Open Group shall not be
|
|
rpm-build |
34167a |
used in advertising or otherwise to promote the sale, use or other dealings
|
|
rpm-build |
34167a |
in this Software without prior written authorization from The Open Group.
|
|
rpm-build |
34167a |
* *
|
|
rpm-build |
34167a |
* Author: Keith Packard, MIT X Consortium
|
|
rpm-build |
34167a |
*/
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
#ifdef HAVE_CONFIG_H
|
|
rpm-build |
34167a |
#include <config.h>
|
|
rpm-build |
34167a |
#endif
|
|
rpm-build |
34167a |
#include <X11/Xos.h>
|
|
rpm-build |
34167a |
#include <X11/X.h>
|
|
rpm-build |
34167a |
#include <X11/Xmd.h>
|
|
rpm-build |
34167a |
#include <X11/Xdmcp.h>
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
#ifdef HASXDMAUTH
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
/*
|
|
rpm-build |
34167a |
* The following function exists only to demonstrate the
|
|
rpm-build |
34167a |
* desired functional interface for this routine. You will
|
|
rpm-build |
34167a |
* need to add the appropriate algorithm if you wish to
|
|
rpm-build |
34167a |
* use XDM-AUTHENTICATION-1/XDM-AUTHORIZATION-1.
|
|
rpm-build |
34167a |
*
|
|
rpm-build |
34167a |
* The interface for this routine is quite simple. All three
|
|
rpm-build |
34167a |
* arguments are arrays of 8 unsigned characters, the first two
|
|
rpm-build |
34167a |
* are 64 bits of useful data, the last is 56 bits of useful
|
|
rpm-build |
34167a |
* data packed into 8 bytes, using the low 7 bits of each
|
|
rpm-build |
34167a |
* byte, filling the high bit with odd parity.
|
|
rpm-build |
34167a |
*
|
|
rpm-build |
34167a |
* Examine the XDMCP specification for the correct algorithm
|
|
rpm-build |
34167a |
*/
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
#include "Wrap.h"
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
void
|
|
rpm-build |
34167a |
XdmcpUnwrap (
|
|
rpm-build |
34167a |
unsigned char *input,
|
|
rpm-build |
34167a |
unsigned char *wrapper,
|
|
rpm-build |
34167a |
unsigned char *output,
|
|
rpm-build |
34167a |
int bytes)
|
|
rpm-build |
34167a |
{
|
|
rpm-build |
34167a |
int i, j, k;
|
|
rpm-build |
34167a |
unsigned char tmp[8];
|
|
rpm-build |
34167a |
unsigned char blocks[2][8];
|
|
rpm-build |
34167a |
unsigned char expand_wrapper[8];
|
|
rpm-build |
34167a |
auth_wrapper_schedule schedule;
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
_XdmcpWrapperToOddParity (wrapper, expand_wrapper);
|
|
rpm-build |
34167a |
_XdmcpAuthSetup (expand_wrapper, schedule);
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
k = 0;
|
|
rpm-build |
34167a |
for (j = 0; j < bytes; j += 8)
|
|
rpm-build |
34167a |
{
|
|
rpm-build |
34167a |
if (bytes - j < 8)
|
|
rpm-build |
34167a |
return; /* bad input length */
|
|
rpm-build |
34167a |
for (i = 0; i < 8; i++)
|
|
rpm-build |
34167a |
blocks[k][i] = input[j + i];
|
|
rpm-build |
34167a |
_XdmcpAuthDoIt ((unsigned char *) (input + j), (unsigned char *) tmp, schedule, 0);
|
|
rpm-build |
34167a |
/* block chaining */
|
|
rpm-build |
34167a |
k = (k == 0) ? 1 : 0;
|
|
rpm-build |
34167a |
for (i = 0; i < 8; i++)
|
|
rpm-build |
34167a |
{
|
|
rpm-build |
34167a |
if (j == 0)
|
|
rpm-build |
34167a |
output[j + i] = tmp[i];
|
|
rpm-build |
34167a |
else
|
|
rpm-build |
34167a |
output[j + i] = tmp[i] ^ blocks[k][i];
|
|
rpm-build |
34167a |
}
|
|
rpm-build |
34167a |
}
|
|
rpm-build |
34167a |
}
|
|
rpm-build |
34167a |
|
|
rpm-build |
34167a |
#endif /* HASXDMAUTH */
|