/*
* UFC-crypt: ultra fast crypt(3) implementation
*
* Copyright (C) 1991, 92, 93, 96, 97, 98, 2000 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; see the file COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* @(#)crypt_util.c 2.56 12/20/96
*
* Support routines
*
*/
#ifdef DEBUG
#include <stdio.h>
#endif
#include <string.h>
#ifndef STATIC
#define STATIC static
#endif
#ifndef DOS
#include "ufc-crypt.h"
#else
/*
* Thanks to greg%wind@plains.NoDak.edu (Greg W. Wettstein)
* for DOS patches
*/
#include "pl.h"
#include "ufc.h"
#endif
#include "crypt.h"
#include "crypt-private.h"
/* Prototypes for local functions. */
#if __STDC__ - 0
#ifndef __GNU_LIBRARY__
void _ufc_clearmem (char *start, int cnt);
void _ufc_copymem (char *from, char *to, int cnt);
#endif
#ifdef _UFC_32_
STATIC void shuffle_sb (long32 *k, ufc_long saltbits);
#else
STATIC void shuffle_sb (long64 *k, ufc_long saltbits);
#endif
#endif
/*
* Permutation done once on the 56 bit
* key derived from the original 8 byte ASCII key.
*/
static const int pc1[56] = {
57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18,
10, 2, 59, 51,