Blame sunrpc/des_soft.c

Packit 6c4009
#if !defined(lint) && defined(SCCSIDS)
Packit 6c4009
static char sccsid[] = "@(#)des_soft.c	2.2 88/08/10 4.0 RPCSRC; from 1.13 88/02/08 SMI";
Packit 6c4009
#endif
Packit 6c4009
/*
Packit 6c4009
 * Copyright (c) 2010, Oracle America, Inc.
Packit 6c4009
 * Redistribution and use in source and binary forms, with or without
Packit 6c4009
 * modification, are permitted provided that the following conditions are
Packit 6c4009
 * met:
Packit 6c4009
 *
Packit 6c4009
 *     * Redistributions of source code must retain the above copyright
Packit 6c4009
 *       notice, this list of conditions and the following disclaimer.
Packit 6c4009
 *     * Redistributions in binary form must reproduce the above
Packit 6c4009
 *       copyright notice, this list of conditions and the following
Packit 6c4009
 *       disclaimer in the documentation and/or other materials
Packit 6c4009
 *       provided with the distribution.
Packit 6c4009
 *     * Neither the name of the "Oracle America, Inc." nor the names of its
Packit 6c4009
 *       contributors may be used to endorse or promote products derived
Packit 6c4009
 *       from this software without specific prior written permission.
Packit 6c4009
 *
Packit 6c4009
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 6c4009
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 6c4009
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
Packit 6c4009
 *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
Packit 6c4009
 *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
Packit 6c4009
 *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 6c4009
 *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
Packit 6c4009
 *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit 6c4009
 *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
Packit 6c4009
 *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Packit 6c4009
 *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 6c4009
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#include <rpc/des_crypt.h>
Packit 6c4009
#include <shlib-compat.h>
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Table giving odd parity in the low bit for ASCII characters
Packit 6c4009
 */
Packit 6c4009
static const char partab[128] =
Packit 6c4009
{
Packit 6c4009
  0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x07, 0x07,
Packit 6c4009
  0x08, 0x08, 0x0b, 0x0b, 0x0d, 0x0d, 0x0e, 0x0e,
Packit 6c4009
  0x10, 0x10, 0x13, 0x13, 0x15, 0x15, 0x16, 0x16,
Packit 6c4009
  0x19, 0x19, 0x1a, 0x1a, 0x1c, 0x1c, 0x1f, 0x1f,
Packit 6c4009
  0x20, 0x20, 0x23, 0x23, 0x25, 0x25, 0x26, 0x26,
Packit 6c4009
  0x29, 0x29, 0x2a, 0x2a, 0x2c, 0x2c, 0x2f, 0x2f,
Packit 6c4009
  0x31, 0x31, 0x32, 0x32, 0x34, 0x34, 0x37, 0x37,
Packit 6c4009
  0x38, 0x38, 0x3b, 0x3b, 0x3d, 0x3d, 0x3e, 0x3e,
Packit 6c4009
  0x40, 0x40, 0x43, 0x43, 0x45, 0x45, 0x46, 0x46,
Packit 6c4009
  0x49, 0x49, 0x4a, 0x4a, 0x4c, 0x4c, 0x4f, 0x4f,
Packit 6c4009
  0x51, 0x51, 0x52, 0x52, 0x54, 0x54, 0x57, 0x57,
Packit 6c4009
  0x58, 0x58, 0x5b, 0x5b, 0x5d, 0x5d, 0x5e, 0x5e,
Packit 6c4009
  0x61, 0x61, 0x62, 0x62, 0x64, 0x64, 0x67, 0x67,
Packit 6c4009
  0x68, 0x68, 0x6b, 0x6b, 0x6d, 0x6d, 0x6e, 0x6e,
Packit 6c4009
  0x70, 0x70, 0x73, 0x73, 0x75, 0x75, 0x76, 0x76,
Packit 6c4009
  0x79, 0x79, 0x7a, 0x7a, 0x7c, 0x7c, 0x7f, 0x7f,
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * Add odd parity to low bit of 8 byte key
Packit 6c4009
 */
Packit 6c4009
void
Packit 6c4009
des_setparity (char *p)
Packit 6c4009
{
Packit 6c4009
  int i;
Packit 6c4009
Packit 6c4009
  for (i = 0; i < 8; i++)
Packit 6c4009
    {
Packit 6c4009
      *p = partab[*p & 0x7f];
Packit 6c4009
      p++;
Packit 6c4009
    }
Packit 6c4009
}
Packit 6c4009
hidden_nolink (des_setparity, libc, GLIBC_2_1)