Browse Source

remove setkey and encrypt interfaces. they are useless and dangerous.

ok deraadt naddy
OPENBSD_5_7
tedu 9 years ago
parent
commit
9898588ce8
3 changed files with 9 additions and 116 deletions
  1. +2
    -2
      src/lib/libc/crypt/Makefile.inc
  2. +7
    -7
      src/lib/libc/crypt/crypt.c
  3. +0
    -107
      src/lib/libc/crypt/crypt2.c

+ 2
- 2
src/lib/libc/crypt/Makefile.inc View File

@ -1,8 +1,8 @@
# $OpenBSD: Makefile.inc,v 1.24 2014/11/20 19:18:25 tedu Exp $
# $OpenBSD: Makefile.inc,v 1.25 2014/12/08 20:36:18 tedu Exp $
.PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/crypt ${LIBCSRCDIR}/crypt
SRCS+= crypt.c crypt2.c cryptutil.c arc4random.c arc4random_uniform.c \
SRCS+= crypt.c cryptutil.c arc4random.c arc4random_uniform.c \
blowfish.c bcrypt.c
MAN+= crypt.3 crypt_checkpass.3 blowfish.3 arc4random.3


+ 7
- 7
src/lib/libc/crypt/crypt.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: crypt.c,v 1.24 2014/11/25 03:23:22 tedu Exp $ */
/* $OpenBSD: crypt.c,v 1.25 2014/12/08 20:36:18 tedu Exp $ */
/*
* FreeSec: libcrypt
@ -158,7 +158,7 @@ const u_int32_t _des_bits32[32] =
0x00000008, 0x00000004, 0x00000002, 0x00000001
};
const u_char _des_bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
static const u_char _des_bits8[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
static const u_int32_t *bits28, *bits24;
static u_char init_perm[64], final_perm[64];
@ -196,7 +196,7 @@ ascii_to_bin(char ch)
return(0);
}
void
static void
_des_init(void)
{
int i, j, b, k, inbit, obit;
@ -324,7 +324,7 @@ _des_init(void)
_des_initialised = 1;
}
u_int32_t
static u_int32_t
_des_setup_salt(int32_t salt)
{
u_int32_t obit, saltbit, saltbits;
@ -342,7 +342,7 @@ _des_setup_salt(int32_t salt)
return saltbits;
}
int
static int
des_setkey(const char *key)
{
u_int32_t k0, k1, rawkey0, rawkey1;
@ -422,7 +422,7 @@ des_setkey(const char *key)
return(0);
}
int
static int
_des_do_des(u_int32_t l_in, u_int32_t r_in, u_int32_t *l_out, u_int32_t *r_out,
int count, u_int32_t saltbits)
{
@ -539,7 +539,7 @@ _des_do_des(u_int32_t l_in, u_int32_t r_in, u_int32_t *l_out, u_int32_t *r_out,
return(0);
}
int
static int
des_cipher(const char *in, char *out, int32_t salt, int count)
{
u_int32_t l_out, r_out, rawl, rawr, saltbits;


+ 0
- 107
src/lib/libc/crypt/crypt2.c View File

@ -1,107 +0,0 @@
/* $OpenBSD: crypt2.c,v 1.5 2014/05/17 13:27:55 tedu Exp $ */
/*
* FreeSec: libcrypt
*
* Copyright (c) 1994 David Burren
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the author nor the names of other contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
* This is an original implementation of the DES and the crypt(3) interfaces
* by David Burren <davidb@werj.com.au>.
*
* An excellent reference on the underlying algorithm (and related
* algorithms) is:
*
* B. Schneier, Applied Cryptography: protocols, algorithms,
* and source code in C, John Wiley & Sons, 1994.
*
* Note that in that book's description of DES the lookups for the initial,
* pbox, and final permutations are inverted (this has been brought to the
* attention of the author). A list of errata for this book has been
* posted to the sci.crypt newsgroup by the author and is available for FTP.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <pwd.h>
#include <unistd.h>
#include <string.h>
#ifdef DEBUG
# include <stdio.h>
#endif
extern const u_char _des_bits8[8];
extern const u_int32_t _des_bits32[32];
extern int _des_initialised;
void _des_init(void);
u_int32_t _des_setup_salt(int32_t salt);
int _des_do_des(u_int32_t , u_int32_t , u_int32_t *, u_int32_t *, int, u_int32_t);
int
setkey(const char *key)
{
int i, j;
u_int32_t packed_keys[2];
u_char *p;
p = (u_char *) packed_keys;
for (i = 0; i < 8; i++) {
p[i] = 0;
for (j = 0; j < 8; j++)
if (*key++ & 1)
p[i] |= _des_bits8[j];
}
return(des_setkey((char *)p));
}
int
encrypt(char *block, int flag)
{
u_int32_t saltbits, io[2];
u_char *p;
int i, j, retval;
if (!_des_initialised)
_des_init();
saltbits = _des_setup_salt(0);
p = (u_char *)block;
for (i = 0; i < 2; i++) {
io[i] = 0L;
for (j = 0; j < 32; j++)
if (*p++ & 1)
io[i] |= _des_bits32[j];
}
retval = _des_do_des(io[0], io[1], io, io + 1, flag ? -1 : 1, saltbits);
for (i = 0; i < 2; i++)
for (j = 0; j < 32; j++)
block[(i << 5) | j] = (io[i] & _des_bits32[j]) ? 1 : 0;
return(retval);
}

Loading…
Cancel
Save