-#ifdef HAS_AUTH_XA1
-
-static int next_nonce(void)
-{
- static int nonce = 0;
- static pthread_mutex_t nonce_mutex = PTHREAD_MUTEX_INITIALIZER;
- int ret;
- pthread_mutex_lock(&nonce_mutex);
- ret = nonce++;
- pthread_mutex_unlock(&nonce_mutex);
- return ret;
-}
-
-/*
- * This code and the code it calls is taken from libXdmcp,
- * specifically from Wrap.c, Wrap.h, and Wraphelp.c. The US
- * has changed, thank goodness, and it should be OK to bury
- * DES code in an open source product without a maze of
- * twisty wrapper functions stored offshore. Or maybe
- * not. --Bart Massey 2003/11/5
- */
-
-static void
-Wrap (
- des_cblock input,
- des_cblock key,
- des_cblock output,
- int bytes)
-{
- int i, j;
- int len;
- des_cblock tmp;
- des_cblock expand_key;
- des_key_schedule schedule;
-
- XCBDESKeyToOddParity (key, expand_key);
- XCBDESKeySchedule (expand_key, schedule);
- for (j = 0; j < bytes; j += 8)
- {
- len = 8;
- if (bytes - j < len)
- len = bytes - j;
- /* block chaining */
- for (i = 0; i < len; i++)
- {
- if (j == 0)
- tmp[i] = input[i];
- else
- tmp[i] = input[j + i] ^ output[j - 8 + i];
- }
- for (; i < 8; i++)
- {
- if (j == 0)
- tmp[i] = 0;
- else
- tmp[i] = 0 ^ output[j - 8 + i];
- }
- XCBDESEncrypt (tmp, (output + j), schedule, 1);
- }
-}
-
-#endif
-